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 cacheUniqueFindersCache(MBThread mbThread) {
382 if (mbThread.isNew()) {
383 Object[] args = new Object[] {
384 Long.valueOf(mbThread.getRootMessageId())
385 };
386
387 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ROOTMESSAGEID, args,
388 Long.valueOf(1));
389 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID, args,
390 mbThread);
391 }
392 else {
393 MBThreadModelImpl mbThreadModelImpl = (MBThreadModelImpl)mbThread;
394
395 if ((mbThreadModelImpl.getColumnBitmask() &
396 FINDER_PATH_FETCH_BY_ROOTMESSAGEID.getColumnBitmask()) != 0) {
397 Object[] args = new Object[] {
398 Long.valueOf(mbThread.getRootMessageId())
399 };
400
401 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ROOTMESSAGEID,
402 args, Long.valueOf(1));
403 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID,
404 args, mbThread);
405 }
406 }
407 }
408
409 protected void clearUniqueFindersCache(MBThread mbThread) {
410 MBThreadModelImpl mbThreadModelImpl = (MBThreadModelImpl)mbThread;
411
412 Object[] args = new Object[] { Long.valueOf(mbThread.getRootMessageId()) };
413
414 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ROOTMESSAGEID, args);
415 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID, args);
416
417 if ((mbThreadModelImpl.getColumnBitmask() &
418 FINDER_PATH_FETCH_BY_ROOTMESSAGEID.getColumnBitmask()) != 0) {
419 args = new Object[] {
420 Long.valueOf(mbThreadModelImpl.getOriginalRootMessageId())
421 };
422
423 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ROOTMESSAGEID,
424 args);
425 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID,
426 args);
427 }
428 }
429
430
436 public MBThread create(long threadId) {
437 MBThread mbThread = new MBThreadImpl();
438
439 mbThread.setNew(true);
440 mbThread.setPrimaryKey(threadId);
441
442 return mbThread;
443 }
444
445
453 public MBThread remove(long threadId)
454 throws NoSuchThreadException, SystemException {
455 return remove(Long.valueOf(threadId));
456 }
457
458
466 @Override
467 public MBThread remove(Serializable primaryKey)
468 throws NoSuchThreadException, SystemException {
469 Session session = null;
470
471 try {
472 session = openSession();
473
474 MBThread mbThread = (MBThread)session.get(MBThreadImpl.class,
475 primaryKey);
476
477 if (mbThread == null) {
478 if (_log.isWarnEnabled()) {
479 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
480 }
481
482 throw new NoSuchThreadException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
483 primaryKey);
484 }
485
486 return remove(mbThread);
487 }
488 catch (NoSuchThreadException nsee) {
489 throw nsee;
490 }
491 catch (Exception e) {
492 throw processException(e);
493 }
494 finally {
495 closeSession(session);
496 }
497 }
498
499 @Override
500 protected MBThread removeImpl(MBThread mbThread) throws SystemException {
501 mbThread = toUnwrappedModel(mbThread);
502
503 Session session = null;
504
505 try {
506 session = openSession();
507
508 BatchSessionUtil.delete(session, mbThread);
509 }
510 catch (Exception e) {
511 throw processException(e);
512 }
513 finally {
514 closeSession(session);
515 }
516
517 clearCache(mbThread);
518
519 return mbThread;
520 }
521
522 @Override
523 public MBThread updateImpl(
524 com.liferay.portlet.messageboards.model.MBThread mbThread, boolean merge)
525 throws SystemException {
526 mbThread = toUnwrappedModel(mbThread);
527
528 boolean isNew = mbThread.isNew();
529
530 MBThreadModelImpl mbThreadModelImpl = (MBThreadModelImpl)mbThread;
531
532 Session session = null;
533
534 try {
535 session = openSession();
536
537 BatchSessionUtil.update(session, mbThread, merge);
538
539 mbThread.setNew(false);
540 }
541 catch (Exception e) {
542 throw processException(e);
543 }
544 finally {
545 closeSession(session);
546 }
547
548 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
549
550 if (isNew || !MBThreadModelImpl.COLUMN_BITMASK_ENABLED) {
551 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
552 }
553
554 else {
555 if ((mbThreadModelImpl.getColumnBitmask() &
556 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
557 Object[] args = new Object[] {
558 Long.valueOf(mbThreadModelImpl.getOriginalGroupId())
559 };
560
561 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
562 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
563 args);
564
565 args = new Object[] { Long.valueOf(mbThreadModelImpl.getGroupId()) };
566
567 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
568 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
569 args);
570 }
571
572 if ((mbThreadModelImpl.getColumnBitmask() &
573 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C.getColumnBitmask()) != 0) {
574 Object[] args = new Object[] {
575 Long.valueOf(mbThreadModelImpl.getOriginalGroupId()),
576 Long.valueOf(mbThreadModelImpl.getOriginalCategoryId())
577 };
578
579 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C, args);
580 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C,
581 args);
582
583 args = new Object[] {
584 Long.valueOf(mbThreadModelImpl.getGroupId()),
585 Long.valueOf(mbThreadModelImpl.getCategoryId())
586 };
587
588 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C, args);
589 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C,
590 args);
591 }
592
593 if ((mbThreadModelImpl.getColumnBitmask() &
594 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
595 Object[] args = new Object[] {
596 Long.valueOf(mbThreadModelImpl.getOriginalGroupId()),
597 Integer.valueOf(mbThreadModelImpl.getOriginalStatus())
598 };
599
600 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
601 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
602 args);
603
604 args = new Object[] {
605 Long.valueOf(mbThreadModelImpl.getGroupId()),
606 Integer.valueOf(mbThreadModelImpl.getStatus())
607 };
608
609 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
610 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
611 args);
612 }
613
614 if ((mbThreadModelImpl.getColumnBitmask() &
615 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P.getColumnBitmask()) != 0) {
616 Object[] args = new Object[] {
617 Long.valueOf(mbThreadModelImpl.getOriginalCategoryId()),
618 Double.valueOf(mbThreadModelImpl.getOriginalPriority())
619 };
620
621 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_P, args);
622 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P,
623 args);
624
625 args = new Object[] {
626 Long.valueOf(mbThreadModelImpl.getCategoryId()),
627 Double.valueOf(mbThreadModelImpl.getPriority())
628 };
629
630 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_P, args);
631 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P,
632 args);
633 }
634
635 if ((mbThreadModelImpl.getColumnBitmask() &
636 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P.getColumnBitmask()) != 0) {
637 Object[] args = new Object[] {
638 mbThreadModelImpl.getOriginalLastPostDate(),
639 Double.valueOf(mbThreadModelImpl.getOriginalPriority())
640 };
641
642 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_P, args);
643 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P,
644 args);
645
646 args = new Object[] {
647 mbThreadModelImpl.getLastPostDate(),
648 Double.valueOf(mbThreadModelImpl.getPriority())
649 };
650
651 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_P, args);
652 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P,
653 args);
654 }
655
656 if ((mbThreadModelImpl.getColumnBitmask() &
657 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L.getColumnBitmask()) != 0) {
658 Object[] args = new Object[] {
659 Long.valueOf(mbThreadModelImpl.getOriginalGroupId()),
660 Long.valueOf(mbThreadModelImpl.getOriginalCategoryId()),
661
662 mbThreadModelImpl.getOriginalLastPostDate()
663 };
664
665 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
666 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
667 args);
668
669 args = new Object[] {
670 Long.valueOf(mbThreadModelImpl.getGroupId()),
671 Long.valueOf(mbThreadModelImpl.getCategoryId()),
672
673 mbThreadModelImpl.getLastPostDate()
674 };
675
676 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
677 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
678 args);
679 }
680
681 if ((mbThreadModelImpl.getColumnBitmask() &
682 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_S.getColumnBitmask()) != 0) {
683 Object[] args = new Object[] {
684 Long.valueOf(mbThreadModelImpl.getOriginalGroupId()),
685 Long.valueOf(mbThreadModelImpl.getOriginalCategoryId()),
686 Integer.valueOf(mbThreadModelImpl.getOriginalStatus())
687 };
688
689 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
690 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_S,
691 args);
692
693 args = new Object[] {
694 Long.valueOf(mbThreadModelImpl.getGroupId()),
695 Long.valueOf(mbThreadModelImpl.getCategoryId()),
696 Integer.valueOf(mbThreadModelImpl.getStatus())
697 };
698
699 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
700 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_S,
701 args);
702 }
703 }
704
705 EntityCacheUtil.putResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
706 MBThreadImpl.class, mbThread.getPrimaryKey(), mbThread);
707
708 clearUniqueFindersCache(mbThread);
709 cacheUniqueFindersCache(mbThread);
710
711 return mbThread;
712 }
713
714 protected MBThread toUnwrappedModel(MBThread mbThread) {
715 if (mbThread instanceof MBThreadImpl) {
716 return mbThread;
717 }
718
719 MBThreadImpl mbThreadImpl = new MBThreadImpl();
720
721 mbThreadImpl.setNew(mbThread.isNew());
722 mbThreadImpl.setPrimaryKey(mbThread.getPrimaryKey());
723
724 mbThreadImpl.setThreadId(mbThread.getThreadId());
725 mbThreadImpl.setGroupId(mbThread.getGroupId());
726 mbThreadImpl.setCompanyId(mbThread.getCompanyId());
727 mbThreadImpl.setCategoryId(mbThread.getCategoryId());
728 mbThreadImpl.setRootMessageId(mbThread.getRootMessageId());
729 mbThreadImpl.setRootMessageUserId(mbThread.getRootMessageUserId());
730 mbThreadImpl.setMessageCount(mbThread.getMessageCount());
731 mbThreadImpl.setViewCount(mbThread.getViewCount());
732 mbThreadImpl.setLastPostByUserId(mbThread.getLastPostByUserId());
733 mbThreadImpl.setLastPostDate(mbThread.getLastPostDate());
734 mbThreadImpl.setPriority(mbThread.getPriority());
735 mbThreadImpl.setQuestion(mbThread.isQuestion());
736 mbThreadImpl.setStatus(mbThread.getStatus());
737 mbThreadImpl.setStatusByUserId(mbThread.getStatusByUserId());
738 mbThreadImpl.setStatusByUserName(mbThread.getStatusByUserName());
739 mbThreadImpl.setStatusDate(mbThread.getStatusDate());
740
741 return mbThreadImpl;
742 }
743
744
752 @Override
753 public MBThread findByPrimaryKey(Serializable primaryKey)
754 throws NoSuchModelException, SystemException {
755 return findByPrimaryKey(((Long)primaryKey).longValue());
756 }
757
758
766 public MBThread findByPrimaryKey(long threadId)
767 throws NoSuchThreadException, SystemException {
768 MBThread mbThread = fetchByPrimaryKey(threadId);
769
770 if (mbThread == null) {
771 if (_log.isWarnEnabled()) {
772 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + threadId);
773 }
774
775 throw new NoSuchThreadException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
776 threadId);
777 }
778
779 return mbThread;
780 }
781
782
789 @Override
790 public MBThread fetchByPrimaryKey(Serializable primaryKey)
791 throws SystemException {
792 return fetchByPrimaryKey(((Long)primaryKey).longValue());
793 }
794
795
802 public MBThread fetchByPrimaryKey(long threadId) throws SystemException {
803 MBThread mbThread = (MBThread)EntityCacheUtil.getResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
804 MBThreadImpl.class, threadId);
805
806 if (mbThread == _nullMBThread) {
807 return null;
808 }
809
810 if (mbThread == null) {
811 Session session = null;
812
813 boolean hasException = false;
814
815 try {
816 session = openSession();
817
818 mbThread = (MBThread)session.get(MBThreadImpl.class,
819 Long.valueOf(threadId));
820 }
821 catch (Exception e) {
822 hasException = true;
823
824 throw processException(e);
825 }
826 finally {
827 if (mbThread != null) {
828 cacheResult(mbThread);
829 }
830 else if (!hasException) {
831 EntityCacheUtil.putResult(MBThreadModelImpl.ENTITY_CACHE_ENABLED,
832 MBThreadImpl.class, threadId, _nullMBThread);
833 }
834
835 closeSession(session);
836 }
837 }
838
839 return mbThread;
840 }
841
842
849 public List<MBThread> findByGroupId(long groupId) throws SystemException {
850 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
851 }
852
853
866 public List<MBThread> findByGroupId(long groupId, int start, int end)
867 throws SystemException {
868 return findByGroupId(groupId, start, end, null);
869 }
870
871
885 public List<MBThread> findByGroupId(long groupId, int start, int end,
886 OrderByComparator orderByComparator) throws SystemException {
887 FinderPath finderPath = null;
888 Object[] finderArgs = null;
889
890 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
891 (orderByComparator == null)) {
892 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
893 finderArgs = new Object[] { groupId };
894 }
895 else {
896 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
897 finderArgs = new Object[] { groupId, start, end, orderByComparator };
898 }
899
900 List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(finderPath,
901 finderArgs, this);
902
903 if ((list != null) && !list.isEmpty()) {
904 for (MBThread mbThread : list) {
905 if ((groupId != mbThread.getGroupId())) {
906 list = null;
907
908 break;
909 }
910 }
911 }
912
913 if (list == null) {
914 StringBundler query = null;
915
916 if (orderByComparator != null) {
917 query = new StringBundler(3 +
918 (orderByComparator.getOrderByFields().length * 3));
919 }
920 else {
921 query = new StringBundler(3);
922 }
923
924 query.append(_SQL_SELECT_MBTHREAD_WHERE);
925
926 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
927
928 if (orderByComparator != null) {
929 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
930 orderByComparator);
931 }
932
933 else {
934 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
935 }
936
937 String sql = query.toString();
938
939 Session session = null;
940
941 try {
942 session = openSession();
943
944 Query q = session.createQuery(sql);
945
946 QueryPos qPos = QueryPos.getInstance(q);
947
948 qPos.add(groupId);
949
950 list = (List<MBThread>)QueryUtil.list(q, getDialect(), start,
951 end);
952 }
953 catch (Exception e) {
954 throw processException(e);
955 }
956 finally {
957 if (list == null) {
958 FinderCacheUtil.removeResult(finderPath, finderArgs);
959 }
960 else {
961 cacheResult(list);
962
963 FinderCacheUtil.putResult(finderPath, finderArgs, list);
964 }
965
966 closeSession(session);
967 }
968 }
969
970 return list;
971 }
972
973
982 public MBThread findByGroupId_First(long groupId,
983 OrderByComparator orderByComparator)
984 throws NoSuchThreadException, SystemException {
985 MBThread mbThread = fetchByGroupId_First(groupId, orderByComparator);
986
987 if (mbThread != null) {
988 return mbThread;
989 }
990
991 StringBundler msg = new StringBundler(4);
992
993 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
994
995 msg.append("groupId=");
996 msg.append(groupId);
997
998 msg.append(StringPool.CLOSE_CURLY_BRACE);
999
1000 throw new NoSuchThreadException(msg.toString());
1001 }
1002
1003
1011 public MBThread fetchByGroupId_First(long groupId,
1012 OrderByComparator orderByComparator) throws SystemException {
1013 List<MBThread> list = findByGroupId(groupId, 0, 1, orderByComparator);
1014
1015 if (!list.isEmpty()) {
1016 return list.get(0);
1017 }
1018
1019 return null;
1020 }
1021
1022
1031 public MBThread findByGroupId_Last(long groupId,
1032 OrderByComparator orderByComparator)
1033 throws NoSuchThreadException, SystemException {
1034 MBThread mbThread = fetchByGroupId_Last(groupId, orderByComparator);
1035
1036 if (mbThread != null) {
1037 return mbThread;
1038 }
1039
1040 StringBundler msg = new StringBundler(4);
1041
1042 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1043
1044 msg.append("groupId=");
1045 msg.append(groupId);
1046
1047 msg.append(StringPool.CLOSE_CURLY_BRACE);
1048
1049 throw new NoSuchThreadException(msg.toString());
1050 }
1051
1052
1060 public MBThread fetchByGroupId_Last(long groupId,
1061 OrderByComparator orderByComparator) throws SystemException {
1062 int count = countByGroupId(groupId);
1063
1064 List<MBThread> list = findByGroupId(groupId, count - 1, count,
1065 orderByComparator);
1066
1067 if (!list.isEmpty()) {
1068 return list.get(0);
1069 }
1070
1071 return null;
1072 }
1073
1074
1084 public MBThread[] findByGroupId_PrevAndNext(long threadId, long groupId,
1085 OrderByComparator orderByComparator)
1086 throws NoSuchThreadException, SystemException {
1087 MBThread mbThread = findByPrimaryKey(threadId);
1088
1089 Session session = null;
1090
1091 try {
1092 session = openSession();
1093
1094 MBThread[] array = new MBThreadImpl[3];
1095
1096 array[0] = getByGroupId_PrevAndNext(session, mbThread, groupId,
1097 orderByComparator, true);
1098
1099 array[1] = mbThread;
1100
1101 array[2] = getByGroupId_PrevAndNext(session, mbThread, groupId,
1102 orderByComparator, false);
1103
1104 return array;
1105 }
1106 catch (Exception e) {
1107 throw processException(e);
1108 }
1109 finally {
1110 closeSession(session);
1111 }
1112 }
1113
1114 protected MBThread getByGroupId_PrevAndNext(Session session,
1115 MBThread mbThread, long groupId, OrderByComparator orderByComparator,
1116 boolean previous) {
1117 StringBundler query = null;
1118
1119 if (orderByComparator != null) {
1120 query = new StringBundler(6 +
1121 (orderByComparator.getOrderByFields().length * 6));
1122 }
1123 else {
1124 query = new StringBundler(3);
1125 }
1126
1127 query.append(_SQL_SELECT_MBTHREAD_WHERE);
1128
1129 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1130
1131 if (orderByComparator != null) {
1132 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1133
1134 if (orderByConditionFields.length > 0) {
1135 query.append(WHERE_AND);
1136 }
1137
1138 for (int i = 0; i < orderByConditionFields.length; i++) {
1139 query.append(_ORDER_BY_ENTITY_ALIAS);
1140 query.append(orderByConditionFields[i]);
1141
1142 if ((i + 1) < orderByConditionFields.length) {
1143 if (orderByComparator.isAscending() ^ previous) {
1144 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1145 }
1146 else {
1147 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1148 }
1149 }
1150 else {
1151 if (orderByComparator.isAscending() ^ previous) {
1152 query.append(WHERE_GREATER_THAN);
1153 }
1154 else {
1155 query.append(WHERE_LESSER_THAN);
1156 }
1157 }
1158 }
1159
1160 query.append(ORDER_BY_CLAUSE);
1161
1162 String[] orderByFields = orderByComparator.getOrderByFields();
1163
1164 for (int i = 0; i < orderByFields.length; i++) {
1165 query.append(_ORDER_BY_ENTITY_ALIAS);
1166 query.append(orderByFields[i]);
1167
1168 if ((i + 1) < orderByFields.length) {
1169 if (orderByComparator.isAscending() ^ previous) {
1170 query.append(ORDER_BY_ASC_HAS_NEXT);
1171 }
1172 else {
1173 query.append(ORDER_BY_DESC_HAS_NEXT);
1174 }
1175 }
1176 else {
1177 if (orderByComparator.isAscending() ^ previous) {
1178 query.append(ORDER_BY_ASC);
1179 }
1180 else {
1181 query.append(ORDER_BY_DESC);
1182 }
1183 }
1184 }
1185 }
1186
1187 else {
1188 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
1189 }
1190
1191 String sql = query.toString();
1192
1193 Query q = session.createQuery(sql);
1194
1195 q.setFirstResult(0);
1196 q.setMaxResults(2);
1197
1198 QueryPos qPos = QueryPos.getInstance(q);
1199
1200 qPos.add(groupId);
1201
1202 if (orderByComparator != null) {
1203 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
1204
1205 for (Object value : values) {
1206 qPos.add(value);
1207 }
1208 }
1209
1210 List<MBThread> list = q.list();
1211
1212 if (list.size() == 2) {
1213 return list.get(1);
1214 }
1215 else {
1216 return null;
1217 }
1218 }
1219
1220
1227 public List<MBThread> filterFindByGroupId(long groupId)
1228 throws SystemException {
1229 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1230 QueryUtil.ALL_POS, null);
1231 }
1232
1233
1246 public List<MBThread> filterFindByGroupId(long groupId, int start, int end)
1247 throws SystemException {
1248 return filterFindByGroupId(groupId, start, end, null);
1249 }
1250
1251
1265 public List<MBThread> filterFindByGroupId(long groupId, int start, int end,
1266 OrderByComparator orderByComparator) throws SystemException {
1267 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1268 return findByGroupId(groupId, start, end, orderByComparator);
1269 }
1270
1271 StringBundler query = null;
1272
1273 if (orderByComparator != null) {
1274 query = new StringBundler(3 +
1275 (orderByComparator.getOrderByFields().length * 3));
1276 }
1277 else {
1278 query = new StringBundler(3);
1279 }
1280
1281 if (getDB().isSupportsInlineDistinct()) {
1282 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
1283 }
1284 else {
1285 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
1286 }
1287
1288 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1289
1290 if (!getDB().isSupportsInlineDistinct()) {
1291 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
1292 }
1293
1294 if (orderByComparator != null) {
1295 if (getDB().isSupportsInlineDistinct()) {
1296 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1297 orderByComparator);
1298 }
1299 else {
1300 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1301 orderByComparator);
1302 }
1303 }
1304
1305 else {
1306 if (getDB().isSupportsInlineDistinct()) {
1307 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
1308 }
1309 else {
1310 query.append(MBThreadModelImpl.ORDER_BY_SQL);
1311 }
1312 }
1313
1314 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1315 MBThread.class.getName(),
1316 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1317
1318 Session session = null;
1319
1320 try {
1321 session = openSession();
1322
1323 SQLQuery q = session.createSQLQuery(sql);
1324
1325 if (getDB().isSupportsInlineDistinct()) {
1326 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
1327 }
1328 else {
1329 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
1330 }
1331
1332 QueryPos qPos = QueryPos.getInstance(q);
1333
1334 qPos.add(groupId);
1335
1336 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
1337 }
1338 catch (Exception e) {
1339 throw processException(e);
1340 }
1341 finally {
1342 closeSession(session);
1343 }
1344 }
1345
1346
1356 public MBThread[] filterFindByGroupId_PrevAndNext(long threadId,
1357 long groupId, OrderByComparator orderByComparator)
1358 throws NoSuchThreadException, SystemException {
1359 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1360 return findByGroupId_PrevAndNext(threadId, groupId,
1361 orderByComparator);
1362 }
1363
1364 MBThread mbThread = findByPrimaryKey(threadId);
1365
1366 Session session = null;
1367
1368 try {
1369 session = openSession();
1370
1371 MBThread[] array = new MBThreadImpl[3];
1372
1373 array[0] = filterGetByGroupId_PrevAndNext(session, mbThread,
1374 groupId, orderByComparator, true);
1375
1376 array[1] = mbThread;
1377
1378 array[2] = filterGetByGroupId_PrevAndNext(session, mbThread,
1379 groupId, orderByComparator, false);
1380
1381 return array;
1382 }
1383 catch (Exception e) {
1384 throw processException(e);
1385 }
1386 finally {
1387 closeSession(session);
1388 }
1389 }
1390
1391 protected MBThread filterGetByGroupId_PrevAndNext(Session session,
1392 MBThread mbThread, long groupId, OrderByComparator orderByComparator,
1393 boolean previous) {
1394 StringBundler query = null;
1395
1396 if (orderByComparator != null) {
1397 query = new StringBundler(6 +
1398 (orderByComparator.getOrderByFields().length * 6));
1399 }
1400 else {
1401 query = new StringBundler(3);
1402 }
1403
1404 if (getDB().isSupportsInlineDistinct()) {
1405 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
1406 }
1407 else {
1408 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
1409 }
1410
1411 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1412
1413 if (!getDB().isSupportsInlineDistinct()) {
1414 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
1415 }
1416
1417 if (orderByComparator != null) {
1418 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1419
1420 if (orderByConditionFields.length > 0) {
1421 query.append(WHERE_AND);
1422 }
1423
1424 for (int i = 0; i < orderByConditionFields.length; i++) {
1425 if (getDB().isSupportsInlineDistinct()) {
1426 query.append(_ORDER_BY_ENTITY_ALIAS);
1427 }
1428 else {
1429 query.append(_ORDER_BY_ENTITY_TABLE);
1430 }
1431
1432 query.append(orderByConditionFields[i]);
1433
1434 if ((i + 1) < orderByConditionFields.length) {
1435 if (orderByComparator.isAscending() ^ previous) {
1436 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1437 }
1438 else {
1439 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1440 }
1441 }
1442 else {
1443 if (orderByComparator.isAscending() ^ previous) {
1444 query.append(WHERE_GREATER_THAN);
1445 }
1446 else {
1447 query.append(WHERE_LESSER_THAN);
1448 }
1449 }
1450 }
1451
1452 query.append(ORDER_BY_CLAUSE);
1453
1454 String[] orderByFields = orderByComparator.getOrderByFields();
1455
1456 for (int i = 0; i < orderByFields.length; i++) {
1457 if (getDB().isSupportsInlineDistinct()) {
1458 query.append(_ORDER_BY_ENTITY_ALIAS);
1459 }
1460 else {
1461 query.append(_ORDER_BY_ENTITY_TABLE);
1462 }
1463
1464 query.append(orderByFields[i]);
1465
1466 if ((i + 1) < orderByFields.length) {
1467 if (orderByComparator.isAscending() ^ previous) {
1468 query.append(ORDER_BY_ASC_HAS_NEXT);
1469 }
1470 else {
1471 query.append(ORDER_BY_DESC_HAS_NEXT);
1472 }
1473 }
1474 else {
1475 if (orderByComparator.isAscending() ^ previous) {
1476 query.append(ORDER_BY_ASC);
1477 }
1478 else {
1479 query.append(ORDER_BY_DESC);
1480 }
1481 }
1482 }
1483 }
1484
1485 else {
1486 if (getDB().isSupportsInlineDistinct()) {
1487 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
1488 }
1489 else {
1490 query.append(MBThreadModelImpl.ORDER_BY_SQL);
1491 }
1492 }
1493
1494 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1495 MBThread.class.getName(),
1496 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1497
1498 SQLQuery q = session.createSQLQuery(sql);
1499
1500 q.setFirstResult(0);
1501 q.setMaxResults(2);
1502
1503 if (getDB().isSupportsInlineDistinct()) {
1504 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
1505 }
1506 else {
1507 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
1508 }
1509
1510 QueryPos qPos = QueryPos.getInstance(q);
1511
1512 qPos.add(groupId);
1513
1514 if (orderByComparator != null) {
1515 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
1516
1517 for (Object value : values) {
1518 qPos.add(value);
1519 }
1520 }
1521
1522 List<MBThread> list = q.list();
1523
1524 if (list.size() == 2) {
1525 return list.get(1);
1526 }
1527 else {
1528 return null;
1529 }
1530 }
1531
1532
1540 public MBThread findByRootMessageId(long rootMessageId)
1541 throws NoSuchThreadException, SystemException {
1542 MBThread mbThread = fetchByRootMessageId(rootMessageId);
1543
1544 if (mbThread == null) {
1545 StringBundler msg = new StringBundler(4);
1546
1547 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1548
1549 msg.append("rootMessageId=");
1550 msg.append(rootMessageId);
1551
1552 msg.append(StringPool.CLOSE_CURLY_BRACE);
1553
1554 if (_log.isWarnEnabled()) {
1555 _log.warn(msg.toString());
1556 }
1557
1558 throw new NoSuchThreadException(msg.toString());
1559 }
1560
1561 return mbThread;
1562 }
1563
1564
1571 public MBThread fetchByRootMessageId(long rootMessageId)
1572 throws SystemException {
1573 return fetchByRootMessageId(rootMessageId, true);
1574 }
1575
1576
1584 public MBThread fetchByRootMessageId(long rootMessageId,
1585 boolean retrieveFromCache) throws SystemException {
1586 Object[] finderArgs = new Object[] { rootMessageId };
1587
1588 Object result = null;
1589
1590 if (retrieveFromCache) {
1591 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID,
1592 finderArgs, this);
1593 }
1594
1595 if (result instanceof MBThread) {
1596 MBThread mbThread = (MBThread)result;
1597
1598 if ((rootMessageId != mbThread.getRootMessageId())) {
1599 result = null;
1600 }
1601 }
1602
1603 if (result == null) {
1604 StringBundler query = new StringBundler(3);
1605
1606 query.append(_SQL_SELECT_MBTHREAD_WHERE);
1607
1608 query.append(_FINDER_COLUMN_ROOTMESSAGEID_ROOTMESSAGEID_2);
1609
1610 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
1611
1612 String sql = query.toString();
1613
1614 Session session = null;
1615
1616 try {
1617 session = openSession();
1618
1619 Query q = session.createQuery(sql);
1620
1621 QueryPos qPos = QueryPos.getInstance(q);
1622
1623 qPos.add(rootMessageId);
1624
1625 List<MBThread> list = q.list();
1626
1627 result = list;
1628
1629 MBThread mbThread = null;
1630
1631 if (list.isEmpty()) {
1632 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID,
1633 finderArgs, list);
1634 }
1635 else {
1636 mbThread = list.get(0);
1637
1638 cacheResult(mbThread);
1639
1640 if ((mbThread.getRootMessageId() != rootMessageId)) {
1641 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID,
1642 finderArgs, mbThread);
1643 }
1644 }
1645
1646 return mbThread;
1647 }
1648 catch (Exception e) {
1649 throw processException(e);
1650 }
1651 finally {
1652 if (result == null) {
1653 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_ROOTMESSAGEID,
1654 finderArgs);
1655 }
1656
1657 closeSession(session);
1658 }
1659 }
1660 else {
1661 if (result instanceof List<?>) {
1662 return null;
1663 }
1664 else {
1665 return (MBThread)result;
1666 }
1667 }
1668 }
1669
1670
1678 public List<MBThread> findByG_C(long groupId, long categoryId)
1679 throws SystemException {
1680 return findByG_C(groupId, categoryId, QueryUtil.ALL_POS,
1681 QueryUtil.ALL_POS, null);
1682 }
1683
1684
1698 public List<MBThread> findByG_C(long groupId, long categoryId, int start,
1699 int end) throws SystemException {
1700 return findByG_C(groupId, categoryId, start, end, null);
1701 }
1702
1703
1718 public List<MBThread> findByG_C(long groupId, long categoryId, int start,
1719 int end, OrderByComparator orderByComparator) throws SystemException {
1720 FinderPath finderPath = null;
1721 Object[] finderArgs = null;
1722
1723 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1724 (orderByComparator == null)) {
1725 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C;
1726 finderArgs = new Object[] { groupId, categoryId };
1727 }
1728 else {
1729 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C;
1730 finderArgs = new Object[] {
1731 groupId, categoryId,
1732
1733 start, end, orderByComparator
1734 };
1735 }
1736
1737 List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(finderPath,
1738 finderArgs, this);
1739
1740 if ((list != null) && !list.isEmpty()) {
1741 for (MBThread mbThread : list) {
1742 if ((groupId != mbThread.getGroupId()) ||
1743 (categoryId != mbThread.getCategoryId())) {
1744 list = null;
1745
1746 break;
1747 }
1748 }
1749 }
1750
1751 if (list == null) {
1752 StringBundler query = null;
1753
1754 if (orderByComparator != null) {
1755 query = new StringBundler(4 +
1756 (orderByComparator.getOrderByFields().length * 3));
1757 }
1758 else {
1759 query = new StringBundler(4);
1760 }
1761
1762 query.append(_SQL_SELECT_MBTHREAD_WHERE);
1763
1764 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
1765
1766 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
1767
1768 if (orderByComparator != null) {
1769 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1770 orderByComparator);
1771 }
1772
1773 else {
1774 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
1775 }
1776
1777 String sql = query.toString();
1778
1779 Session session = null;
1780
1781 try {
1782 session = openSession();
1783
1784 Query q = session.createQuery(sql);
1785
1786 QueryPos qPos = QueryPos.getInstance(q);
1787
1788 qPos.add(groupId);
1789
1790 qPos.add(categoryId);
1791
1792 list = (List<MBThread>)QueryUtil.list(q, getDialect(), start,
1793 end);
1794 }
1795 catch (Exception e) {
1796 throw processException(e);
1797 }
1798 finally {
1799 if (list == null) {
1800 FinderCacheUtil.removeResult(finderPath, finderArgs);
1801 }
1802 else {
1803 cacheResult(list);
1804
1805 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1806 }
1807
1808 closeSession(session);
1809 }
1810 }
1811
1812 return list;
1813 }
1814
1815
1825 public MBThread findByG_C_First(long groupId, long categoryId,
1826 OrderByComparator orderByComparator)
1827 throws NoSuchThreadException, SystemException {
1828 MBThread mbThread = fetchByG_C_First(groupId, categoryId,
1829 orderByComparator);
1830
1831 if (mbThread != null) {
1832 return mbThread;
1833 }
1834
1835 StringBundler msg = new StringBundler(6);
1836
1837 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1838
1839 msg.append("groupId=");
1840 msg.append(groupId);
1841
1842 msg.append(", categoryId=");
1843 msg.append(categoryId);
1844
1845 msg.append(StringPool.CLOSE_CURLY_BRACE);
1846
1847 throw new NoSuchThreadException(msg.toString());
1848 }
1849
1850
1859 public MBThread fetchByG_C_First(long groupId, long categoryId,
1860 OrderByComparator orderByComparator) throws SystemException {
1861 List<MBThread> list = findByG_C(groupId, categoryId, 0, 1,
1862 orderByComparator);
1863
1864 if (!list.isEmpty()) {
1865 return list.get(0);
1866 }
1867
1868 return null;
1869 }
1870
1871
1881 public MBThread findByG_C_Last(long groupId, long categoryId,
1882 OrderByComparator orderByComparator)
1883 throws NoSuchThreadException, SystemException {
1884 MBThread mbThread = fetchByG_C_Last(groupId, categoryId,
1885 orderByComparator);
1886
1887 if (mbThread != null) {
1888 return mbThread;
1889 }
1890
1891 StringBundler msg = new StringBundler(6);
1892
1893 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1894
1895 msg.append("groupId=");
1896 msg.append(groupId);
1897
1898 msg.append(", categoryId=");
1899 msg.append(categoryId);
1900
1901 msg.append(StringPool.CLOSE_CURLY_BRACE);
1902
1903 throw new NoSuchThreadException(msg.toString());
1904 }
1905
1906
1915 public MBThread fetchByG_C_Last(long groupId, long categoryId,
1916 OrderByComparator orderByComparator) throws SystemException {
1917 int count = countByG_C(groupId, categoryId);
1918
1919 List<MBThread> list = findByG_C(groupId, categoryId, count - 1, count,
1920 orderByComparator);
1921
1922 if (!list.isEmpty()) {
1923 return list.get(0);
1924 }
1925
1926 return null;
1927 }
1928
1929
1940 public MBThread[] findByG_C_PrevAndNext(long threadId, long groupId,
1941 long categoryId, OrderByComparator orderByComparator)
1942 throws NoSuchThreadException, SystemException {
1943 MBThread mbThread = findByPrimaryKey(threadId);
1944
1945 Session session = null;
1946
1947 try {
1948 session = openSession();
1949
1950 MBThread[] array = new MBThreadImpl[3];
1951
1952 array[0] = getByG_C_PrevAndNext(session, mbThread, groupId,
1953 categoryId, orderByComparator, true);
1954
1955 array[1] = mbThread;
1956
1957 array[2] = getByG_C_PrevAndNext(session, mbThread, groupId,
1958 categoryId, orderByComparator, false);
1959
1960 return array;
1961 }
1962 catch (Exception e) {
1963 throw processException(e);
1964 }
1965 finally {
1966 closeSession(session);
1967 }
1968 }
1969
1970 protected MBThread getByG_C_PrevAndNext(Session session, MBThread mbThread,
1971 long groupId, long categoryId, OrderByComparator orderByComparator,
1972 boolean previous) {
1973 StringBundler query = null;
1974
1975 if (orderByComparator != null) {
1976 query = new StringBundler(6 +
1977 (orderByComparator.getOrderByFields().length * 6));
1978 }
1979 else {
1980 query = new StringBundler(3);
1981 }
1982
1983 query.append(_SQL_SELECT_MBTHREAD_WHERE);
1984
1985 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
1986
1987 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
1988
1989 if (orderByComparator != null) {
1990 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1991
1992 if (orderByConditionFields.length > 0) {
1993 query.append(WHERE_AND);
1994 }
1995
1996 for (int i = 0; i < orderByConditionFields.length; i++) {
1997 query.append(_ORDER_BY_ENTITY_ALIAS);
1998 query.append(orderByConditionFields[i]);
1999
2000 if ((i + 1) < orderByConditionFields.length) {
2001 if (orderByComparator.isAscending() ^ previous) {
2002 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2003 }
2004 else {
2005 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2006 }
2007 }
2008 else {
2009 if (orderByComparator.isAscending() ^ previous) {
2010 query.append(WHERE_GREATER_THAN);
2011 }
2012 else {
2013 query.append(WHERE_LESSER_THAN);
2014 }
2015 }
2016 }
2017
2018 query.append(ORDER_BY_CLAUSE);
2019
2020 String[] orderByFields = orderByComparator.getOrderByFields();
2021
2022 for (int i = 0; i < orderByFields.length; i++) {
2023 query.append(_ORDER_BY_ENTITY_ALIAS);
2024 query.append(orderByFields[i]);
2025
2026 if ((i + 1) < orderByFields.length) {
2027 if (orderByComparator.isAscending() ^ previous) {
2028 query.append(ORDER_BY_ASC_HAS_NEXT);
2029 }
2030 else {
2031 query.append(ORDER_BY_DESC_HAS_NEXT);
2032 }
2033 }
2034 else {
2035 if (orderByComparator.isAscending() ^ previous) {
2036 query.append(ORDER_BY_ASC);
2037 }
2038 else {
2039 query.append(ORDER_BY_DESC);
2040 }
2041 }
2042 }
2043 }
2044
2045 else {
2046 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
2047 }
2048
2049 String sql = query.toString();
2050
2051 Query q = session.createQuery(sql);
2052
2053 q.setFirstResult(0);
2054 q.setMaxResults(2);
2055
2056 QueryPos qPos = QueryPos.getInstance(q);
2057
2058 qPos.add(groupId);
2059
2060 qPos.add(categoryId);
2061
2062 if (orderByComparator != null) {
2063 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
2064
2065 for (Object value : values) {
2066 qPos.add(value);
2067 }
2068 }
2069
2070 List<MBThread> list = q.list();
2071
2072 if (list.size() == 2) {
2073 return list.get(1);
2074 }
2075 else {
2076 return null;
2077 }
2078 }
2079
2080
2092 public List<MBThread> findByG_C(long groupId, long[] categoryIds)
2093 throws SystemException {
2094 return findByG_C(groupId, categoryIds, QueryUtil.ALL_POS,
2095 QueryUtil.ALL_POS, null);
2096 }
2097
2098
2112 public List<MBThread> findByG_C(long groupId, long[] categoryIds,
2113 int start, int end) throws SystemException {
2114 return findByG_C(groupId, categoryIds, start, end, null);
2115 }
2116
2117
2132 public List<MBThread> findByG_C(long groupId, long[] categoryIds,
2133 int start, int end, OrderByComparator orderByComparator)
2134 throws SystemException {
2135 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C;
2136 Object[] finderArgs = null;
2137
2138 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2139 (orderByComparator == null)) {
2140 finderArgs = new Object[] { groupId, StringUtil.merge(categoryIds) };
2141 }
2142 else {
2143 finderArgs = new Object[] {
2144 groupId, StringUtil.merge(categoryIds),
2145
2146 start, end, orderByComparator
2147 };
2148 }
2149
2150 List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(finderPath,
2151 finderArgs, this);
2152
2153 if ((list != null) && !list.isEmpty()) {
2154 for (MBThread mbThread : list) {
2155 if ((groupId != mbThread.getGroupId()) ||
2156 !ArrayUtil.contains(categoryIds,
2157 mbThread.getCategoryId())) {
2158 list = null;
2159
2160 break;
2161 }
2162 }
2163 }
2164
2165 if (list == null) {
2166 StringBundler query = new StringBundler();
2167
2168 query.append(_SQL_SELECT_MBTHREAD_WHERE);
2169
2170 boolean conjunctionable = false;
2171
2172 if (conjunctionable) {
2173 query.append(WHERE_AND);
2174 }
2175
2176 query.append(_FINDER_COLUMN_G_C_GROUPID_5);
2177
2178 conjunctionable = true;
2179
2180 if ((categoryIds == null) || (categoryIds.length > 0)) {
2181 if (conjunctionable) {
2182 query.append(WHERE_AND);
2183 }
2184
2185 query.append(StringPool.OPEN_PARENTHESIS);
2186
2187 for (int i = 0; i < categoryIds.length; i++) {
2188 query.append(_FINDER_COLUMN_G_C_CATEGORYID_5);
2189
2190 if ((i + 1) < categoryIds.length) {
2191 query.append(WHERE_OR);
2192 }
2193 }
2194
2195 query.append(StringPool.CLOSE_PARENTHESIS);
2196
2197 conjunctionable = true;
2198 }
2199
2200 if (orderByComparator != null) {
2201 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2202 orderByComparator);
2203 }
2204
2205 else {
2206 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
2207 }
2208
2209 String sql = query.toString();
2210
2211 Session session = null;
2212
2213 try {
2214 session = openSession();
2215
2216 Query q = session.createQuery(sql);
2217
2218 QueryPos qPos = QueryPos.getInstance(q);
2219
2220 qPos.add(groupId);
2221
2222 if (categoryIds != null) {
2223 qPos.add(categoryIds);
2224 }
2225
2226 list = (List<MBThread>)QueryUtil.list(q, getDialect(), start,
2227 end);
2228 }
2229 catch (Exception e) {
2230 throw processException(e);
2231 }
2232 finally {
2233 if (list == null) {
2234 FinderCacheUtil.removeResult(finderPath, finderArgs);
2235 }
2236 else {
2237 cacheResult(list);
2238
2239 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2240 }
2241
2242 closeSession(session);
2243 }
2244 }
2245
2246 return list;
2247 }
2248
2249
2257 public List<MBThread> filterFindByG_C(long groupId, long categoryId)
2258 throws SystemException {
2259 return filterFindByG_C(groupId, categoryId, QueryUtil.ALL_POS,
2260 QueryUtil.ALL_POS, null);
2261 }
2262
2263
2277 public List<MBThread> filterFindByG_C(long groupId, long categoryId,
2278 int start, int end) throws SystemException {
2279 return filterFindByG_C(groupId, categoryId, start, end, null);
2280 }
2281
2282
2297 public List<MBThread> filterFindByG_C(long groupId, long categoryId,
2298 int start, int end, OrderByComparator orderByComparator)
2299 throws SystemException {
2300 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2301 return findByG_C(groupId, categoryId, start, end, orderByComparator);
2302 }
2303
2304 StringBundler query = null;
2305
2306 if (orderByComparator != null) {
2307 query = new StringBundler(4 +
2308 (orderByComparator.getOrderByFields().length * 3));
2309 }
2310 else {
2311 query = new StringBundler(4);
2312 }
2313
2314 if (getDB().isSupportsInlineDistinct()) {
2315 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
2316 }
2317 else {
2318 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
2319 }
2320
2321 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
2322
2323 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
2324
2325 if (!getDB().isSupportsInlineDistinct()) {
2326 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
2327 }
2328
2329 if (orderByComparator != null) {
2330 if (getDB().isSupportsInlineDistinct()) {
2331 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2332 orderByComparator);
2333 }
2334 else {
2335 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2336 orderByComparator);
2337 }
2338 }
2339
2340 else {
2341 if (getDB().isSupportsInlineDistinct()) {
2342 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
2343 }
2344 else {
2345 query.append(MBThreadModelImpl.ORDER_BY_SQL);
2346 }
2347 }
2348
2349 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2350 MBThread.class.getName(),
2351 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2352
2353 Session session = null;
2354
2355 try {
2356 session = openSession();
2357
2358 SQLQuery q = session.createSQLQuery(sql);
2359
2360 if (getDB().isSupportsInlineDistinct()) {
2361 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
2362 }
2363 else {
2364 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
2365 }
2366
2367 QueryPos qPos = QueryPos.getInstance(q);
2368
2369 qPos.add(groupId);
2370
2371 qPos.add(categoryId);
2372
2373 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
2374 }
2375 catch (Exception e) {
2376 throw processException(e);
2377 }
2378 finally {
2379 closeSession(session);
2380 }
2381 }
2382
2383
2394 public MBThread[] filterFindByG_C_PrevAndNext(long threadId, long groupId,
2395 long categoryId, OrderByComparator orderByComparator)
2396 throws NoSuchThreadException, SystemException {
2397 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2398 return findByG_C_PrevAndNext(threadId, groupId, categoryId,
2399 orderByComparator);
2400 }
2401
2402 MBThread mbThread = findByPrimaryKey(threadId);
2403
2404 Session session = null;
2405
2406 try {
2407 session = openSession();
2408
2409 MBThread[] array = new MBThreadImpl[3];
2410
2411 array[0] = filterGetByG_C_PrevAndNext(session, mbThread, groupId,
2412 categoryId, orderByComparator, true);
2413
2414 array[1] = mbThread;
2415
2416 array[2] = filterGetByG_C_PrevAndNext(session, mbThread, groupId,
2417 categoryId, orderByComparator, false);
2418
2419 return array;
2420 }
2421 catch (Exception e) {
2422 throw processException(e);
2423 }
2424 finally {
2425 closeSession(session);
2426 }
2427 }
2428
2429 protected MBThread filterGetByG_C_PrevAndNext(Session session,
2430 MBThread mbThread, long groupId, long categoryId,
2431 OrderByComparator orderByComparator, boolean previous) {
2432 StringBundler query = null;
2433
2434 if (orderByComparator != null) {
2435 query = new StringBundler(6 +
2436 (orderByComparator.getOrderByFields().length * 6));
2437 }
2438 else {
2439 query = new StringBundler(3);
2440 }
2441
2442 if (getDB().isSupportsInlineDistinct()) {
2443 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
2444 }
2445 else {
2446 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
2447 }
2448
2449 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
2450
2451 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
2452
2453 if (!getDB().isSupportsInlineDistinct()) {
2454 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
2455 }
2456
2457 if (orderByComparator != null) {
2458 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2459
2460 if (orderByConditionFields.length > 0) {
2461 query.append(WHERE_AND);
2462 }
2463
2464 for (int i = 0; i < orderByConditionFields.length; i++) {
2465 if (getDB().isSupportsInlineDistinct()) {
2466 query.append(_ORDER_BY_ENTITY_ALIAS);
2467 }
2468 else {
2469 query.append(_ORDER_BY_ENTITY_TABLE);
2470 }
2471
2472 query.append(orderByConditionFields[i]);
2473
2474 if ((i + 1) < orderByConditionFields.length) {
2475 if (orderByComparator.isAscending() ^ previous) {
2476 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2477 }
2478 else {
2479 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2480 }
2481 }
2482 else {
2483 if (orderByComparator.isAscending() ^ previous) {
2484 query.append(WHERE_GREATER_THAN);
2485 }
2486 else {
2487 query.append(WHERE_LESSER_THAN);
2488 }
2489 }
2490 }
2491
2492 query.append(ORDER_BY_CLAUSE);
2493
2494 String[] orderByFields = orderByComparator.getOrderByFields();
2495
2496 for (int i = 0; i < orderByFields.length; i++) {
2497 if (getDB().isSupportsInlineDistinct()) {
2498 query.append(_ORDER_BY_ENTITY_ALIAS);
2499 }
2500 else {
2501 query.append(_ORDER_BY_ENTITY_TABLE);
2502 }
2503
2504 query.append(orderByFields[i]);
2505
2506 if ((i + 1) < orderByFields.length) {
2507 if (orderByComparator.isAscending() ^ previous) {
2508 query.append(ORDER_BY_ASC_HAS_NEXT);
2509 }
2510 else {
2511 query.append(ORDER_BY_DESC_HAS_NEXT);
2512 }
2513 }
2514 else {
2515 if (orderByComparator.isAscending() ^ previous) {
2516 query.append(ORDER_BY_ASC);
2517 }
2518 else {
2519 query.append(ORDER_BY_DESC);
2520 }
2521 }
2522 }
2523 }
2524
2525 else {
2526 if (getDB().isSupportsInlineDistinct()) {
2527 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
2528 }
2529 else {
2530 query.append(MBThreadModelImpl.ORDER_BY_SQL);
2531 }
2532 }
2533
2534 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2535 MBThread.class.getName(),
2536 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2537
2538 SQLQuery q = session.createSQLQuery(sql);
2539
2540 q.setFirstResult(0);
2541 q.setMaxResults(2);
2542
2543 if (getDB().isSupportsInlineDistinct()) {
2544 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
2545 }
2546 else {
2547 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
2548 }
2549
2550 QueryPos qPos = QueryPos.getInstance(q);
2551
2552 qPos.add(groupId);
2553
2554 qPos.add(categoryId);
2555
2556 if (orderByComparator != null) {
2557 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
2558
2559 for (Object value : values) {
2560 qPos.add(value);
2561 }
2562 }
2563
2564 List<MBThread> list = q.list();
2565
2566 if (list.size() == 2) {
2567 return list.get(1);
2568 }
2569 else {
2570 return null;
2571 }
2572 }
2573
2574
2582 public List<MBThread> filterFindByG_C(long groupId, long[] categoryIds)
2583 throws SystemException {
2584 return filterFindByG_C(groupId, categoryIds, QueryUtil.ALL_POS,
2585 QueryUtil.ALL_POS, null);
2586 }
2587
2588
2602 public List<MBThread> filterFindByG_C(long groupId, long[] categoryIds,
2603 int start, int end) throws SystemException {
2604 return filterFindByG_C(groupId, categoryIds, start, end, null);
2605 }
2606
2607
2622 public List<MBThread> filterFindByG_C(long groupId, long[] categoryIds,
2623 int start, int end, OrderByComparator orderByComparator)
2624 throws SystemException {
2625 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2626 return findByG_C(groupId, categoryIds, start, end, orderByComparator);
2627 }
2628
2629 StringBundler query = new StringBundler();
2630
2631 if (getDB().isSupportsInlineDistinct()) {
2632 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
2633 }
2634 else {
2635 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
2636 }
2637
2638 boolean conjunctionable = false;
2639
2640 if (conjunctionable) {
2641 query.append(WHERE_AND);
2642 }
2643
2644 query.append(_FINDER_COLUMN_G_C_GROUPID_5);
2645
2646 conjunctionable = true;
2647
2648 if ((categoryIds == null) || (categoryIds.length > 0)) {
2649 if (conjunctionable) {
2650 query.append(WHERE_AND);
2651 }
2652
2653 query.append(StringPool.OPEN_PARENTHESIS);
2654
2655 for (int i = 0; i < categoryIds.length; i++) {
2656 query.append(_FINDER_COLUMN_G_C_CATEGORYID_5);
2657
2658 if ((i + 1) < categoryIds.length) {
2659 query.append(WHERE_OR);
2660 }
2661 }
2662
2663 query.append(StringPool.CLOSE_PARENTHESIS);
2664
2665 conjunctionable = true;
2666 }
2667
2668 if (!getDB().isSupportsInlineDistinct()) {
2669 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
2670 }
2671
2672 if (orderByComparator != null) {
2673 if (getDB().isSupportsInlineDistinct()) {
2674 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2675 orderByComparator);
2676 }
2677 else {
2678 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2679 orderByComparator);
2680 }
2681 }
2682
2683 else {
2684 if (getDB().isSupportsInlineDistinct()) {
2685 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
2686 }
2687 else {
2688 query.append(MBThreadModelImpl.ORDER_BY_SQL);
2689 }
2690 }
2691
2692 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2693 MBThread.class.getName(),
2694 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2695
2696 Session session = null;
2697
2698 try {
2699 session = openSession();
2700
2701 SQLQuery q = session.createSQLQuery(sql);
2702
2703 if (getDB().isSupportsInlineDistinct()) {
2704 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
2705 }
2706 else {
2707 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
2708 }
2709
2710 QueryPos qPos = QueryPos.getInstance(q);
2711
2712 qPos.add(groupId);
2713
2714 if (categoryIds != null) {
2715 qPos.add(categoryIds);
2716 }
2717
2718 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
2719 }
2720 catch (Exception e) {
2721 throw processException(e);
2722 }
2723 finally {
2724 closeSession(session);
2725 }
2726 }
2727
2728
2736 public List<MBThread> findByG_NotC(long groupId, long categoryId)
2737 throws SystemException {
2738 return findByG_NotC(groupId, categoryId, QueryUtil.ALL_POS,
2739 QueryUtil.ALL_POS, null);
2740 }
2741
2742
2756 public List<MBThread> findByG_NotC(long groupId, long categoryId,
2757 int start, int end) throws SystemException {
2758 return findByG_NotC(groupId, categoryId, start, end, null);
2759 }
2760
2761
2776 public List<MBThread> findByG_NotC(long groupId, long categoryId,
2777 int start, int end, OrderByComparator orderByComparator)
2778 throws SystemException {
2779 FinderPath finderPath = null;
2780 Object[] finderArgs = null;
2781
2782 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTC;
2783 finderArgs = new Object[] {
2784 groupId, categoryId,
2785
2786 start, end, orderByComparator
2787 };
2788
2789 List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(finderPath,
2790 finderArgs, this);
2791
2792 if ((list != null) && !list.isEmpty()) {
2793 for (MBThread mbThread : list) {
2794 if ((groupId != mbThread.getGroupId()) ||
2795 (categoryId != mbThread.getCategoryId())) {
2796 list = null;
2797
2798 break;
2799 }
2800 }
2801 }
2802
2803 if (list == null) {
2804 StringBundler query = null;
2805
2806 if (orderByComparator != null) {
2807 query = new StringBundler(4 +
2808 (orderByComparator.getOrderByFields().length * 3));
2809 }
2810 else {
2811 query = new StringBundler(4);
2812 }
2813
2814 query.append(_SQL_SELECT_MBTHREAD_WHERE);
2815
2816 query.append(_FINDER_COLUMN_G_NOTC_GROUPID_2);
2817
2818 query.append(_FINDER_COLUMN_G_NOTC_CATEGORYID_2);
2819
2820 if (orderByComparator != null) {
2821 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2822 orderByComparator);
2823 }
2824
2825 else {
2826 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
2827 }
2828
2829 String sql = query.toString();
2830
2831 Session session = null;
2832
2833 try {
2834 session = openSession();
2835
2836 Query q = session.createQuery(sql);
2837
2838 QueryPos qPos = QueryPos.getInstance(q);
2839
2840 qPos.add(groupId);
2841
2842 qPos.add(categoryId);
2843
2844 list = (List<MBThread>)QueryUtil.list(q, getDialect(), start,
2845 end);
2846 }
2847 catch (Exception e) {
2848 throw processException(e);
2849 }
2850 finally {
2851 if (list == null) {
2852 FinderCacheUtil.removeResult(finderPath, finderArgs);
2853 }
2854 else {
2855 cacheResult(list);
2856
2857 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2858 }
2859
2860 closeSession(session);
2861 }
2862 }
2863
2864 return list;
2865 }
2866
2867
2877 public MBThread findByG_NotC_First(long groupId, long categoryId,
2878 OrderByComparator orderByComparator)
2879 throws NoSuchThreadException, SystemException {
2880 MBThread mbThread = fetchByG_NotC_First(groupId, categoryId,
2881 orderByComparator);
2882
2883 if (mbThread != null) {
2884 return mbThread;
2885 }
2886
2887 StringBundler msg = new StringBundler(6);
2888
2889 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2890
2891 msg.append("groupId=");
2892 msg.append(groupId);
2893
2894 msg.append(", categoryId=");
2895 msg.append(categoryId);
2896
2897 msg.append(StringPool.CLOSE_CURLY_BRACE);
2898
2899 throw new NoSuchThreadException(msg.toString());
2900 }
2901
2902
2911 public MBThread fetchByG_NotC_First(long groupId, long categoryId,
2912 OrderByComparator orderByComparator) throws SystemException {
2913 List<MBThread> list = findByG_NotC(groupId, categoryId, 0, 1,
2914 orderByComparator);
2915
2916 if (!list.isEmpty()) {
2917 return list.get(0);
2918 }
2919
2920 return null;
2921 }
2922
2923
2933 public MBThread findByG_NotC_Last(long groupId, long categoryId,
2934 OrderByComparator orderByComparator)
2935 throws NoSuchThreadException, SystemException {
2936 MBThread mbThread = fetchByG_NotC_Last(groupId, categoryId,
2937 orderByComparator);
2938
2939 if (mbThread != null) {
2940 return mbThread;
2941 }
2942
2943 StringBundler msg = new StringBundler(6);
2944
2945 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2946
2947 msg.append("groupId=");
2948 msg.append(groupId);
2949
2950 msg.append(", categoryId=");
2951 msg.append(categoryId);
2952
2953 msg.append(StringPool.CLOSE_CURLY_BRACE);
2954
2955 throw new NoSuchThreadException(msg.toString());
2956 }
2957
2958
2967 public MBThread fetchByG_NotC_Last(long groupId, long categoryId,
2968 OrderByComparator orderByComparator) throws SystemException {
2969 int count = countByG_NotC(groupId, categoryId);
2970
2971 List<MBThread> list = findByG_NotC(groupId, categoryId, count - 1,
2972 count, orderByComparator);
2973
2974 if (!list.isEmpty()) {
2975 return list.get(0);
2976 }
2977
2978 return null;
2979 }
2980
2981
2992 public MBThread[] findByG_NotC_PrevAndNext(long threadId, long groupId,
2993 long categoryId, OrderByComparator orderByComparator)
2994 throws NoSuchThreadException, SystemException {
2995 MBThread mbThread = findByPrimaryKey(threadId);
2996
2997 Session session = null;
2998
2999 try {
3000 session = openSession();
3001
3002 MBThread[] array = new MBThreadImpl[3];
3003
3004 array[0] = getByG_NotC_PrevAndNext(session, mbThread, groupId,
3005 categoryId, orderByComparator, true);
3006
3007 array[1] = mbThread;
3008
3009 array[2] = getByG_NotC_PrevAndNext(session, mbThread, groupId,
3010 categoryId, orderByComparator, false);
3011
3012 return array;
3013 }
3014 catch (Exception e) {
3015 throw processException(e);
3016 }
3017 finally {
3018 closeSession(session);
3019 }
3020 }
3021
3022 protected MBThread getByG_NotC_PrevAndNext(Session session,
3023 MBThread mbThread, long groupId, long categoryId,
3024 OrderByComparator orderByComparator, boolean previous) {
3025 StringBundler query = null;
3026
3027 if (orderByComparator != null) {
3028 query = new StringBundler(6 +
3029 (orderByComparator.getOrderByFields().length * 6));
3030 }
3031 else {
3032 query = new StringBundler(3);
3033 }
3034
3035 query.append(_SQL_SELECT_MBTHREAD_WHERE);
3036
3037 query.append(_FINDER_COLUMN_G_NOTC_GROUPID_2);
3038
3039 query.append(_FINDER_COLUMN_G_NOTC_CATEGORYID_2);
3040
3041 if (orderByComparator != null) {
3042 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3043
3044 if (orderByConditionFields.length > 0) {
3045 query.append(WHERE_AND);
3046 }
3047
3048 for (int i = 0; i < orderByConditionFields.length; i++) {
3049 query.append(_ORDER_BY_ENTITY_ALIAS);
3050 query.append(orderByConditionFields[i]);
3051
3052 if ((i + 1) < orderByConditionFields.length) {
3053 if (orderByComparator.isAscending() ^ previous) {
3054 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3055 }
3056 else {
3057 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3058 }
3059 }
3060 else {
3061 if (orderByComparator.isAscending() ^ previous) {
3062 query.append(WHERE_GREATER_THAN);
3063 }
3064 else {
3065 query.append(WHERE_LESSER_THAN);
3066 }
3067 }
3068 }
3069
3070 query.append(ORDER_BY_CLAUSE);
3071
3072 String[] orderByFields = orderByComparator.getOrderByFields();
3073
3074 for (int i = 0; i < orderByFields.length; i++) {
3075 query.append(_ORDER_BY_ENTITY_ALIAS);
3076 query.append(orderByFields[i]);
3077
3078 if ((i + 1) < orderByFields.length) {
3079 if (orderByComparator.isAscending() ^ previous) {
3080 query.append(ORDER_BY_ASC_HAS_NEXT);
3081 }
3082 else {
3083 query.append(ORDER_BY_DESC_HAS_NEXT);
3084 }
3085 }
3086 else {
3087 if (orderByComparator.isAscending() ^ previous) {
3088 query.append(ORDER_BY_ASC);
3089 }
3090 else {
3091 query.append(ORDER_BY_DESC);
3092 }
3093 }
3094 }
3095 }
3096
3097 else {
3098 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
3099 }
3100
3101 String sql = query.toString();
3102
3103 Query q = session.createQuery(sql);
3104
3105 q.setFirstResult(0);
3106 q.setMaxResults(2);
3107
3108 QueryPos qPos = QueryPos.getInstance(q);
3109
3110 qPos.add(groupId);
3111
3112 qPos.add(categoryId);
3113
3114 if (orderByComparator != null) {
3115 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
3116
3117 for (Object value : values) {
3118 qPos.add(value);
3119 }
3120 }
3121
3122 List<MBThread> list = q.list();
3123
3124 if (list.size() == 2) {
3125 return list.get(1);
3126 }
3127 else {
3128 return null;
3129 }
3130 }
3131
3132
3140 public List<MBThread> filterFindByG_NotC(long groupId, long categoryId)
3141 throws SystemException {
3142 return filterFindByG_NotC(groupId, categoryId, QueryUtil.ALL_POS,
3143 QueryUtil.ALL_POS, null);
3144 }
3145
3146
3160 public List<MBThread> filterFindByG_NotC(long groupId, long categoryId,
3161 int start, int end) throws SystemException {
3162 return filterFindByG_NotC(groupId, categoryId, start, end, null);
3163 }
3164
3165
3180 public List<MBThread> filterFindByG_NotC(long groupId, long categoryId,
3181 int start, int end, OrderByComparator orderByComparator)
3182 throws SystemException {
3183 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3184 return findByG_NotC(groupId, categoryId, start, end,
3185 orderByComparator);
3186 }
3187
3188 StringBundler query = null;
3189
3190 if (orderByComparator != null) {
3191 query = new StringBundler(4 +
3192 (orderByComparator.getOrderByFields().length * 3));
3193 }
3194 else {
3195 query = new StringBundler(4);
3196 }
3197
3198 if (getDB().isSupportsInlineDistinct()) {
3199 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
3200 }
3201 else {
3202 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
3203 }
3204
3205 query.append(_FINDER_COLUMN_G_NOTC_GROUPID_2);
3206
3207 query.append(_FINDER_COLUMN_G_NOTC_CATEGORYID_2);
3208
3209 if (!getDB().isSupportsInlineDistinct()) {
3210 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
3211 }
3212
3213 if (orderByComparator != null) {
3214 if (getDB().isSupportsInlineDistinct()) {
3215 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3216 orderByComparator);
3217 }
3218 else {
3219 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3220 orderByComparator);
3221 }
3222 }
3223
3224 else {
3225 if (getDB().isSupportsInlineDistinct()) {
3226 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
3227 }
3228 else {
3229 query.append(MBThreadModelImpl.ORDER_BY_SQL);
3230 }
3231 }
3232
3233 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3234 MBThread.class.getName(),
3235 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3236
3237 Session session = null;
3238
3239 try {
3240 session = openSession();
3241
3242 SQLQuery q = session.createSQLQuery(sql);
3243
3244 if (getDB().isSupportsInlineDistinct()) {
3245 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
3246 }
3247 else {
3248 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
3249 }
3250
3251 QueryPos qPos = QueryPos.getInstance(q);
3252
3253 qPos.add(groupId);
3254
3255 qPos.add(categoryId);
3256
3257 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
3258 }
3259 catch (Exception e) {
3260 throw processException(e);
3261 }
3262 finally {
3263 closeSession(session);
3264 }
3265 }
3266
3267
3278 public MBThread[] filterFindByG_NotC_PrevAndNext(long threadId,
3279 long groupId, long categoryId, OrderByComparator orderByComparator)
3280 throws NoSuchThreadException, SystemException {
3281 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3282 return findByG_NotC_PrevAndNext(threadId, groupId, categoryId,
3283 orderByComparator);
3284 }
3285
3286 MBThread mbThread = findByPrimaryKey(threadId);
3287
3288 Session session = null;
3289
3290 try {
3291 session = openSession();
3292
3293 MBThread[] array = new MBThreadImpl[3];
3294
3295 array[0] = filterGetByG_NotC_PrevAndNext(session, mbThread,
3296 groupId, categoryId, orderByComparator, true);
3297
3298 array[1] = mbThread;
3299
3300 array[2] = filterGetByG_NotC_PrevAndNext(session, mbThread,
3301 groupId, categoryId, orderByComparator, false);
3302
3303 return array;
3304 }
3305 catch (Exception e) {
3306 throw processException(e);
3307 }
3308 finally {
3309 closeSession(session);
3310 }
3311 }
3312
3313 protected MBThread filterGetByG_NotC_PrevAndNext(Session session,
3314 MBThread mbThread, long groupId, long categoryId,
3315 OrderByComparator orderByComparator, boolean previous) {
3316 StringBundler query = null;
3317
3318 if (orderByComparator != null) {
3319 query = new StringBundler(6 +
3320 (orderByComparator.getOrderByFields().length * 6));
3321 }
3322 else {
3323 query = new StringBundler(3);
3324 }
3325
3326 if (getDB().isSupportsInlineDistinct()) {
3327 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
3328 }
3329 else {
3330 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
3331 }
3332
3333 query.append(_FINDER_COLUMN_G_NOTC_GROUPID_2);
3334
3335 query.append(_FINDER_COLUMN_G_NOTC_CATEGORYID_2);
3336
3337 if (!getDB().isSupportsInlineDistinct()) {
3338 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
3339 }
3340
3341 if (orderByComparator != null) {
3342 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3343
3344 if (orderByConditionFields.length > 0) {
3345 query.append(WHERE_AND);
3346 }
3347
3348 for (int i = 0; i < orderByConditionFields.length; i++) {
3349 if (getDB().isSupportsInlineDistinct()) {
3350 query.append(_ORDER_BY_ENTITY_ALIAS);
3351 }
3352 else {
3353 query.append(_ORDER_BY_ENTITY_TABLE);
3354 }
3355
3356 query.append(orderByConditionFields[i]);
3357
3358 if ((i + 1) < orderByConditionFields.length) {
3359 if (orderByComparator.isAscending() ^ previous) {
3360 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3361 }
3362 else {
3363 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3364 }
3365 }
3366 else {
3367 if (orderByComparator.isAscending() ^ previous) {
3368 query.append(WHERE_GREATER_THAN);
3369 }
3370 else {
3371 query.append(WHERE_LESSER_THAN);
3372 }
3373 }
3374 }
3375
3376 query.append(ORDER_BY_CLAUSE);
3377
3378 String[] orderByFields = orderByComparator.getOrderByFields();
3379
3380 for (int i = 0; i < orderByFields.length; i++) {
3381 if (getDB().isSupportsInlineDistinct()) {
3382 query.append(_ORDER_BY_ENTITY_ALIAS);
3383 }
3384 else {
3385 query.append(_ORDER_BY_ENTITY_TABLE);
3386 }
3387
3388 query.append(orderByFields[i]);
3389
3390 if ((i + 1) < orderByFields.length) {
3391 if (orderByComparator.isAscending() ^ previous) {
3392 query.append(ORDER_BY_ASC_HAS_NEXT);
3393 }
3394 else {
3395 query.append(ORDER_BY_DESC_HAS_NEXT);
3396 }
3397 }
3398 else {
3399 if (orderByComparator.isAscending() ^ previous) {
3400 query.append(ORDER_BY_ASC);
3401 }
3402 else {
3403 query.append(ORDER_BY_DESC);
3404 }
3405 }
3406 }
3407 }
3408
3409 else {
3410 if (getDB().isSupportsInlineDistinct()) {
3411 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
3412 }
3413 else {
3414 query.append(MBThreadModelImpl.ORDER_BY_SQL);
3415 }
3416 }
3417
3418 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3419 MBThread.class.getName(),
3420 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3421
3422 SQLQuery q = session.createSQLQuery(sql);
3423
3424 q.setFirstResult(0);
3425 q.setMaxResults(2);
3426
3427 if (getDB().isSupportsInlineDistinct()) {
3428 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
3429 }
3430 else {
3431 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
3432 }
3433
3434 QueryPos qPos = QueryPos.getInstance(q);
3435
3436 qPos.add(groupId);
3437
3438 qPos.add(categoryId);
3439
3440 if (orderByComparator != null) {
3441 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
3442
3443 for (Object value : values) {
3444 qPos.add(value);
3445 }
3446 }
3447
3448 List<MBThread> list = q.list();
3449
3450 if (list.size() == 2) {
3451 return list.get(1);
3452 }
3453 else {
3454 return null;
3455 }
3456 }
3457
3458
3466 public List<MBThread> findByG_S(long groupId, int status)
3467 throws SystemException {
3468 return findByG_S(groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3469 null);
3470 }
3471
3472
3486 public List<MBThread> findByG_S(long groupId, int status, int start, int end)
3487 throws SystemException {
3488 return findByG_S(groupId, status, start, end, null);
3489 }
3490
3491
3506 public List<MBThread> findByG_S(long groupId, int status, int start,
3507 int end, OrderByComparator orderByComparator) throws SystemException {
3508 FinderPath finderPath = null;
3509 Object[] finderArgs = null;
3510
3511 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3512 (orderByComparator == null)) {
3513 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
3514 finderArgs = new Object[] { groupId, status };
3515 }
3516 else {
3517 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
3518 finderArgs = new Object[] {
3519 groupId, status,
3520
3521 start, end, orderByComparator
3522 };
3523 }
3524
3525 List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(finderPath,
3526 finderArgs, this);
3527
3528 if ((list != null) && !list.isEmpty()) {
3529 for (MBThread mbThread : list) {
3530 if ((groupId != mbThread.getGroupId()) ||
3531 (status != mbThread.getStatus())) {
3532 list = null;
3533
3534 break;
3535 }
3536 }
3537 }
3538
3539 if (list == null) {
3540 StringBundler query = null;
3541
3542 if (orderByComparator != null) {
3543 query = new StringBundler(4 +
3544 (orderByComparator.getOrderByFields().length * 3));
3545 }
3546 else {
3547 query = new StringBundler(4);
3548 }
3549
3550 query.append(_SQL_SELECT_MBTHREAD_WHERE);
3551
3552 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3553
3554 query.append(_FINDER_COLUMN_G_S_STATUS_2);
3555
3556 if (orderByComparator != null) {
3557 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3558 orderByComparator);
3559 }
3560
3561 else {
3562 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
3563 }
3564
3565 String sql = query.toString();
3566
3567 Session session = null;
3568
3569 try {
3570 session = openSession();
3571
3572 Query q = session.createQuery(sql);
3573
3574 QueryPos qPos = QueryPos.getInstance(q);
3575
3576 qPos.add(groupId);
3577
3578 qPos.add(status);
3579
3580 list = (List<MBThread>)QueryUtil.list(q, getDialect(), start,
3581 end);
3582 }
3583 catch (Exception e) {
3584 throw processException(e);
3585 }
3586 finally {
3587 if (list == null) {
3588 FinderCacheUtil.removeResult(finderPath, finderArgs);
3589 }
3590 else {
3591 cacheResult(list);
3592
3593 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3594 }
3595
3596 closeSession(session);
3597 }
3598 }
3599
3600 return list;
3601 }
3602
3603
3613 public MBThread findByG_S_First(long groupId, int status,
3614 OrderByComparator orderByComparator)
3615 throws NoSuchThreadException, SystemException {
3616 MBThread mbThread = fetchByG_S_First(groupId, status, orderByComparator);
3617
3618 if (mbThread != null) {
3619 return mbThread;
3620 }
3621
3622 StringBundler msg = new StringBundler(6);
3623
3624 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3625
3626 msg.append("groupId=");
3627 msg.append(groupId);
3628
3629 msg.append(", status=");
3630 msg.append(status);
3631
3632 msg.append(StringPool.CLOSE_CURLY_BRACE);
3633
3634 throw new NoSuchThreadException(msg.toString());
3635 }
3636
3637
3646 public MBThread fetchByG_S_First(long groupId, int status,
3647 OrderByComparator orderByComparator) throws SystemException {
3648 List<MBThread> list = findByG_S(groupId, status, 0, 1, orderByComparator);
3649
3650 if (!list.isEmpty()) {
3651 return list.get(0);
3652 }
3653
3654 return null;
3655 }
3656
3657
3667 public MBThread findByG_S_Last(long groupId, int status,
3668 OrderByComparator orderByComparator)
3669 throws NoSuchThreadException, SystemException {
3670 MBThread mbThread = fetchByG_S_Last(groupId, status, orderByComparator);
3671
3672 if (mbThread != null) {
3673 return mbThread;
3674 }
3675
3676 StringBundler msg = new StringBundler(6);
3677
3678 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3679
3680 msg.append("groupId=");
3681 msg.append(groupId);
3682
3683 msg.append(", status=");
3684 msg.append(status);
3685
3686 msg.append(StringPool.CLOSE_CURLY_BRACE);
3687
3688 throw new NoSuchThreadException(msg.toString());
3689 }
3690
3691
3700 public MBThread fetchByG_S_Last(long groupId, int status,
3701 OrderByComparator orderByComparator) throws SystemException {
3702 int count = countByG_S(groupId, status);
3703
3704 List<MBThread> list = findByG_S(groupId, status, count - 1, count,
3705 orderByComparator);
3706
3707 if (!list.isEmpty()) {
3708 return list.get(0);
3709 }
3710
3711 return null;
3712 }
3713
3714
3725 public MBThread[] findByG_S_PrevAndNext(long threadId, long groupId,
3726 int status, OrderByComparator orderByComparator)
3727 throws NoSuchThreadException, SystemException {
3728 MBThread mbThread = findByPrimaryKey(threadId);
3729
3730 Session session = null;
3731
3732 try {
3733 session = openSession();
3734
3735 MBThread[] array = new MBThreadImpl[3];
3736
3737 array[0] = getByG_S_PrevAndNext(session, mbThread, groupId, status,
3738 orderByComparator, true);
3739
3740 array[1] = mbThread;
3741
3742 array[2] = getByG_S_PrevAndNext(session, mbThread, groupId, status,
3743 orderByComparator, false);
3744
3745 return array;
3746 }
3747 catch (Exception e) {
3748 throw processException(e);
3749 }
3750 finally {
3751 closeSession(session);
3752 }
3753 }
3754
3755 protected MBThread getByG_S_PrevAndNext(Session session, MBThread mbThread,
3756 long groupId, int status, OrderByComparator orderByComparator,
3757 boolean previous) {
3758 StringBundler query = null;
3759
3760 if (orderByComparator != null) {
3761 query = new StringBundler(6 +
3762 (orderByComparator.getOrderByFields().length * 6));
3763 }
3764 else {
3765 query = new StringBundler(3);
3766 }
3767
3768 query.append(_SQL_SELECT_MBTHREAD_WHERE);
3769
3770 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3771
3772 query.append(_FINDER_COLUMN_G_S_STATUS_2);
3773
3774 if (orderByComparator != null) {
3775 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3776
3777 if (orderByConditionFields.length > 0) {
3778 query.append(WHERE_AND);
3779 }
3780
3781 for (int i = 0; i < orderByConditionFields.length; i++) {
3782 query.append(_ORDER_BY_ENTITY_ALIAS);
3783 query.append(orderByConditionFields[i]);
3784
3785 if ((i + 1) < orderByConditionFields.length) {
3786 if (orderByComparator.isAscending() ^ previous) {
3787 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3788 }
3789 else {
3790 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3791 }
3792 }
3793 else {
3794 if (orderByComparator.isAscending() ^ previous) {
3795 query.append(WHERE_GREATER_THAN);
3796 }
3797 else {
3798 query.append(WHERE_LESSER_THAN);
3799 }
3800 }
3801 }
3802
3803 query.append(ORDER_BY_CLAUSE);
3804
3805 String[] orderByFields = orderByComparator.getOrderByFields();
3806
3807 for (int i = 0; i < orderByFields.length; i++) {
3808 query.append(_ORDER_BY_ENTITY_ALIAS);
3809 query.append(orderByFields[i]);
3810
3811 if ((i + 1) < orderByFields.length) {
3812 if (orderByComparator.isAscending() ^ previous) {
3813 query.append(ORDER_BY_ASC_HAS_NEXT);
3814 }
3815 else {
3816 query.append(ORDER_BY_DESC_HAS_NEXT);
3817 }
3818 }
3819 else {
3820 if (orderByComparator.isAscending() ^ previous) {
3821 query.append(ORDER_BY_ASC);
3822 }
3823 else {
3824 query.append(ORDER_BY_DESC);
3825 }
3826 }
3827 }
3828 }
3829
3830 else {
3831 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
3832 }
3833
3834 String sql = query.toString();
3835
3836 Query q = session.createQuery(sql);
3837
3838 q.setFirstResult(0);
3839 q.setMaxResults(2);
3840
3841 QueryPos qPos = QueryPos.getInstance(q);
3842
3843 qPos.add(groupId);
3844
3845 qPos.add(status);
3846
3847 if (orderByComparator != null) {
3848 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
3849
3850 for (Object value : values) {
3851 qPos.add(value);
3852 }
3853 }
3854
3855 List<MBThread> list = q.list();
3856
3857 if (list.size() == 2) {
3858 return list.get(1);
3859 }
3860 else {
3861 return null;
3862 }
3863 }
3864
3865
3873 public List<MBThread> filterFindByG_S(long groupId, int status)
3874 throws SystemException {
3875 return filterFindByG_S(groupId, status, QueryUtil.ALL_POS,
3876 QueryUtil.ALL_POS, null);
3877 }
3878
3879
3893 public List<MBThread> filterFindByG_S(long groupId, int status, int start,
3894 int end) throws SystemException {
3895 return filterFindByG_S(groupId, status, start, end, null);
3896 }
3897
3898
3913 public List<MBThread> filterFindByG_S(long groupId, int status, int start,
3914 int end, OrderByComparator orderByComparator) throws SystemException {
3915 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3916 return findByG_S(groupId, status, start, end, orderByComparator);
3917 }
3918
3919 StringBundler query = null;
3920
3921 if (orderByComparator != null) {
3922 query = new StringBundler(4 +
3923 (orderByComparator.getOrderByFields().length * 3));
3924 }
3925 else {
3926 query = new StringBundler(4);
3927 }
3928
3929 if (getDB().isSupportsInlineDistinct()) {
3930 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
3931 }
3932 else {
3933 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
3934 }
3935
3936 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3937
3938 query.append(_FINDER_COLUMN_G_S_STATUS_2);
3939
3940 if (!getDB().isSupportsInlineDistinct()) {
3941 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
3942 }
3943
3944 if (orderByComparator != null) {
3945 if (getDB().isSupportsInlineDistinct()) {
3946 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3947 orderByComparator);
3948 }
3949 else {
3950 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3951 orderByComparator);
3952 }
3953 }
3954
3955 else {
3956 if (getDB().isSupportsInlineDistinct()) {
3957 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
3958 }
3959 else {
3960 query.append(MBThreadModelImpl.ORDER_BY_SQL);
3961 }
3962 }
3963
3964 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3965 MBThread.class.getName(),
3966 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3967
3968 Session session = null;
3969
3970 try {
3971 session = openSession();
3972
3973 SQLQuery q = session.createSQLQuery(sql);
3974
3975 if (getDB().isSupportsInlineDistinct()) {
3976 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
3977 }
3978 else {
3979 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
3980 }
3981
3982 QueryPos qPos = QueryPos.getInstance(q);
3983
3984 qPos.add(groupId);
3985
3986 qPos.add(status);
3987
3988 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
3989 }
3990 catch (Exception e) {
3991 throw processException(e);
3992 }
3993 finally {
3994 closeSession(session);
3995 }
3996 }
3997
3998
4009 public MBThread[] filterFindByG_S_PrevAndNext(long threadId, long groupId,
4010 int status, OrderByComparator orderByComparator)
4011 throws NoSuchThreadException, SystemException {
4012 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4013 return findByG_S_PrevAndNext(threadId, groupId, status,
4014 orderByComparator);
4015 }
4016
4017 MBThread mbThread = findByPrimaryKey(threadId);
4018
4019 Session session = null;
4020
4021 try {
4022 session = openSession();
4023
4024 MBThread[] array = new MBThreadImpl[3];
4025
4026 array[0] = filterGetByG_S_PrevAndNext(session, mbThread, groupId,
4027 status, orderByComparator, true);
4028
4029 array[1] = mbThread;
4030
4031 array[2] = filterGetByG_S_PrevAndNext(session, mbThread, groupId,
4032 status, orderByComparator, false);
4033
4034 return array;
4035 }
4036 catch (Exception e) {
4037 throw processException(e);
4038 }
4039 finally {
4040 closeSession(session);
4041 }
4042 }
4043
4044 protected MBThread filterGetByG_S_PrevAndNext(Session session,
4045 MBThread mbThread, long groupId, int status,
4046 OrderByComparator orderByComparator, boolean previous) {
4047 StringBundler query = null;
4048
4049 if (orderByComparator != null) {
4050 query = new StringBundler(6 +
4051 (orderByComparator.getOrderByFields().length * 6));
4052 }
4053 else {
4054 query = new StringBundler(3);
4055 }
4056
4057 if (getDB().isSupportsInlineDistinct()) {
4058 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
4059 }
4060 else {
4061 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
4062 }
4063
4064 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4065
4066 query.append(_FINDER_COLUMN_G_S_STATUS_2);
4067
4068 if (!getDB().isSupportsInlineDistinct()) {
4069 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
4070 }
4071
4072 if (orderByComparator != null) {
4073 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4074
4075 if (orderByConditionFields.length > 0) {
4076 query.append(WHERE_AND);
4077 }
4078
4079 for (int i = 0; i < orderByConditionFields.length; i++) {
4080 if (getDB().isSupportsInlineDistinct()) {
4081 query.append(_ORDER_BY_ENTITY_ALIAS);
4082 }
4083 else {
4084 query.append(_ORDER_BY_ENTITY_TABLE);
4085 }
4086
4087 query.append(orderByConditionFields[i]);
4088
4089 if ((i + 1) < orderByConditionFields.length) {
4090 if (orderByComparator.isAscending() ^ previous) {
4091 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4092 }
4093 else {
4094 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4095 }
4096 }
4097 else {
4098 if (orderByComparator.isAscending() ^ previous) {
4099 query.append(WHERE_GREATER_THAN);
4100 }
4101 else {
4102 query.append(WHERE_LESSER_THAN);
4103 }
4104 }
4105 }
4106
4107 query.append(ORDER_BY_CLAUSE);
4108
4109 String[] orderByFields = orderByComparator.getOrderByFields();
4110
4111 for (int i = 0; i < orderByFields.length; i++) {
4112 if (getDB().isSupportsInlineDistinct()) {
4113 query.append(_ORDER_BY_ENTITY_ALIAS);
4114 }
4115 else {
4116 query.append(_ORDER_BY_ENTITY_TABLE);
4117 }
4118
4119 query.append(orderByFields[i]);
4120
4121 if ((i + 1) < orderByFields.length) {
4122 if (orderByComparator.isAscending() ^ previous) {
4123 query.append(ORDER_BY_ASC_HAS_NEXT);
4124 }
4125 else {
4126 query.append(ORDER_BY_DESC_HAS_NEXT);
4127 }
4128 }
4129 else {
4130 if (orderByComparator.isAscending() ^ previous) {
4131 query.append(ORDER_BY_ASC);
4132 }
4133 else {
4134 query.append(ORDER_BY_DESC);
4135 }
4136 }
4137 }
4138 }
4139
4140 else {
4141 if (getDB().isSupportsInlineDistinct()) {
4142 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
4143 }
4144 else {
4145 query.append(MBThreadModelImpl.ORDER_BY_SQL);
4146 }
4147 }
4148
4149 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4150 MBThread.class.getName(),
4151 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4152
4153 SQLQuery q = session.createSQLQuery(sql);
4154
4155 q.setFirstResult(0);
4156 q.setMaxResults(2);
4157
4158 if (getDB().isSupportsInlineDistinct()) {
4159 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
4160 }
4161 else {
4162 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
4163 }
4164
4165 QueryPos qPos = QueryPos.getInstance(q);
4166
4167 qPos.add(groupId);
4168
4169 qPos.add(status);
4170
4171 if (orderByComparator != null) {
4172 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
4173
4174 for (Object value : values) {
4175 qPos.add(value);
4176 }
4177 }
4178
4179 List<MBThread> list = q.list();
4180
4181 if (list.size() == 2) {
4182 return list.get(1);
4183 }
4184 else {
4185 return null;
4186 }
4187 }
4188
4189
4197 public List<MBThread> findByC_P(long categoryId, double priority)
4198 throws SystemException {
4199 return findByC_P(categoryId, priority, QueryUtil.ALL_POS,
4200 QueryUtil.ALL_POS, null);
4201 }
4202
4203
4217 public List<MBThread> findByC_P(long categoryId, double priority,
4218 int start, int end) throws SystemException {
4219 return findByC_P(categoryId, priority, start, end, null);
4220 }
4221
4222
4237 public List<MBThread> findByC_P(long categoryId, double priority,
4238 int start, int end, OrderByComparator orderByComparator)
4239 throws SystemException {
4240 FinderPath finderPath = null;
4241 Object[] finderArgs = null;
4242
4243 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4244 (orderByComparator == null)) {
4245 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P;
4246 finderArgs = new Object[] { categoryId, priority };
4247 }
4248 else {
4249 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_P;
4250 finderArgs = new Object[] {
4251 categoryId, priority,
4252
4253 start, end, orderByComparator
4254 };
4255 }
4256
4257 List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(finderPath,
4258 finderArgs, this);
4259
4260 if ((list != null) && !list.isEmpty()) {
4261 for (MBThread mbThread : list) {
4262 if ((categoryId != mbThread.getCategoryId()) ||
4263 (priority != mbThread.getPriority())) {
4264 list = null;
4265
4266 break;
4267 }
4268 }
4269 }
4270
4271 if (list == null) {
4272 StringBundler query = null;
4273
4274 if (orderByComparator != null) {
4275 query = new StringBundler(4 +
4276 (orderByComparator.getOrderByFields().length * 3));
4277 }
4278 else {
4279 query = new StringBundler(4);
4280 }
4281
4282 query.append(_SQL_SELECT_MBTHREAD_WHERE);
4283
4284 query.append(_FINDER_COLUMN_C_P_CATEGORYID_2);
4285
4286 query.append(_FINDER_COLUMN_C_P_PRIORITY_2);
4287
4288 if (orderByComparator != null) {
4289 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4290 orderByComparator);
4291 }
4292
4293 else {
4294 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
4295 }
4296
4297 String sql = query.toString();
4298
4299 Session session = null;
4300
4301 try {
4302 session = openSession();
4303
4304 Query q = session.createQuery(sql);
4305
4306 QueryPos qPos = QueryPos.getInstance(q);
4307
4308 qPos.add(categoryId);
4309
4310 qPos.add(priority);
4311
4312 list = (List<MBThread>)QueryUtil.list(q, getDialect(), start,
4313 end);
4314 }
4315 catch (Exception e) {
4316 throw processException(e);
4317 }
4318 finally {
4319 if (list == null) {
4320 FinderCacheUtil.removeResult(finderPath, finderArgs);
4321 }
4322 else {
4323 cacheResult(list);
4324
4325 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4326 }
4327
4328 closeSession(session);
4329 }
4330 }
4331
4332 return list;
4333 }
4334
4335
4345 public MBThread findByC_P_First(long categoryId, double priority,
4346 OrderByComparator orderByComparator)
4347 throws NoSuchThreadException, SystemException {
4348 MBThread mbThread = fetchByC_P_First(categoryId, priority,
4349 orderByComparator);
4350
4351 if (mbThread != null) {
4352 return mbThread;
4353 }
4354
4355 StringBundler msg = new StringBundler(6);
4356
4357 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4358
4359 msg.append("categoryId=");
4360 msg.append(categoryId);
4361
4362 msg.append(", priority=");
4363 msg.append(priority);
4364
4365 msg.append(StringPool.CLOSE_CURLY_BRACE);
4366
4367 throw new NoSuchThreadException(msg.toString());
4368 }
4369
4370
4379 public MBThread fetchByC_P_First(long categoryId, double priority,
4380 OrderByComparator orderByComparator) throws SystemException {
4381 List<MBThread> list = findByC_P(categoryId, priority, 0, 1,
4382 orderByComparator);
4383
4384 if (!list.isEmpty()) {
4385 return list.get(0);
4386 }
4387
4388 return null;
4389 }
4390
4391
4401 public MBThread findByC_P_Last(long categoryId, double priority,
4402 OrderByComparator orderByComparator)
4403 throws NoSuchThreadException, SystemException {
4404 MBThread mbThread = fetchByC_P_Last(categoryId, priority,
4405 orderByComparator);
4406
4407 if (mbThread != null) {
4408 return mbThread;
4409 }
4410
4411 StringBundler msg = new StringBundler(6);
4412
4413 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4414
4415 msg.append("categoryId=");
4416 msg.append(categoryId);
4417
4418 msg.append(", priority=");
4419 msg.append(priority);
4420
4421 msg.append(StringPool.CLOSE_CURLY_BRACE);
4422
4423 throw new NoSuchThreadException(msg.toString());
4424 }
4425
4426
4435 public MBThread fetchByC_P_Last(long categoryId, double priority,
4436 OrderByComparator orderByComparator) throws SystemException {
4437 int count = countByC_P(categoryId, priority);
4438
4439 List<MBThread> list = findByC_P(categoryId, priority, count - 1, count,
4440 orderByComparator);
4441
4442 if (!list.isEmpty()) {
4443 return list.get(0);
4444 }
4445
4446 return null;
4447 }
4448
4449
4460 public MBThread[] findByC_P_PrevAndNext(long threadId, long categoryId,
4461 double priority, OrderByComparator orderByComparator)
4462 throws NoSuchThreadException, SystemException {
4463 MBThread mbThread = findByPrimaryKey(threadId);
4464
4465 Session session = null;
4466
4467 try {
4468 session = openSession();
4469
4470 MBThread[] array = new MBThreadImpl[3];
4471
4472 array[0] = getByC_P_PrevAndNext(session, mbThread, categoryId,
4473 priority, orderByComparator, true);
4474
4475 array[1] = mbThread;
4476
4477 array[2] = getByC_P_PrevAndNext(session, mbThread, categoryId,
4478 priority, orderByComparator, false);
4479
4480 return array;
4481 }
4482 catch (Exception e) {
4483 throw processException(e);
4484 }
4485 finally {
4486 closeSession(session);
4487 }
4488 }
4489
4490 protected MBThread getByC_P_PrevAndNext(Session session, MBThread mbThread,
4491 long categoryId, double priority, OrderByComparator orderByComparator,
4492 boolean previous) {
4493 StringBundler query = null;
4494
4495 if (orderByComparator != null) {
4496 query = new StringBundler(6 +
4497 (orderByComparator.getOrderByFields().length * 6));
4498 }
4499 else {
4500 query = new StringBundler(3);
4501 }
4502
4503 query.append(_SQL_SELECT_MBTHREAD_WHERE);
4504
4505 query.append(_FINDER_COLUMN_C_P_CATEGORYID_2);
4506
4507 query.append(_FINDER_COLUMN_C_P_PRIORITY_2);
4508
4509 if (orderByComparator != null) {
4510 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4511
4512 if (orderByConditionFields.length > 0) {
4513 query.append(WHERE_AND);
4514 }
4515
4516 for (int i = 0; i < orderByConditionFields.length; i++) {
4517 query.append(_ORDER_BY_ENTITY_ALIAS);
4518 query.append(orderByConditionFields[i]);
4519
4520 if ((i + 1) < orderByConditionFields.length) {
4521 if (orderByComparator.isAscending() ^ previous) {
4522 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4523 }
4524 else {
4525 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4526 }
4527 }
4528 else {
4529 if (orderByComparator.isAscending() ^ previous) {
4530 query.append(WHERE_GREATER_THAN);
4531 }
4532 else {
4533 query.append(WHERE_LESSER_THAN);
4534 }
4535 }
4536 }
4537
4538 query.append(ORDER_BY_CLAUSE);
4539
4540 String[] orderByFields = orderByComparator.getOrderByFields();
4541
4542 for (int i = 0; i < orderByFields.length; i++) {
4543 query.append(_ORDER_BY_ENTITY_ALIAS);
4544 query.append(orderByFields[i]);
4545
4546 if ((i + 1) < orderByFields.length) {
4547 if (orderByComparator.isAscending() ^ previous) {
4548 query.append(ORDER_BY_ASC_HAS_NEXT);
4549 }
4550 else {
4551 query.append(ORDER_BY_DESC_HAS_NEXT);
4552 }
4553 }
4554 else {
4555 if (orderByComparator.isAscending() ^ previous) {
4556 query.append(ORDER_BY_ASC);
4557 }
4558 else {
4559 query.append(ORDER_BY_DESC);
4560 }
4561 }
4562 }
4563 }
4564
4565 else {
4566 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
4567 }
4568
4569 String sql = query.toString();
4570
4571 Query q = session.createQuery(sql);
4572
4573 q.setFirstResult(0);
4574 q.setMaxResults(2);
4575
4576 QueryPos qPos = QueryPos.getInstance(q);
4577
4578 qPos.add(categoryId);
4579
4580 qPos.add(priority);
4581
4582 if (orderByComparator != null) {
4583 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
4584
4585 for (Object value : values) {
4586 qPos.add(value);
4587 }
4588 }
4589
4590 List<MBThread> list = q.list();
4591
4592 if (list.size() == 2) {
4593 return list.get(1);
4594 }
4595 else {
4596 return null;
4597 }
4598 }
4599
4600
4608 public List<MBThread> findByL_P(Date lastPostDate, double priority)
4609 throws SystemException {
4610 return findByL_P(lastPostDate, priority, QueryUtil.ALL_POS,
4611 QueryUtil.ALL_POS, null);
4612 }
4613
4614
4628 public List<MBThread> findByL_P(Date lastPostDate, double priority,
4629 int start, int end) throws SystemException {
4630 return findByL_P(lastPostDate, priority, start, end, null);
4631 }
4632
4633
4648 public List<MBThread> findByL_P(Date lastPostDate, double priority,
4649 int start, int end, OrderByComparator orderByComparator)
4650 throws SystemException {
4651 FinderPath finderPath = null;
4652 Object[] finderArgs = null;
4653
4654 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4655 (orderByComparator == null)) {
4656 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P;
4657 finderArgs = new Object[] { lastPostDate, priority };
4658 }
4659 else {
4660 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_L_P;
4661 finderArgs = new Object[] {
4662 lastPostDate, priority,
4663
4664 start, end, orderByComparator
4665 };
4666 }
4667
4668 List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(finderPath,
4669 finderArgs, this);
4670
4671 if ((list != null) && !list.isEmpty()) {
4672 for (MBThread mbThread : list) {
4673 if (!Validator.equals(lastPostDate, mbThread.getLastPostDate()) ||
4674 (priority != mbThread.getPriority())) {
4675 list = null;
4676
4677 break;
4678 }
4679 }
4680 }
4681
4682 if (list == null) {
4683 StringBundler query = null;
4684
4685 if (orderByComparator != null) {
4686 query = new StringBundler(4 +
4687 (orderByComparator.getOrderByFields().length * 3));
4688 }
4689 else {
4690 query = new StringBundler(4);
4691 }
4692
4693 query.append(_SQL_SELECT_MBTHREAD_WHERE);
4694
4695 if (lastPostDate == null) {
4696 query.append(_FINDER_COLUMN_L_P_LASTPOSTDATE_1);
4697 }
4698 else {
4699 query.append(_FINDER_COLUMN_L_P_LASTPOSTDATE_2);
4700 }
4701
4702 query.append(_FINDER_COLUMN_L_P_PRIORITY_2);
4703
4704 if (orderByComparator != null) {
4705 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4706 orderByComparator);
4707 }
4708
4709 else {
4710 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
4711 }
4712
4713 String sql = query.toString();
4714
4715 Session session = null;
4716
4717 try {
4718 session = openSession();
4719
4720 Query q = session.createQuery(sql);
4721
4722 QueryPos qPos = QueryPos.getInstance(q);
4723
4724 if (lastPostDate != null) {
4725 qPos.add(CalendarUtil.getTimestamp(lastPostDate));
4726 }
4727
4728 qPos.add(priority);
4729
4730 list = (List<MBThread>)QueryUtil.list(q, getDialect(), start,
4731 end);
4732 }
4733 catch (Exception e) {
4734 throw processException(e);
4735 }
4736 finally {
4737 if (list == null) {
4738 FinderCacheUtil.removeResult(finderPath, finderArgs);
4739 }
4740 else {
4741 cacheResult(list);
4742
4743 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4744 }
4745
4746 closeSession(session);
4747 }
4748 }
4749
4750 return list;
4751 }
4752
4753
4763 public MBThread findByL_P_First(Date lastPostDate, double priority,
4764 OrderByComparator orderByComparator)
4765 throws NoSuchThreadException, SystemException {
4766 MBThread mbThread = fetchByL_P_First(lastPostDate, priority,
4767 orderByComparator);
4768
4769 if (mbThread != null) {
4770 return mbThread;
4771 }
4772
4773 StringBundler msg = new StringBundler(6);
4774
4775 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4776
4777 msg.append("lastPostDate=");
4778 msg.append(lastPostDate);
4779
4780 msg.append(", priority=");
4781 msg.append(priority);
4782
4783 msg.append(StringPool.CLOSE_CURLY_BRACE);
4784
4785 throw new NoSuchThreadException(msg.toString());
4786 }
4787
4788
4797 public MBThread fetchByL_P_First(Date lastPostDate, double priority,
4798 OrderByComparator orderByComparator) throws SystemException {
4799 List<MBThread> list = findByL_P(lastPostDate, priority, 0, 1,
4800 orderByComparator);
4801
4802 if (!list.isEmpty()) {
4803 return list.get(0);
4804 }
4805
4806 return null;
4807 }
4808
4809
4819 public MBThread findByL_P_Last(Date lastPostDate, double priority,
4820 OrderByComparator orderByComparator)
4821 throws NoSuchThreadException, SystemException {
4822 MBThread mbThread = fetchByL_P_Last(lastPostDate, priority,
4823 orderByComparator);
4824
4825 if (mbThread != null) {
4826 return mbThread;
4827 }
4828
4829 StringBundler msg = new StringBundler(6);
4830
4831 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4832
4833 msg.append("lastPostDate=");
4834 msg.append(lastPostDate);
4835
4836 msg.append(", priority=");
4837 msg.append(priority);
4838
4839 msg.append(StringPool.CLOSE_CURLY_BRACE);
4840
4841 throw new NoSuchThreadException(msg.toString());
4842 }
4843
4844
4853 public MBThread fetchByL_P_Last(Date lastPostDate, double priority,
4854 OrderByComparator orderByComparator) throws SystemException {
4855 int count = countByL_P(lastPostDate, priority);
4856
4857 List<MBThread> list = findByL_P(lastPostDate, priority, count - 1,
4858 count, orderByComparator);
4859
4860 if (!list.isEmpty()) {
4861 return list.get(0);
4862 }
4863
4864 return null;
4865 }
4866
4867
4878 public MBThread[] findByL_P_PrevAndNext(long threadId, Date lastPostDate,
4879 double priority, OrderByComparator orderByComparator)
4880 throws NoSuchThreadException, SystemException {
4881 MBThread mbThread = findByPrimaryKey(threadId);
4882
4883 Session session = null;
4884
4885 try {
4886 session = openSession();
4887
4888 MBThread[] array = new MBThreadImpl[3];
4889
4890 array[0] = getByL_P_PrevAndNext(session, mbThread, lastPostDate,
4891 priority, orderByComparator, true);
4892
4893 array[1] = mbThread;
4894
4895 array[2] = getByL_P_PrevAndNext(session, mbThread, lastPostDate,
4896 priority, orderByComparator, false);
4897
4898 return array;
4899 }
4900 catch (Exception e) {
4901 throw processException(e);
4902 }
4903 finally {
4904 closeSession(session);
4905 }
4906 }
4907
4908 protected MBThread getByL_P_PrevAndNext(Session session, MBThread mbThread,
4909 Date lastPostDate, double priority,
4910 OrderByComparator orderByComparator, boolean previous) {
4911 StringBundler query = null;
4912
4913 if (orderByComparator != null) {
4914 query = new StringBundler(6 +
4915 (orderByComparator.getOrderByFields().length * 6));
4916 }
4917 else {
4918 query = new StringBundler(3);
4919 }
4920
4921 query.append(_SQL_SELECT_MBTHREAD_WHERE);
4922
4923 if (lastPostDate == null) {
4924 query.append(_FINDER_COLUMN_L_P_LASTPOSTDATE_1);
4925 }
4926 else {
4927 query.append(_FINDER_COLUMN_L_P_LASTPOSTDATE_2);
4928 }
4929
4930 query.append(_FINDER_COLUMN_L_P_PRIORITY_2);
4931
4932 if (orderByComparator != null) {
4933 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4934
4935 if (orderByConditionFields.length > 0) {
4936 query.append(WHERE_AND);
4937 }
4938
4939 for (int i = 0; i < orderByConditionFields.length; i++) {
4940 query.append(_ORDER_BY_ENTITY_ALIAS);
4941 query.append(orderByConditionFields[i]);
4942
4943 if ((i + 1) < orderByConditionFields.length) {
4944 if (orderByComparator.isAscending() ^ previous) {
4945 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4946 }
4947 else {
4948 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4949 }
4950 }
4951 else {
4952 if (orderByComparator.isAscending() ^ previous) {
4953 query.append(WHERE_GREATER_THAN);
4954 }
4955 else {
4956 query.append(WHERE_LESSER_THAN);
4957 }
4958 }
4959 }
4960
4961 query.append(ORDER_BY_CLAUSE);
4962
4963 String[] orderByFields = orderByComparator.getOrderByFields();
4964
4965 for (int i = 0; i < orderByFields.length; i++) {
4966 query.append(_ORDER_BY_ENTITY_ALIAS);
4967 query.append(orderByFields[i]);
4968
4969 if ((i + 1) < orderByFields.length) {
4970 if (orderByComparator.isAscending() ^ previous) {
4971 query.append(ORDER_BY_ASC_HAS_NEXT);
4972 }
4973 else {
4974 query.append(ORDER_BY_DESC_HAS_NEXT);
4975 }
4976 }
4977 else {
4978 if (orderByComparator.isAscending() ^ previous) {
4979 query.append(ORDER_BY_ASC);
4980 }
4981 else {
4982 query.append(ORDER_BY_DESC);
4983 }
4984 }
4985 }
4986 }
4987
4988 else {
4989 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
4990 }
4991
4992 String sql = query.toString();
4993
4994 Query q = session.createQuery(sql);
4995
4996 q.setFirstResult(0);
4997 q.setMaxResults(2);
4998
4999 QueryPos qPos = QueryPos.getInstance(q);
5000
5001 if (lastPostDate != null) {
5002 qPos.add(CalendarUtil.getTimestamp(lastPostDate));
5003 }
5004
5005 qPos.add(priority);
5006
5007 if (orderByComparator != null) {
5008 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
5009
5010 for (Object value : values) {
5011 qPos.add(value);
5012 }
5013 }
5014
5015 List<MBThread> list = q.list();
5016
5017 if (list.size() == 2) {
5018 return list.get(1);
5019 }
5020 else {
5021 return null;
5022 }
5023 }
5024
5025
5034 public List<MBThread> findByG_C_L(long groupId, long categoryId,
5035 Date lastPostDate) throws SystemException {
5036 return findByG_C_L(groupId, categoryId, lastPostDate,
5037 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5038 }
5039
5040
5055 public List<MBThread> findByG_C_L(long groupId, long categoryId,
5056 Date lastPostDate, int start, int end) throws SystemException {
5057 return findByG_C_L(groupId, categoryId, lastPostDate, start, end, null);
5058 }
5059
5060
5076 public List<MBThread> findByG_C_L(long groupId, long categoryId,
5077 Date lastPostDate, int start, int end,
5078 OrderByComparator orderByComparator) throws SystemException {
5079 FinderPath finderPath = null;
5080 Object[] finderArgs = null;
5081
5082 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5083 (orderByComparator == null)) {
5084 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L;
5085 finderArgs = new Object[] { groupId, categoryId, lastPostDate };
5086 }
5087 else {
5088 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L;
5089 finderArgs = new Object[] {
5090 groupId, categoryId, lastPostDate,
5091
5092 start, end, orderByComparator
5093 };
5094 }
5095
5096 List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(finderPath,
5097 finderArgs, this);
5098
5099 if ((list != null) && !list.isEmpty()) {
5100 for (MBThread mbThread : list) {
5101 if ((groupId != mbThread.getGroupId()) ||
5102 (categoryId != mbThread.getCategoryId()) ||
5103 !Validator.equals(lastPostDate,
5104 mbThread.getLastPostDate())) {
5105 list = null;
5106
5107 break;
5108 }
5109 }
5110 }
5111
5112 if (list == null) {
5113 StringBundler query = null;
5114
5115 if (orderByComparator != null) {
5116 query = new StringBundler(5 +
5117 (orderByComparator.getOrderByFields().length * 3));
5118 }
5119 else {
5120 query = new StringBundler(5);
5121 }
5122
5123 query.append(_SQL_SELECT_MBTHREAD_WHERE);
5124
5125 query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
5126
5127 query.append(_FINDER_COLUMN_G_C_L_CATEGORYID_2);
5128
5129 if (lastPostDate == null) {
5130 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1);
5131 }
5132 else {
5133 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_2);
5134 }
5135
5136 if (orderByComparator != null) {
5137 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5138 orderByComparator);
5139 }
5140
5141 else {
5142 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
5143 }
5144
5145 String sql = query.toString();
5146
5147 Session session = null;
5148
5149 try {
5150 session = openSession();
5151
5152 Query q = session.createQuery(sql);
5153
5154 QueryPos qPos = QueryPos.getInstance(q);
5155
5156 qPos.add(groupId);
5157
5158 qPos.add(categoryId);
5159
5160 if (lastPostDate != null) {
5161 qPos.add(CalendarUtil.getTimestamp(lastPostDate));
5162 }
5163
5164 list = (List<MBThread>)QueryUtil.list(q, getDialect(), start,
5165 end);
5166 }
5167 catch (Exception e) {
5168 throw processException(e);
5169 }
5170 finally {
5171 if (list == null) {
5172 FinderCacheUtil.removeResult(finderPath, finderArgs);
5173 }
5174 else {
5175 cacheResult(list);
5176
5177 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5178 }
5179
5180 closeSession(session);
5181 }
5182 }
5183
5184 return list;
5185 }
5186
5187
5198 public MBThread findByG_C_L_First(long groupId, long categoryId,
5199 Date lastPostDate, OrderByComparator orderByComparator)
5200 throws NoSuchThreadException, SystemException {
5201 MBThread mbThread = fetchByG_C_L_First(groupId, categoryId,
5202 lastPostDate, orderByComparator);
5203
5204 if (mbThread != null) {
5205 return mbThread;
5206 }
5207
5208 StringBundler msg = new StringBundler(8);
5209
5210 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5211
5212 msg.append("groupId=");
5213 msg.append(groupId);
5214
5215 msg.append(", categoryId=");
5216 msg.append(categoryId);
5217
5218 msg.append(", lastPostDate=");
5219 msg.append(lastPostDate);
5220
5221 msg.append(StringPool.CLOSE_CURLY_BRACE);
5222
5223 throw new NoSuchThreadException(msg.toString());
5224 }
5225
5226
5236 public MBThread fetchByG_C_L_First(long groupId, long categoryId,
5237 Date lastPostDate, OrderByComparator orderByComparator)
5238 throws SystemException {
5239 List<MBThread> list = findByG_C_L(groupId, categoryId, lastPostDate, 0,
5240 1, orderByComparator);
5241
5242 if (!list.isEmpty()) {
5243 return list.get(0);
5244 }
5245
5246 return null;
5247 }
5248
5249
5260 public MBThread findByG_C_L_Last(long groupId, long categoryId,
5261 Date lastPostDate, OrderByComparator orderByComparator)
5262 throws NoSuchThreadException, SystemException {
5263 MBThread mbThread = fetchByG_C_L_Last(groupId, categoryId,
5264 lastPostDate, orderByComparator);
5265
5266 if (mbThread != null) {
5267 return mbThread;
5268 }
5269
5270 StringBundler msg = new StringBundler(8);
5271
5272 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5273
5274 msg.append("groupId=");
5275 msg.append(groupId);
5276
5277 msg.append(", categoryId=");
5278 msg.append(categoryId);
5279
5280 msg.append(", lastPostDate=");
5281 msg.append(lastPostDate);
5282
5283 msg.append(StringPool.CLOSE_CURLY_BRACE);
5284
5285 throw new NoSuchThreadException(msg.toString());
5286 }
5287
5288
5298 public MBThread fetchByG_C_L_Last(long groupId, long categoryId,
5299 Date lastPostDate, OrderByComparator orderByComparator)
5300 throws SystemException {
5301 int count = countByG_C_L(groupId, categoryId, lastPostDate);
5302
5303 List<MBThread> list = findByG_C_L(groupId, categoryId, lastPostDate,
5304 count - 1, count, orderByComparator);
5305
5306 if (!list.isEmpty()) {
5307 return list.get(0);
5308 }
5309
5310 return null;
5311 }
5312
5313
5325 public MBThread[] findByG_C_L_PrevAndNext(long threadId, long groupId,
5326 long categoryId, Date lastPostDate, OrderByComparator orderByComparator)
5327 throws NoSuchThreadException, SystemException {
5328 MBThread mbThread = findByPrimaryKey(threadId);
5329
5330 Session session = null;
5331
5332 try {
5333 session = openSession();
5334
5335 MBThread[] array = new MBThreadImpl[3];
5336
5337 array[0] = getByG_C_L_PrevAndNext(session, mbThread, groupId,
5338 categoryId, lastPostDate, orderByComparator, true);
5339
5340 array[1] = mbThread;
5341
5342 array[2] = getByG_C_L_PrevAndNext(session, mbThread, groupId,
5343 categoryId, lastPostDate, orderByComparator, false);
5344
5345 return array;
5346 }
5347 catch (Exception e) {
5348 throw processException(e);
5349 }
5350 finally {
5351 closeSession(session);
5352 }
5353 }
5354
5355 protected MBThread getByG_C_L_PrevAndNext(Session session,
5356 MBThread mbThread, long groupId, long categoryId, Date lastPostDate,
5357 OrderByComparator orderByComparator, boolean previous) {
5358 StringBundler query = null;
5359
5360 if (orderByComparator != null) {
5361 query = new StringBundler(6 +
5362 (orderByComparator.getOrderByFields().length * 6));
5363 }
5364 else {
5365 query = new StringBundler(3);
5366 }
5367
5368 query.append(_SQL_SELECT_MBTHREAD_WHERE);
5369
5370 query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
5371
5372 query.append(_FINDER_COLUMN_G_C_L_CATEGORYID_2);
5373
5374 if (lastPostDate == null) {
5375 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1);
5376 }
5377 else {
5378 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_2);
5379 }
5380
5381 if (orderByComparator != null) {
5382 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5383
5384 if (orderByConditionFields.length > 0) {
5385 query.append(WHERE_AND);
5386 }
5387
5388 for (int i = 0; i < orderByConditionFields.length; i++) {
5389 query.append(_ORDER_BY_ENTITY_ALIAS);
5390 query.append(orderByConditionFields[i]);
5391
5392 if ((i + 1) < orderByConditionFields.length) {
5393 if (orderByComparator.isAscending() ^ previous) {
5394 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5395 }
5396 else {
5397 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5398 }
5399 }
5400 else {
5401 if (orderByComparator.isAscending() ^ previous) {
5402 query.append(WHERE_GREATER_THAN);
5403 }
5404 else {
5405 query.append(WHERE_LESSER_THAN);
5406 }
5407 }
5408 }
5409
5410 query.append(ORDER_BY_CLAUSE);
5411
5412 String[] orderByFields = orderByComparator.getOrderByFields();
5413
5414 for (int i = 0; i < orderByFields.length; i++) {
5415 query.append(_ORDER_BY_ENTITY_ALIAS);
5416 query.append(orderByFields[i]);
5417
5418 if ((i + 1) < orderByFields.length) {
5419 if (orderByComparator.isAscending() ^ previous) {
5420 query.append(ORDER_BY_ASC_HAS_NEXT);
5421 }
5422 else {
5423 query.append(ORDER_BY_DESC_HAS_NEXT);
5424 }
5425 }
5426 else {
5427 if (orderByComparator.isAscending() ^ previous) {
5428 query.append(ORDER_BY_ASC);
5429 }
5430 else {
5431 query.append(ORDER_BY_DESC);
5432 }
5433 }
5434 }
5435 }
5436
5437 else {
5438 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
5439 }
5440
5441 String sql = query.toString();
5442
5443 Query q = session.createQuery(sql);
5444
5445 q.setFirstResult(0);
5446 q.setMaxResults(2);
5447
5448 QueryPos qPos = QueryPos.getInstance(q);
5449
5450 qPos.add(groupId);
5451
5452 qPos.add(categoryId);
5453
5454 if (lastPostDate != null) {
5455 qPos.add(CalendarUtil.getTimestamp(lastPostDate));
5456 }
5457
5458 if (orderByComparator != null) {
5459 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
5460
5461 for (Object value : values) {
5462 qPos.add(value);
5463 }
5464 }
5465
5466 List<MBThread> list = q.list();
5467
5468 if (list.size() == 2) {
5469 return list.get(1);
5470 }
5471 else {
5472 return null;
5473 }
5474 }
5475
5476
5485 public List<MBThread> filterFindByG_C_L(long groupId, long categoryId,
5486 Date lastPostDate) throws SystemException {
5487 return filterFindByG_C_L(groupId, categoryId, lastPostDate,
5488 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5489 }
5490
5491
5506 public List<MBThread> filterFindByG_C_L(long groupId, long categoryId,
5507 Date lastPostDate, int start, int end) throws SystemException {
5508 return filterFindByG_C_L(groupId, categoryId, lastPostDate, start, end,
5509 null);
5510 }
5511
5512
5528 public List<MBThread> filterFindByG_C_L(long groupId, long categoryId,
5529 Date lastPostDate, int start, int end,
5530 OrderByComparator orderByComparator) throws SystemException {
5531 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5532 return findByG_C_L(groupId, categoryId, lastPostDate, start, end,
5533 orderByComparator);
5534 }
5535
5536 StringBundler query = null;
5537
5538 if (orderByComparator != null) {
5539 query = new StringBundler(5 +
5540 (orderByComparator.getOrderByFields().length * 3));
5541 }
5542 else {
5543 query = new StringBundler(5);
5544 }
5545
5546 if (getDB().isSupportsInlineDistinct()) {
5547 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
5548 }
5549 else {
5550 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
5551 }
5552
5553 query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
5554
5555 query.append(_FINDER_COLUMN_G_C_L_CATEGORYID_2);
5556
5557 if (lastPostDate == null) {
5558 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1);
5559 }
5560 else {
5561 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_2);
5562 }
5563
5564 if (!getDB().isSupportsInlineDistinct()) {
5565 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
5566 }
5567
5568 if (orderByComparator != null) {
5569 if (getDB().isSupportsInlineDistinct()) {
5570 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5571 orderByComparator);
5572 }
5573 else {
5574 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
5575 orderByComparator);
5576 }
5577 }
5578
5579 else {
5580 if (getDB().isSupportsInlineDistinct()) {
5581 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
5582 }
5583 else {
5584 query.append(MBThreadModelImpl.ORDER_BY_SQL);
5585 }
5586 }
5587
5588 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5589 MBThread.class.getName(),
5590 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5591
5592 Session session = null;
5593
5594 try {
5595 session = openSession();
5596
5597 SQLQuery q = session.createSQLQuery(sql);
5598
5599 if (getDB().isSupportsInlineDistinct()) {
5600 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
5601 }
5602 else {
5603 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
5604 }
5605
5606 QueryPos qPos = QueryPos.getInstance(q);
5607
5608 qPos.add(groupId);
5609
5610 qPos.add(categoryId);
5611
5612 if (lastPostDate != null) {
5613 qPos.add(CalendarUtil.getTimestamp(lastPostDate));
5614 }
5615
5616 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
5617 }
5618 catch (Exception e) {
5619 throw processException(e);
5620 }
5621 finally {
5622 closeSession(session);
5623 }
5624 }
5625
5626
5638 public MBThread[] filterFindByG_C_L_PrevAndNext(long threadId,
5639 long groupId, long categoryId, Date lastPostDate,
5640 OrderByComparator orderByComparator)
5641 throws NoSuchThreadException, SystemException {
5642 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5643 return findByG_C_L_PrevAndNext(threadId, groupId, categoryId,
5644 lastPostDate, orderByComparator);
5645 }
5646
5647 MBThread mbThread = findByPrimaryKey(threadId);
5648
5649 Session session = null;
5650
5651 try {
5652 session = openSession();
5653
5654 MBThread[] array = new MBThreadImpl[3];
5655
5656 array[0] = filterGetByG_C_L_PrevAndNext(session, mbThread, groupId,
5657 categoryId, lastPostDate, orderByComparator, true);
5658
5659 array[1] = mbThread;
5660
5661 array[2] = filterGetByG_C_L_PrevAndNext(session, mbThread, groupId,
5662 categoryId, lastPostDate, orderByComparator, false);
5663
5664 return array;
5665 }
5666 catch (Exception e) {
5667 throw processException(e);
5668 }
5669 finally {
5670 closeSession(session);
5671 }
5672 }
5673
5674 protected MBThread filterGetByG_C_L_PrevAndNext(Session session,
5675 MBThread mbThread, long groupId, long categoryId, Date lastPostDate,
5676 OrderByComparator orderByComparator, boolean previous) {
5677 StringBundler query = null;
5678
5679 if (orderByComparator != null) {
5680 query = new StringBundler(6 +
5681 (orderByComparator.getOrderByFields().length * 6));
5682 }
5683 else {
5684 query = new StringBundler(3);
5685 }
5686
5687 if (getDB().isSupportsInlineDistinct()) {
5688 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
5689 }
5690 else {
5691 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
5692 }
5693
5694 query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
5695
5696 query.append(_FINDER_COLUMN_G_C_L_CATEGORYID_2);
5697
5698 if (lastPostDate == null) {
5699 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1);
5700 }
5701 else {
5702 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_2);
5703 }
5704
5705 if (!getDB().isSupportsInlineDistinct()) {
5706 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
5707 }
5708
5709 if (orderByComparator != null) {
5710 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5711
5712 if (orderByConditionFields.length > 0) {
5713 query.append(WHERE_AND);
5714 }
5715
5716 for (int i = 0; i < orderByConditionFields.length; i++) {
5717 if (getDB().isSupportsInlineDistinct()) {
5718 query.append(_ORDER_BY_ENTITY_ALIAS);
5719 }
5720 else {
5721 query.append(_ORDER_BY_ENTITY_TABLE);
5722 }
5723
5724 query.append(orderByConditionFields[i]);
5725
5726 if ((i + 1) < orderByConditionFields.length) {
5727 if (orderByComparator.isAscending() ^ previous) {
5728 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5729 }
5730 else {
5731 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5732 }
5733 }
5734 else {
5735 if (orderByComparator.isAscending() ^ previous) {
5736 query.append(WHERE_GREATER_THAN);
5737 }
5738 else {
5739 query.append(WHERE_LESSER_THAN);
5740 }
5741 }
5742 }
5743
5744 query.append(ORDER_BY_CLAUSE);
5745
5746 String[] orderByFields = orderByComparator.getOrderByFields();
5747
5748 for (int i = 0; i < orderByFields.length; i++) {
5749 if (getDB().isSupportsInlineDistinct()) {
5750 query.append(_ORDER_BY_ENTITY_ALIAS);
5751 }
5752 else {
5753 query.append(_ORDER_BY_ENTITY_TABLE);
5754 }
5755
5756 query.append(orderByFields[i]);
5757
5758 if ((i + 1) < orderByFields.length) {
5759 if (orderByComparator.isAscending() ^ previous) {
5760 query.append(ORDER_BY_ASC_HAS_NEXT);
5761 }
5762 else {
5763 query.append(ORDER_BY_DESC_HAS_NEXT);
5764 }
5765 }
5766 else {
5767 if (orderByComparator.isAscending() ^ previous) {
5768 query.append(ORDER_BY_ASC);
5769 }
5770 else {
5771 query.append(ORDER_BY_DESC);
5772 }
5773 }
5774 }
5775 }
5776
5777 else {
5778 if (getDB().isSupportsInlineDistinct()) {
5779 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
5780 }
5781 else {
5782 query.append(MBThreadModelImpl.ORDER_BY_SQL);
5783 }
5784 }
5785
5786 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5787 MBThread.class.getName(),
5788 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5789
5790 SQLQuery q = session.createSQLQuery(sql);
5791
5792 q.setFirstResult(0);
5793 q.setMaxResults(2);
5794
5795 if (getDB().isSupportsInlineDistinct()) {
5796 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
5797 }
5798 else {
5799 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
5800 }
5801
5802 QueryPos qPos = QueryPos.getInstance(q);
5803
5804 qPos.add(groupId);
5805
5806 qPos.add(categoryId);
5807
5808 if (lastPostDate != null) {
5809 qPos.add(CalendarUtil.getTimestamp(lastPostDate));
5810 }
5811
5812 if (orderByComparator != null) {
5813 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
5814
5815 for (Object value : values) {
5816 qPos.add(value);
5817 }
5818 }
5819
5820 List<MBThread> list = q.list();
5821
5822 if (list.size() == 2) {
5823 return list.get(1);
5824 }
5825 else {
5826 return null;
5827 }
5828 }
5829
5830
5839 public List<MBThread> findByG_C_S(long groupId, long categoryId, int status)
5840 throws SystemException {
5841 return findByG_C_S(groupId, categoryId, status, QueryUtil.ALL_POS,
5842 QueryUtil.ALL_POS, null);
5843 }
5844
5845
5860 public List<MBThread> findByG_C_S(long groupId, long categoryId,
5861 int status, int start, int end) throws SystemException {
5862 return findByG_C_S(groupId, categoryId, status, start, end, null);
5863 }
5864
5865
5881 public List<MBThread> findByG_C_S(long groupId, long categoryId,
5882 int status, int start, int end, OrderByComparator orderByComparator)
5883 throws SystemException {
5884 FinderPath finderPath = null;
5885 Object[] finderArgs = null;
5886
5887 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5888 (orderByComparator == null)) {
5889 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_S;
5890 finderArgs = new Object[] { groupId, categoryId, status };
5891 }
5892 else {
5893 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_S;
5894 finderArgs = new Object[] {
5895 groupId, categoryId, status,
5896
5897 start, end, orderByComparator
5898 };
5899 }
5900
5901 List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(finderPath,
5902 finderArgs, this);
5903
5904 if ((list != null) && !list.isEmpty()) {
5905 for (MBThread mbThread : list) {
5906 if ((groupId != mbThread.getGroupId()) ||
5907 (categoryId != mbThread.getCategoryId()) ||
5908 (status != mbThread.getStatus())) {
5909 list = null;
5910
5911 break;
5912 }
5913 }
5914 }
5915
5916 if (list == null) {
5917 StringBundler query = null;
5918
5919 if (orderByComparator != null) {
5920 query = new StringBundler(5 +
5921 (orderByComparator.getOrderByFields().length * 3));
5922 }
5923 else {
5924 query = new StringBundler(5);
5925 }
5926
5927 query.append(_SQL_SELECT_MBTHREAD_WHERE);
5928
5929 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
5930
5931 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
5932
5933 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
5934
5935 if (orderByComparator != null) {
5936 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5937 orderByComparator);
5938 }
5939
5940 else {
5941 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
5942 }
5943
5944 String sql = query.toString();
5945
5946 Session session = null;
5947
5948 try {
5949 session = openSession();
5950
5951 Query q = session.createQuery(sql);
5952
5953 QueryPos qPos = QueryPos.getInstance(q);
5954
5955 qPos.add(groupId);
5956
5957 qPos.add(categoryId);
5958
5959 qPos.add(status);
5960
5961 list = (List<MBThread>)QueryUtil.list(q, getDialect(), start,
5962 end);
5963 }
5964 catch (Exception e) {
5965 throw processException(e);
5966 }
5967 finally {
5968 if (list == null) {
5969 FinderCacheUtil.removeResult(finderPath, finderArgs);
5970 }
5971 else {
5972 cacheResult(list);
5973
5974 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5975 }
5976
5977 closeSession(session);
5978 }
5979 }
5980
5981 return list;
5982 }
5983
5984
5995 public MBThread findByG_C_S_First(long groupId, long categoryId,
5996 int status, OrderByComparator orderByComparator)
5997 throws NoSuchThreadException, SystemException {
5998 MBThread mbThread = fetchByG_C_S_First(groupId, categoryId, status,
5999 orderByComparator);
6000
6001 if (mbThread != null) {
6002 return mbThread;
6003 }
6004
6005 StringBundler msg = new StringBundler(8);
6006
6007 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6008
6009 msg.append("groupId=");
6010 msg.append(groupId);
6011
6012 msg.append(", categoryId=");
6013 msg.append(categoryId);
6014
6015 msg.append(", status=");
6016 msg.append(status);
6017
6018 msg.append(StringPool.CLOSE_CURLY_BRACE);
6019
6020 throw new NoSuchThreadException(msg.toString());
6021 }
6022
6023
6033 public MBThread fetchByG_C_S_First(long groupId, long categoryId,
6034 int status, OrderByComparator orderByComparator)
6035 throws SystemException {
6036 List<MBThread> list = findByG_C_S(groupId, categoryId, status, 0, 1,
6037 orderByComparator);
6038
6039 if (!list.isEmpty()) {
6040 return list.get(0);
6041 }
6042
6043 return null;
6044 }
6045
6046
6057 public MBThread findByG_C_S_Last(long groupId, long categoryId, int status,
6058 OrderByComparator orderByComparator)
6059 throws NoSuchThreadException, SystemException {
6060 MBThread mbThread = fetchByG_C_S_Last(groupId, categoryId, status,
6061 orderByComparator);
6062
6063 if (mbThread != null) {
6064 return mbThread;
6065 }
6066
6067 StringBundler msg = new StringBundler(8);
6068
6069 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6070
6071 msg.append("groupId=");
6072 msg.append(groupId);
6073
6074 msg.append(", categoryId=");
6075 msg.append(categoryId);
6076
6077 msg.append(", status=");
6078 msg.append(status);
6079
6080 msg.append(StringPool.CLOSE_CURLY_BRACE);
6081
6082 throw new NoSuchThreadException(msg.toString());
6083 }
6084
6085
6095 public MBThread fetchByG_C_S_Last(long groupId, long categoryId,
6096 int status, OrderByComparator orderByComparator)
6097 throws SystemException {
6098 int count = countByG_C_S(groupId, categoryId, status);
6099
6100 List<MBThread> list = findByG_C_S(groupId, categoryId, status,
6101 count - 1, count, orderByComparator);
6102
6103 if (!list.isEmpty()) {
6104 return list.get(0);
6105 }
6106
6107 return null;
6108 }
6109
6110
6122 public MBThread[] findByG_C_S_PrevAndNext(long threadId, long groupId,
6123 long categoryId, int status, OrderByComparator orderByComparator)
6124 throws NoSuchThreadException, SystemException {
6125 MBThread mbThread = findByPrimaryKey(threadId);
6126
6127 Session session = null;
6128
6129 try {
6130 session = openSession();
6131
6132 MBThread[] array = new MBThreadImpl[3];
6133
6134 array[0] = getByG_C_S_PrevAndNext(session, mbThread, groupId,
6135 categoryId, status, orderByComparator, true);
6136
6137 array[1] = mbThread;
6138
6139 array[2] = getByG_C_S_PrevAndNext(session, mbThread, groupId,
6140 categoryId, status, orderByComparator, false);
6141
6142 return array;
6143 }
6144 catch (Exception e) {
6145 throw processException(e);
6146 }
6147 finally {
6148 closeSession(session);
6149 }
6150 }
6151
6152 protected MBThread getByG_C_S_PrevAndNext(Session session,
6153 MBThread mbThread, long groupId, long categoryId, int status,
6154 OrderByComparator orderByComparator, boolean previous) {
6155 StringBundler query = null;
6156
6157 if (orderByComparator != null) {
6158 query = new StringBundler(6 +
6159 (orderByComparator.getOrderByFields().length * 6));
6160 }
6161 else {
6162 query = new StringBundler(3);
6163 }
6164
6165 query.append(_SQL_SELECT_MBTHREAD_WHERE);
6166
6167 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
6168
6169 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
6170
6171 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
6172
6173 if (orderByComparator != null) {
6174 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6175
6176 if (orderByConditionFields.length > 0) {
6177 query.append(WHERE_AND);
6178 }
6179
6180 for (int i = 0; i < orderByConditionFields.length; i++) {
6181 query.append(_ORDER_BY_ENTITY_ALIAS);
6182 query.append(orderByConditionFields[i]);
6183
6184 if ((i + 1) < orderByConditionFields.length) {
6185 if (orderByComparator.isAscending() ^ previous) {
6186 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6187 }
6188 else {
6189 query.append(WHERE_LESSER_THAN_HAS_NEXT);
6190 }
6191 }
6192 else {
6193 if (orderByComparator.isAscending() ^ previous) {
6194 query.append(WHERE_GREATER_THAN);
6195 }
6196 else {
6197 query.append(WHERE_LESSER_THAN);
6198 }
6199 }
6200 }
6201
6202 query.append(ORDER_BY_CLAUSE);
6203
6204 String[] orderByFields = orderByComparator.getOrderByFields();
6205
6206 for (int i = 0; i < orderByFields.length; i++) {
6207 query.append(_ORDER_BY_ENTITY_ALIAS);
6208 query.append(orderByFields[i]);
6209
6210 if ((i + 1) < orderByFields.length) {
6211 if (orderByComparator.isAscending() ^ previous) {
6212 query.append(ORDER_BY_ASC_HAS_NEXT);
6213 }
6214 else {
6215 query.append(ORDER_BY_DESC_HAS_NEXT);
6216 }
6217 }
6218 else {
6219 if (orderByComparator.isAscending() ^ previous) {
6220 query.append(ORDER_BY_ASC);
6221 }
6222 else {
6223 query.append(ORDER_BY_DESC);
6224 }
6225 }
6226 }
6227 }
6228
6229 else {
6230 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
6231 }
6232
6233 String sql = query.toString();
6234
6235 Query q = session.createQuery(sql);
6236
6237 q.setFirstResult(0);
6238 q.setMaxResults(2);
6239
6240 QueryPos qPos = QueryPos.getInstance(q);
6241
6242 qPos.add(groupId);
6243
6244 qPos.add(categoryId);
6245
6246 qPos.add(status);
6247
6248 if (orderByComparator != null) {
6249 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
6250
6251 for (Object value : values) {
6252 qPos.add(value);
6253 }
6254 }
6255
6256 List<MBThread> list = q.list();
6257
6258 if (list.size() == 2) {
6259 return list.get(1);
6260 }
6261 else {
6262 return null;
6263 }
6264 }
6265
6266
6279 public List<MBThread> findByG_C_S(long groupId, long[] categoryIds,
6280 int status) throws SystemException {
6281 return findByG_C_S(groupId, categoryIds, status, QueryUtil.ALL_POS,
6282 QueryUtil.ALL_POS, null);
6283 }
6284
6285
6300 public List<MBThread> findByG_C_S(long groupId, long[] categoryIds,
6301 int status, int start, int end) throws SystemException {
6302 return findByG_C_S(groupId, categoryIds, status, start, end, null);
6303 }
6304
6305
6321 public List<MBThread> findByG_C_S(long groupId, long[] categoryIds,
6322 int status, int start, int end, OrderByComparator orderByComparator)
6323 throws SystemException {
6324 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_S;
6325 Object[] finderArgs = null;
6326
6327 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6328 (orderByComparator == null)) {
6329 finderArgs = new Object[] {
6330 groupId, StringUtil.merge(categoryIds), status
6331 };
6332 }
6333 else {
6334 finderArgs = new Object[] {
6335 groupId, StringUtil.merge(categoryIds), status,
6336
6337 start, end, orderByComparator
6338 };
6339 }
6340
6341 List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(finderPath,
6342 finderArgs, this);
6343
6344 if ((list != null) && !list.isEmpty()) {
6345 for (MBThread mbThread : list) {
6346 if ((groupId != mbThread.getGroupId()) ||
6347 !ArrayUtil.contains(categoryIds,
6348 mbThread.getCategoryId()) ||
6349 (status != mbThread.getStatus())) {
6350 list = null;
6351
6352 break;
6353 }
6354 }
6355 }
6356
6357 if (list == null) {
6358 StringBundler query = new StringBundler();
6359
6360 query.append(_SQL_SELECT_MBTHREAD_WHERE);
6361
6362 boolean conjunctionable = false;
6363
6364 if (conjunctionable) {
6365 query.append(WHERE_AND);
6366 }
6367
6368 query.append(_FINDER_COLUMN_G_C_S_GROUPID_5);
6369
6370 conjunctionable = true;
6371
6372 if ((categoryIds == null) || (categoryIds.length > 0)) {
6373 if (conjunctionable) {
6374 query.append(WHERE_AND);
6375 }
6376
6377 query.append(StringPool.OPEN_PARENTHESIS);
6378
6379 for (int i = 0; i < categoryIds.length; i++) {
6380 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_5);
6381
6382 if ((i + 1) < categoryIds.length) {
6383 query.append(WHERE_OR);
6384 }
6385 }
6386
6387 query.append(StringPool.CLOSE_PARENTHESIS);
6388
6389 conjunctionable = true;
6390 }
6391
6392 if (conjunctionable) {
6393 query.append(WHERE_AND);
6394 }
6395
6396 query.append(_FINDER_COLUMN_G_C_S_STATUS_5);
6397
6398 conjunctionable = true;
6399
6400 if (orderByComparator != null) {
6401 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6402 orderByComparator);
6403 }
6404
6405 else {
6406 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
6407 }
6408
6409 String sql = query.toString();
6410
6411 Session session = null;
6412
6413 try {
6414 session = openSession();
6415
6416 Query q = session.createQuery(sql);
6417
6418 QueryPos qPos = QueryPos.getInstance(q);
6419
6420 qPos.add(groupId);
6421
6422 if (categoryIds != null) {
6423 qPos.add(categoryIds);
6424 }
6425
6426 qPos.add(status);
6427
6428 list = (List<MBThread>)QueryUtil.list(q, getDialect(), start,
6429 end);
6430 }
6431 catch (Exception e) {
6432 throw processException(e);
6433 }
6434 finally {
6435 if (list == null) {
6436 FinderCacheUtil.removeResult(finderPath, finderArgs);
6437 }
6438 else {
6439 cacheResult(list);
6440
6441 FinderCacheUtil.putResult(finderPath, finderArgs, list);
6442 }
6443
6444 closeSession(session);
6445 }
6446 }
6447
6448 return list;
6449 }
6450
6451
6460 public List<MBThread> filterFindByG_C_S(long groupId, long categoryId,
6461 int status) throws SystemException {
6462 return filterFindByG_C_S(groupId, categoryId, status,
6463 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6464 }
6465
6466
6481 public List<MBThread> filterFindByG_C_S(long groupId, long categoryId,
6482 int status, int start, int end) throws SystemException {
6483 return filterFindByG_C_S(groupId, categoryId, status, start, end, null);
6484 }
6485
6486
6502 public List<MBThread> filterFindByG_C_S(long groupId, long categoryId,
6503 int status, int start, int end, OrderByComparator orderByComparator)
6504 throws SystemException {
6505 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6506 return findByG_C_S(groupId, categoryId, status, start, end,
6507 orderByComparator);
6508 }
6509
6510 StringBundler query = null;
6511
6512 if (orderByComparator != null) {
6513 query = new StringBundler(5 +
6514 (orderByComparator.getOrderByFields().length * 3));
6515 }
6516 else {
6517 query = new StringBundler(5);
6518 }
6519
6520 if (getDB().isSupportsInlineDistinct()) {
6521 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
6522 }
6523 else {
6524 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
6525 }
6526
6527 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
6528
6529 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
6530
6531 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
6532
6533 if (!getDB().isSupportsInlineDistinct()) {
6534 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
6535 }
6536
6537 if (orderByComparator != null) {
6538 if (getDB().isSupportsInlineDistinct()) {
6539 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6540 orderByComparator);
6541 }
6542 else {
6543 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6544 orderByComparator);
6545 }
6546 }
6547
6548 else {
6549 if (getDB().isSupportsInlineDistinct()) {
6550 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
6551 }
6552 else {
6553 query.append(MBThreadModelImpl.ORDER_BY_SQL);
6554 }
6555 }
6556
6557 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6558 MBThread.class.getName(),
6559 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6560
6561 Session session = null;
6562
6563 try {
6564 session = openSession();
6565
6566 SQLQuery q = session.createSQLQuery(sql);
6567
6568 if (getDB().isSupportsInlineDistinct()) {
6569 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
6570 }
6571 else {
6572 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
6573 }
6574
6575 QueryPos qPos = QueryPos.getInstance(q);
6576
6577 qPos.add(groupId);
6578
6579 qPos.add(categoryId);
6580
6581 qPos.add(status);
6582
6583 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
6584 }
6585 catch (Exception e) {
6586 throw processException(e);
6587 }
6588 finally {
6589 closeSession(session);
6590 }
6591 }
6592
6593
6605 public MBThread[] filterFindByG_C_S_PrevAndNext(long threadId,
6606 long groupId, long categoryId, int status,
6607 OrderByComparator orderByComparator)
6608 throws NoSuchThreadException, SystemException {
6609 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6610 return findByG_C_S_PrevAndNext(threadId, groupId, categoryId,
6611 status, orderByComparator);
6612 }
6613
6614 MBThread mbThread = findByPrimaryKey(threadId);
6615
6616 Session session = null;
6617
6618 try {
6619 session = openSession();
6620
6621 MBThread[] array = new MBThreadImpl[3];
6622
6623 array[0] = filterGetByG_C_S_PrevAndNext(session, mbThread, groupId,
6624 categoryId, status, orderByComparator, true);
6625
6626 array[1] = mbThread;
6627
6628 array[2] = filterGetByG_C_S_PrevAndNext(session, mbThread, groupId,
6629 categoryId, status, orderByComparator, false);
6630
6631 return array;
6632 }
6633 catch (Exception e) {
6634 throw processException(e);
6635 }
6636 finally {
6637 closeSession(session);
6638 }
6639 }
6640
6641 protected MBThread filterGetByG_C_S_PrevAndNext(Session session,
6642 MBThread mbThread, long groupId, long categoryId, int status,
6643 OrderByComparator orderByComparator, boolean previous) {
6644 StringBundler query = null;
6645
6646 if (orderByComparator != null) {
6647 query = new StringBundler(6 +
6648 (orderByComparator.getOrderByFields().length * 6));
6649 }
6650 else {
6651 query = new StringBundler(3);
6652 }
6653
6654 if (getDB().isSupportsInlineDistinct()) {
6655 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
6656 }
6657 else {
6658 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
6659 }
6660
6661 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
6662
6663 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
6664
6665 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
6666
6667 if (!getDB().isSupportsInlineDistinct()) {
6668 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
6669 }
6670
6671 if (orderByComparator != null) {
6672 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6673
6674 if (orderByConditionFields.length > 0) {
6675 query.append(WHERE_AND);
6676 }
6677
6678 for (int i = 0; i < orderByConditionFields.length; i++) {
6679 if (getDB().isSupportsInlineDistinct()) {
6680 query.append(_ORDER_BY_ENTITY_ALIAS);
6681 }
6682 else {
6683 query.append(_ORDER_BY_ENTITY_TABLE);
6684 }
6685
6686 query.append(orderByConditionFields[i]);
6687
6688 if ((i + 1) < orderByConditionFields.length) {
6689 if (orderByComparator.isAscending() ^ previous) {
6690 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6691 }
6692 else {
6693 query.append(WHERE_LESSER_THAN_HAS_NEXT);
6694 }
6695 }
6696 else {
6697 if (orderByComparator.isAscending() ^ previous) {
6698 query.append(WHERE_GREATER_THAN);
6699 }
6700 else {
6701 query.append(WHERE_LESSER_THAN);
6702 }
6703 }
6704 }
6705
6706 query.append(ORDER_BY_CLAUSE);
6707
6708 String[] orderByFields = orderByComparator.getOrderByFields();
6709
6710 for (int i = 0; i < orderByFields.length; i++) {
6711 if (getDB().isSupportsInlineDistinct()) {
6712 query.append(_ORDER_BY_ENTITY_ALIAS);
6713 }
6714 else {
6715 query.append(_ORDER_BY_ENTITY_TABLE);
6716 }
6717
6718 query.append(orderByFields[i]);
6719
6720 if ((i + 1) < orderByFields.length) {
6721 if (orderByComparator.isAscending() ^ previous) {
6722 query.append(ORDER_BY_ASC_HAS_NEXT);
6723 }
6724 else {
6725 query.append(ORDER_BY_DESC_HAS_NEXT);
6726 }
6727 }
6728 else {
6729 if (orderByComparator.isAscending() ^ previous) {
6730 query.append(ORDER_BY_ASC);
6731 }
6732 else {
6733 query.append(ORDER_BY_DESC);
6734 }
6735 }
6736 }
6737 }
6738
6739 else {
6740 if (getDB().isSupportsInlineDistinct()) {
6741 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
6742 }
6743 else {
6744 query.append(MBThreadModelImpl.ORDER_BY_SQL);
6745 }
6746 }
6747
6748 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6749 MBThread.class.getName(),
6750 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6751
6752 SQLQuery q = session.createSQLQuery(sql);
6753
6754 q.setFirstResult(0);
6755 q.setMaxResults(2);
6756
6757 if (getDB().isSupportsInlineDistinct()) {
6758 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
6759 }
6760 else {
6761 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
6762 }
6763
6764 QueryPos qPos = QueryPos.getInstance(q);
6765
6766 qPos.add(groupId);
6767
6768 qPos.add(categoryId);
6769
6770 qPos.add(status);
6771
6772 if (orderByComparator != null) {
6773 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
6774
6775 for (Object value : values) {
6776 qPos.add(value);
6777 }
6778 }
6779
6780 List<MBThread> list = q.list();
6781
6782 if (list.size() == 2) {
6783 return list.get(1);
6784 }
6785 else {
6786 return null;
6787 }
6788 }
6789
6790
6799 public List<MBThread> filterFindByG_C_S(long groupId, long[] categoryIds,
6800 int status) throws SystemException {
6801 return filterFindByG_C_S(groupId, categoryIds, status,
6802 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6803 }
6804
6805
6820 public List<MBThread> filterFindByG_C_S(long groupId, long[] categoryIds,
6821 int status, int start, int end) throws SystemException {
6822 return filterFindByG_C_S(groupId, categoryIds, status, start, end, null);
6823 }
6824
6825
6841 public List<MBThread> filterFindByG_C_S(long groupId, long[] categoryIds,
6842 int status, int start, int end, OrderByComparator orderByComparator)
6843 throws SystemException {
6844 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6845 return findByG_C_S(groupId, categoryIds, status, start, end,
6846 orderByComparator);
6847 }
6848
6849 StringBundler query = new StringBundler();
6850
6851 if (getDB().isSupportsInlineDistinct()) {
6852 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
6853 }
6854 else {
6855 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
6856 }
6857
6858 boolean conjunctionable = false;
6859
6860 if (conjunctionable) {
6861 query.append(WHERE_AND);
6862 }
6863
6864 query.append(_FINDER_COLUMN_G_C_S_GROUPID_5);
6865
6866 conjunctionable = true;
6867
6868 if ((categoryIds == null) || (categoryIds.length > 0)) {
6869 if (conjunctionable) {
6870 query.append(WHERE_AND);
6871 }
6872
6873 query.append(StringPool.OPEN_PARENTHESIS);
6874
6875 for (int i = 0; i < categoryIds.length; i++) {
6876 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_5);
6877
6878 if ((i + 1) < categoryIds.length) {
6879 query.append(WHERE_OR);
6880 }
6881 }
6882
6883 query.append(StringPool.CLOSE_PARENTHESIS);
6884
6885 conjunctionable = true;
6886 }
6887
6888 if (conjunctionable) {
6889 query.append(WHERE_AND);
6890 }
6891
6892 query.append(_FINDER_COLUMN_G_C_S_STATUS_5);
6893
6894 conjunctionable = true;
6895
6896 if (!getDB().isSupportsInlineDistinct()) {
6897 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
6898 }
6899
6900 if (orderByComparator != null) {
6901 if (getDB().isSupportsInlineDistinct()) {
6902 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6903 orderByComparator);
6904 }
6905 else {
6906 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6907 orderByComparator);
6908 }
6909 }
6910
6911 else {
6912 if (getDB().isSupportsInlineDistinct()) {
6913 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
6914 }
6915 else {
6916 query.append(MBThreadModelImpl.ORDER_BY_SQL);
6917 }
6918 }
6919
6920 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6921 MBThread.class.getName(),
6922 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6923
6924 Session session = null;
6925
6926 try {
6927 session = openSession();
6928
6929 SQLQuery q = session.createSQLQuery(sql);
6930
6931 if (getDB().isSupportsInlineDistinct()) {
6932 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
6933 }
6934 else {
6935 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
6936 }
6937
6938 QueryPos qPos = QueryPos.getInstance(q);
6939
6940 qPos.add(groupId);
6941
6942 if (categoryIds != null) {
6943 qPos.add(categoryIds);
6944 }
6945
6946 qPos.add(status);
6947
6948 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
6949 }
6950 catch (Exception e) {
6951 throw processException(e);
6952 }
6953 finally {
6954 closeSession(session);
6955 }
6956 }
6957
6958
6967 public List<MBThread> findByG_NotC_S(long groupId, long categoryId,
6968 int status) throws SystemException {
6969 return findByG_NotC_S(groupId, categoryId, status, QueryUtil.ALL_POS,
6970 QueryUtil.ALL_POS, null);
6971 }
6972
6973
6988 public List<MBThread> findByG_NotC_S(long groupId, long categoryId,
6989 int status, int start, int end) throws SystemException {
6990 return findByG_NotC_S(groupId, categoryId, status, start, end, null);
6991 }
6992
6993
7009 public List<MBThread> findByG_NotC_S(long groupId, long categoryId,
7010 int status, int start, int end, OrderByComparator orderByComparator)
7011 throws SystemException {
7012 FinderPath finderPath = null;
7013 Object[] finderArgs = null;
7014
7015 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTC_S;
7016 finderArgs = new Object[] {
7017 groupId, categoryId, status,
7018
7019 start, end, orderByComparator
7020 };
7021
7022 List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(finderPath,
7023 finderArgs, this);
7024
7025 if ((list != null) && !list.isEmpty()) {
7026 for (MBThread mbThread : list) {
7027 if ((groupId != mbThread.getGroupId()) ||
7028 (categoryId != mbThread.getCategoryId()) ||
7029 (status != mbThread.getStatus())) {
7030 list = null;
7031
7032 break;
7033 }
7034 }
7035 }
7036
7037 if (list == null) {
7038 StringBundler query = null;
7039
7040 if (orderByComparator != null) {
7041 query = new StringBundler(5 +
7042 (orderByComparator.getOrderByFields().length * 3));
7043 }
7044 else {
7045 query = new StringBundler(5);
7046 }
7047
7048 query.append(_SQL_SELECT_MBTHREAD_WHERE);
7049
7050 query.append(_FINDER_COLUMN_G_NOTC_S_GROUPID_2);
7051
7052 query.append(_FINDER_COLUMN_G_NOTC_S_CATEGORYID_2);
7053
7054 query.append(_FINDER_COLUMN_G_NOTC_S_STATUS_2);
7055
7056 if (orderByComparator != null) {
7057 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7058 orderByComparator);
7059 }
7060
7061 else {
7062 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
7063 }
7064
7065 String sql = query.toString();
7066
7067 Session session = null;
7068
7069 try {
7070 session = openSession();
7071
7072 Query q = session.createQuery(sql);
7073
7074 QueryPos qPos = QueryPos.getInstance(q);
7075
7076 qPos.add(groupId);
7077
7078 qPos.add(categoryId);
7079
7080 qPos.add(status);
7081
7082 list = (List<MBThread>)QueryUtil.list(q, getDialect(), start,
7083 end);
7084 }
7085 catch (Exception e) {
7086 throw processException(e);
7087 }
7088 finally {
7089 if (list == null) {
7090 FinderCacheUtil.removeResult(finderPath, finderArgs);
7091 }
7092 else {
7093 cacheResult(list);
7094
7095 FinderCacheUtil.putResult(finderPath, finderArgs, list);
7096 }
7097
7098 closeSession(session);
7099 }
7100 }
7101
7102 return list;
7103 }
7104
7105
7116 public MBThread findByG_NotC_S_First(long groupId, long categoryId,
7117 int status, OrderByComparator orderByComparator)
7118 throws NoSuchThreadException, SystemException {
7119 MBThread mbThread = fetchByG_NotC_S_First(groupId, categoryId, status,
7120 orderByComparator);
7121
7122 if (mbThread != null) {
7123 return mbThread;
7124 }
7125
7126 StringBundler msg = new StringBundler(8);
7127
7128 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7129
7130 msg.append("groupId=");
7131 msg.append(groupId);
7132
7133 msg.append(", categoryId=");
7134 msg.append(categoryId);
7135
7136 msg.append(", status=");
7137 msg.append(status);
7138
7139 msg.append(StringPool.CLOSE_CURLY_BRACE);
7140
7141 throw new NoSuchThreadException(msg.toString());
7142 }
7143
7144
7154 public MBThread fetchByG_NotC_S_First(long groupId, long categoryId,
7155 int status, OrderByComparator orderByComparator)
7156 throws SystemException {
7157 List<MBThread> list = findByG_NotC_S(groupId, categoryId, status, 0, 1,
7158 orderByComparator);
7159
7160 if (!list.isEmpty()) {
7161 return list.get(0);
7162 }
7163
7164 return null;
7165 }
7166
7167
7178 public MBThread findByG_NotC_S_Last(long groupId, long categoryId,
7179 int status, OrderByComparator orderByComparator)
7180 throws NoSuchThreadException, SystemException {
7181 MBThread mbThread = fetchByG_NotC_S_Last(groupId, categoryId, status,
7182 orderByComparator);
7183
7184 if (mbThread != null) {
7185 return mbThread;
7186 }
7187
7188 StringBundler msg = new StringBundler(8);
7189
7190 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7191
7192 msg.append("groupId=");
7193 msg.append(groupId);
7194
7195 msg.append(", categoryId=");
7196 msg.append(categoryId);
7197
7198 msg.append(", status=");
7199 msg.append(status);
7200
7201 msg.append(StringPool.CLOSE_CURLY_BRACE);
7202
7203 throw new NoSuchThreadException(msg.toString());
7204 }
7205
7206
7216 public MBThread fetchByG_NotC_S_Last(long groupId, long categoryId,
7217 int status, OrderByComparator orderByComparator)
7218 throws SystemException {
7219 int count = countByG_NotC_S(groupId, categoryId, status);
7220
7221 List<MBThread> list = findByG_NotC_S(groupId, categoryId, status,
7222 count - 1, count, orderByComparator);
7223
7224 if (!list.isEmpty()) {
7225 return list.get(0);
7226 }
7227
7228 return null;
7229 }
7230
7231
7243 public MBThread[] findByG_NotC_S_PrevAndNext(long threadId, long groupId,
7244 long categoryId, int status, OrderByComparator orderByComparator)
7245 throws NoSuchThreadException, SystemException {
7246 MBThread mbThread = findByPrimaryKey(threadId);
7247
7248 Session session = null;
7249
7250 try {
7251 session = openSession();
7252
7253 MBThread[] array = new MBThreadImpl[3];
7254
7255 array[0] = getByG_NotC_S_PrevAndNext(session, mbThread, groupId,
7256 categoryId, status, orderByComparator, true);
7257
7258 array[1] = mbThread;
7259
7260 array[2] = getByG_NotC_S_PrevAndNext(session, mbThread, groupId,
7261 categoryId, status, orderByComparator, false);
7262
7263 return array;
7264 }
7265 catch (Exception e) {
7266 throw processException(e);
7267 }
7268 finally {
7269 closeSession(session);
7270 }
7271 }
7272
7273 protected MBThread getByG_NotC_S_PrevAndNext(Session session,
7274 MBThread mbThread, long groupId, long categoryId, int status,
7275 OrderByComparator orderByComparator, boolean previous) {
7276 StringBundler query = null;
7277
7278 if (orderByComparator != null) {
7279 query = new StringBundler(6 +
7280 (orderByComparator.getOrderByFields().length * 6));
7281 }
7282 else {
7283 query = new StringBundler(3);
7284 }
7285
7286 query.append(_SQL_SELECT_MBTHREAD_WHERE);
7287
7288 query.append(_FINDER_COLUMN_G_NOTC_S_GROUPID_2);
7289
7290 query.append(_FINDER_COLUMN_G_NOTC_S_CATEGORYID_2);
7291
7292 query.append(_FINDER_COLUMN_G_NOTC_S_STATUS_2);
7293
7294 if (orderByComparator != null) {
7295 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7296
7297 if (orderByConditionFields.length > 0) {
7298 query.append(WHERE_AND);
7299 }
7300
7301 for (int i = 0; i < orderByConditionFields.length; i++) {
7302 query.append(_ORDER_BY_ENTITY_ALIAS);
7303 query.append(orderByConditionFields[i]);
7304
7305 if ((i + 1) < orderByConditionFields.length) {
7306 if (orderByComparator.isAscending() ^ previous) {
7307 query.append(WHERE_GREATER_THAN_HAS_NEXT);
7308 }
7309 else {
7310 query.append(WHERE_LESSER_THAN_HAS_NEXT);
7311 }
7312 }
7313 else {
7314 if (orderByComparator.isAscending() ^ previous) {
7315 query.append(WHERE_GREATER_THAN);
7316 }
7317 else {
7318 query.append(WHERE_LESSER_THAN);
7319 }
7320 }
7321 }
7322
7323 query.append(ORDER_BY_CLAUSE);
7324
7325 String[] orderByFields = orderByComparator.getOrderByFields();
7326
7327 for (int i = 0; i < orderByFields.length; i++) {
7328 query.append(_ORDER_BY_ENTITY_ALIAS);
7329 query.append(orderByFields[i]);
7330
7331 if ((i + 1) < orderByFields.length) {
7332 if (orderByComparator.isAscending() ^ previous) {
7333 query.append(ORDER_BY_ASC_HAS_NEXT);
7334 }
7335 else {
7336 query.append(ORDER_BY_DESC_HAS_NEXT);
7337 }
7338 }
7339 else {
7340 if (orderByComparator.isAscending() ^ previous) {
7341 query.append(ORDER_BY_ASC);
7342 }
7343 else {
7344 query.append(ORDER_BY_DESC);
7345 }
7346 }
7347 }
7348 }
7349
7350 else {
7351 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
7352 }
7353
7354 String sql = query.toString();
7355
7356 Query q = session.createQuery(sql);
7357
7358 q.setFirstResult(0);
7359 q.setMaxResults(2);
7360
7361 QueryPos qPos = QueryPos.getInstance(q);
7362
7363 qPos.add(groupId);
7364
7365 qPos.add(categoryId);
7366
7367 qPos.add(status);
7368
7369 if (orderByComparator != null) {
7370 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
7371
7372 for (Object value : values) {
7373 qPos.add(value);
7374 }
7375 }
7376
7377 List<MBThread> list = q.list();
7378
7379 if (list.size() == 2) {
7380 return list.get(1);
7381 }
7382 else {
7383 return null;
7384 }
7385 }
7386
7387
7396 public List<MBThread> filterFindByG_NotC_S(long groupId, long categoryId,
7397 int status) throws SystemException {
7398 return filterFindByG_NotC_S(groupId, categoryId, status,
7399 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7400 }
7401
7402
7417 public List<MBThread> filterFindByG_NotC_S(long groupId, long categoryId,
7418 int status, int start, int end) throws SystemException {
7419 return filterFindByG_NotC_S(groupId, categoryId, status, start, end,
7420 null);
7421 }
7422
7423
7439 public List<MBThread> filterFindByG_NotC_S(long groupId, long categoryId,
7440 int status, int start, int end, OrderByComparator orderByComparator)
7441 throws SystemException {
7442 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7443 return findByG_NotC_S(groupId, categoryId, status, start, end,
7444 orderByComparator);
7445 }
7446
7447 StringBundler query = null;
7448
7449 if (orderByComparator != null) {
7450 query = new StringBundler(5 +
7451 (orderByComparator.getOrderByFields().length * 3));
7452 }
7453 else {
7454 query = new StringBundler(5);
7455 }
7456
7457 if (getDB().isSupportsInlineDistinct()) {
7458 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
7459 }
7460 else {
7461 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
7462 }
7463
7464 query.append(_FINDER_COLUMN_G_NOTC_S_GROUPID_2);
7465
7466 query.append(_FINDER_COLUMN_G_NOTC_S_CATEGORYID_2);
7467
7468 query.append(_FINDER_COLUMN_G_NOTC_S_STATUS_2);
7469
7470 if (!getDB().isSupportsInlineDistinct()) {
7471 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
7472 }
7473
7474 if (orderByComparator != null) {
7475 if (getDB().isSupportsInlineDistinct()) {
7476 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7477 orderByComparator);
7478 }
7479 else {
7480 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7481 orderByComparator);
7482 }
7483 }
7484
7485 else {
7486 if (getDB().isSupportsInlineDistinct()) {
7487 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
7488 }
7489 else {
7490 query.append(MBThreadModelImpl.ORDER_BY_SQL);
7491 }
7492 }
7493
7494 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7495 MBThread.class.getName(),
7496 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7497
7498 Session session = null;
7499
7500 try {
7501 session = openSession();
7502
7503 SQLQuery q = session.createSQLQuery(sql);
7504
7505 if (getDB().isSupportsInlineDistinct()) {
7506 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
7507 }
7508 else {
7509 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
7510 }
7511
7512 QueryPos qPos = QueryPos.getInstance(q);
7513
7514 qPos.add(groupId);
7515
7516 qPos.add(categoryId);
7517
7518 qPos.add(status);
7519
7520 return (List<MBThread>)QueryUtil.list(q, getDialect(), start, end);
7521 }
7522 catch (Exception e) {
7523 throw processException(e);
7524 }
7525 finally {
7526 closeSession(session);
7527 }
7528 }
7529
7530
7542 public MBThread[] filterFindByG_NotC_S_PrevAndNext(long threadId,
7543 long groupId, long categoryId, int status,
7544 OrderByComparator orderByComparator)
7545 throws NoSuchThreadException, SystemException {
7546 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7547 return findByG_NotC_S_PrevAndNext(threadId, groupId, categoryId,
7548 status, orderByComparator);
7549 }
7550
7551 MBThread mbThread = findByPrimaryKey(threadId);
7552
7553 Session session = null;
7554
7555 try {
7556 session = openSession();
7557
7558 MBThread[] array = new MBThreadImpl[3];
7559
7560 array[0] = filterGetByG_NotC_S_PrevAndNext(session, mbThread,
7561 groupId, categoryId, status, orderByComparator, true);
7562
7563 array[1] = mbThread;
7564
7565 array[2] = filterGetByG_NotC_S_PrevAndNext(session, mbThread,
7566 groupId, categoryId, status, orderByComparator, false);
7567
7568 return array;
7569 }
7570 catch (Exception e) {
7571 throw processException(e);
7572 }
7573 finally {
7574 closeSession(session);
7575 }
7576 }
7577
7578 protected MBThread filterGetByG_NotC_S_PrevAndNext(Session session,
7579 MBThread mbThread, long groupId, long categoryId, int status,
7580 OrderByComparator orderByComparator, boolean previous) {
7581 StringBundler query = null;
7582
7583 if (orderByComparator != null) {
7584 query = new StringBundler(6 +
7585 (orderByComparator.getOrderByFields().length * 6));
7586 }
7587 else {
7588 query = new StringBundler(3);
7589 }
7590
7591 if (getDB().isSupportsInlineDistinct()) {
7592 query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE);
7593 }
7594 else {
7595 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1);
7596 }
7597
7598 query.append(_FINDER_COLUMN_G_NOTC_S_GROUPID_2);
7599
7600 query.append(_FINDER_COLUMN_G_NOTC_S_CATEGORYID_2);
7601
7602 query.append(_FINDER_COLUMN_G_NOTC_S_STATUS_2);
7603
7604 if (!getDB().isSupportsInlineDistinct()) {
7605 query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2);
7606 }
7607
7608 if (orderByComparator != null) {
7609 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7610
7611 if (orderByConditionFields.length > 0) {
7612 query.append(WHERE_AND);
7613 }
7614
7615 for (int i = 0; i < orderByConditionFields.length; i++) {
7616 if (getDB().isSupportsInlineDistinct()) {
7617 query.append(_ORDER_BY_ENTITY_ALIAS);
7618 }
7619 else {
7620 query.append(_ORDER_BY_ENTITY_TABLE);
7621 }
7622
7623 query.append(orderByConditionFields[i]);
7624
7625 if ((i + 1) < orderByConditionFields.length) {
7626 if (orderByComparator.isAscending() ^ previous) {
7627 query.append(WHERE_GREATER_THAN_HAS_NEXT);
7628 }
7629 else {
7630 query.append(WHERE_LESSER_THAN_HAS_NEXT);
7631 }
7632 }
7633 else {
7634 if (orderByComparator.isAscending() ^ previous) {
7635 query.append(WHERE_GREATER_THAN);
7636 }
7637 else {
7638 query.append(WHERE_LESSER_THAN);
7639 }
7640 }
7641 }
7642
7643 query.append(ORDER_BY_CLAUSE);
7644
7645 String[] orderByFields = orderByComparator.getOrderByFields();
7646
7647 for (int i = 0; i < orderByFields.length; i++) {
7648 if (getDB().isSupportsInlineDistinct()) {
7649 query.append(_ORDER_BY_ENTITY_ALIAS);
7650 }
7651 else {
7652 query.append(_ORDER_BY_ENTITY_TABLE);
7653 }
7654
7655 query.append(orderByFields[i]);
7656
7657 if ((i + 1) < orderByFields.length) {
7658 if (orderByComparator.isAscending() ^ previous) {
7659 query.append(ORDER_BY_ASC_HAS_NEXT);
7660 }
7661 else {
7662 query.append(ORDER_BY_DESC_HAS_NEXT);
7663 }
7664 }
7665 else {
7666 if (orderByComparator.isAscending() ^ previous) {
7667 query.append(ORDER_BY_ASC);
7668 }
7669 else {
7670 query.append(ORDER_BY_DESC);
7671 }
7672 }
7673 }
7674 }
7675
7676 else {
7677 if (getDB().isSupportsInlineDistinct()) {
7678 query.append(MBThreadModelImpl.ORDER_BY_JPQL);
7679 }
7680 else {
7681 query.append(MBThreadModelImpl.ORDER_BY_SQL);
7682 }
7683 }
7684
7685 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7686 MBThread.class.getName(),
7687 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7688
7689 SQLQuery q = session.createSQLQuery(sql);
7690
7691 q.setFirstResult(0);
7692 q.setMaxResults(2);
7693
7694 if (getDB().isSupportsInlineDistinct()) {
7695 q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class);
7696 }
7697 else {
7698 q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class);
7699 }
7700
7701 QueryPos qPos = QueryPos.getInstance(q);
7702
7703 qPos.add(groupId);
7704
7705 qPos.add(categoryId);
7706
7707 qPos.add(status);
7708
7709 if (orderByComparator != null) {
7710 Object[] values = orderByComparator.getOrderByConditionValues(mbThread);
7711
7712 for (Object value : values) {
7713 qPos.add(value);
7714 }
7715 }
7716
7717 List<MBThread> list = q.list();
7718
7719 if (list.size() == 2) {
7720 return list.get(1);
7721 }
7722 else {
7723 return null;
7724 }
7725 }
7726
7727
7733 public List<MBThread> findAll() throws SystemException {
7734 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7735 }
7736
7737
7749 public List<MBThread> findAll(int start, int end) throws SystemException {
7750 return findAll(start, end, null);
7751 }
7752
7753
7766 public List<MBThread> findAll(int start, int end,
7767 OrderByComparator orderByComparator) throws SystemException {
7768 FinderPath finderPath = null;
7769 Object[] finderArgs = new Object[] { start, end, orderByComparator };
7770
7771 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7772 (orderByComparator == null)) {
7773 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
7774 finderArgs = FINDER_ARGS_EMPTY;
7775 }
7776 else {
7777 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
7778 finderArgs = new Object[] { start, end, orderByComparator };
7779 }
7780
7781 List<MBThread> list = (List<MBThread>)FinderCacheUtil.getResult(finderPath,
7782 finderArgs, this);
7783
7784 if (list == null) {
7785 StringBundler query = null;
7786 String sql = null;
7787
7788 if (orderByComparator != null) {
7789 query = new StringBundler(2 +
7790 (orderByComparator.getOrderByFields().length * 3));
7791
7792 query.append(_SQL_SELECT_MBTHREAD);
7793
7794 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7795 orderByComparator);
7796
7797 sql = query.toString();
7798 }
7799 else {
7800 sql = _SQL_SELECT_MBTHREAD.concat(MBThreadModelImpl.ORDER_BY_JPQL);
7801 }
7802
7803 Session session = null;
7804
7805 try {
7806 session = openSession();
7807
7808 Query q = session.createQuery(sql);
7809
7810 if (orderByComparator == null) {
7811 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
7812 start, end, false);
7813
7814 Collections.sort(list);
7815 }
7816 else {
7817 list = (List<MBThread>)QueryUtil.list(q, getDialect(),
7818 start, end);
7819 }
7820 }
7821 catch (Exception e) {
7822 throw processException(e);
7823 }
7824 finally {
7825 if (list == null) {
7826 FinderCacheUtil.removeResult(finderPath, finderArgs);
7827 }
7828 else {
7829 cacheResult(list);
7830
7831 FinderCacheUtil.putResult(finderPath, finderArgs, list);
7832 }
7833
7834 closeSession(session);
7835 }
7836 }
7837
7838 return list;
7839 }
7840
7841
7847 public void removeByGroupId(long groupId) throws SystemException {
7848 for (MBThread mbThread : findByGroupId(groupId)) {
7849 remove(mbThread);
7850 }
7851 }
7852
7853
7860 public MBThread removeByRootMessageId(long rootMessageId)
7861 throws NoSuchThreadException, SystemException {
7862 MBThread mbThread = findByRootMessageId(rootMessageId);
7863
7864 return remove(mbThread);
7865 }
7866
7867
7874 public void removeByG_C(long groupId, long categoryId)
7875 throws SystemException {
7876 for (MBThread mbThread : findByG_C(groupId, categoryId)) {
7877 remove(mbThread);
7878 }
7879 }
7880
7881
7888 public void removeByG_NotC(long groupId, long categoryId)
7889 throws SystemException {
7890 for (MBThread mbThread : findByG_NotC(groupId, categoryId)) {
7891 remove(mbThread);
7892 }
7893 }
7894
7895
7902 public void removeByG_S(long groupId, int status) throws SystemException {
7903 for (MBThread mbThread : findByG_S(groupId, status)) {
7904 remove(mbThread);
7905 }
7906 }
7907
7908
7915 public void removeByC_P(long categoryId, double priority)
7916 throws SystemException {
7917 for (MBThread mbThread : findByC_P(categoryId, priority)) {
7918 remove(mbThread);
7919 }
7920 }
7921
7922
7929 public void removeByL_P(Date lastPostDate, double priority)
7930 throws SystemException {
7931 for (MBThread mbThread : findByL_P(lastPostDate, priority)) {
7932 remove(mbThread);
7933 }
7934 }
7935
7936
7944 public void removeByG_C_L(long groupId, long categoryId, Date lastPostDate)
7945 throws SystemException {
7946 for (MBThread mbThread : findByG_C_L(groupId, categoryId, lastPostDate)) {
7947 remove(mbThread);
7948 }
7949 }
7950
7951
7959 public void removeByG_C_S(long groupId, long categoryId, int status)
7960 throws SystemException {
7961 for (MBThread mbThread : findByG_C_S(groupId, categoryId, status)) {
7962 remove(mbThread);
7963 }
7964 }
7965
7966
7974 public void removeByG_NotC_S(long groupId, long categoryId, int status)
7975 throws SystemException {
7976 for (MBThread mbThread : findByG_NotC_S(groupId, categoryId, status)) {
7977 remove(mbThread);
7978 }
7979 }
7980
7981
7986 public void removeAll() throws SystemException {
7987 for (MBThread mbThread : findAll()) {
7988 remove(mbThread);
7989 }
7990 }
7991
7992
7999 public int countByGroupId(long groupId) throws SystemException {
8000 Object[] finderArgs = new Object[] { groupId };
8001
8002 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
8003 finderArgs, this);
8004
8005 if (count == null) {
8006 StringBundler query = new StringBundler(2);
8007
8008 query.append(_SQL_COUNT_MBTHREAD_WHERE);
8009
8010 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
8011
8012 String sql = query.toString();
8013
8014 Session session = null;
8015
8016 try {
8017 session = openSession();
8018
8019 Query q = session.createQuery(sql);
8020
8021 QueryPos qPos = QueryPos.getInstance(q);
8022
8023 qPos.add(groupId);
8024
8025 count = (Long)q.uniqueResult();
8026 }
8027 catch (Exception e) {
8028 throw processException(e);
8029 }
8030 finally {
8031 if (count == null) {
8032 count = Long.valueOf(0);
8033 }
8034
8035 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
8036 finderArgs, count);
8037
8038 closeSession(session);
8039 }
8040 }
8041
8042 return count.intValue();
8043 }
8044
8045
8052 public int filterCountByGroupId(long groupId) throws SystemException {
8053 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8054 return countByGroupId(groupId);
8055 }
8056
8057 StringBundler query = new StringBundler(2);
8058
8059 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
8060
8061 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
8062
8063 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8064 MBThread.class.getName(),
8065 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8066
8067 Session session = null;
8068
8069 try {
8070 session = openSession();
8071
8072 SQLQuery q = session.createSQLQuery(sql);
8073
8074 q.addScalar(COUNT_COLUMN_NAME,
8075 com.liferay.portal.kernel.dao.orm.Type.LONG);
8076
8077 QueryPos qPos = QueryPos.getInstance(q);
8078
8079 qPos.add(groupId);
8080
8081 Long count = (Long)q.uniqueResult();
8082
8083 return count.intValue();
8084 }
8085 catch (Exception e) {
8086 throw processException(e);
8087 }
8088 finally {
8089 closeSession(session);
8090 }
8091 }
8092
8093
8100 public int countByRootMessageId(long rootMessageId)
8101 throws SystemException {
8102 Object[] finderArgs = new Object[] { rootMessageId };
8103
8104 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ROOTMESSAGEID,
8105 finderArgs, this);
8106
8107 if (count == null) {
8108 StringBundler query = new StringBundler(2);
8109
8110 query.append(_SQL_COUNT_MBTHREAD_WHERE);
8111
8112 query.append(_FINDER_COLUMN_ROOTMESSAGEID_ROOTMESSAGEID_2);
8113
8114 String sql = query.toString();
8115
8116 Session session = null;
8117
8118 try {
8119 session = openSession();
8120
8121 Query q = session.createQuery(sql);
8122
8123 QueryPos qPos = QueryPos.getInstance(q);
8124
8125 qPos.add(rootMessageId);
8126
8127 count = (Long)q.uniqueResult();
8128 }
8129 catch (Exception e) {
8130 throw processException(e);
8131 }
8132 finally {
8133 if (count == null) {
8134 count = Long.valueOf(0);
8135 }
8136
8137 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ROOTMESSAGEID,
8138 finderArgs, count);
8139
8140 closeSession(session);
8141 }
8142 }
8143
8144 return count.intValue();
8145 }
8146
8147
8155 public int countByG_C(long groupId, long categoryId)
8156 throws SystemException {
8157 Object[] finderArgs = new Object[] { groupId, categoryId };
8158
8159 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C,
8160 finderArgs, this);
8161
8162 if (count == null) {
8163 StringBundler query = new StringBundler(3);
8164
8165 query.append(_SQL_COUNT_MBTHREAD_WHERE);
8166
8167 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
8168
8169 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
8170
8171 String sql = query.toString();
8172
8173 Session session = null;
8174
8175 try {
8176 session = openSession();
8177
8178 Query q = session.createQuery(sql);
8179
8180 QueryPos qPos = QueryPos.getInstance(q);
8181
8182 qPos.add(groupId);
8183
8184 qPos.add(categoryId);
8185
8186 count = (Long)q.uniqueResult();
8187 }
8188 catch (Exception e) {
8189 throw processException(e);
8190 }
8191 finally {
8192 if (count == null) {
8193 count = Long.valueOf(0);
8194 }
8195
8196 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C, finderArgs,
8197 count);
8198
8199 closeSession(session);
8200 }
8201 }
8202
8203 return count.intValue();
8204 }
8205
8206
8214 public int countByG_C(long groupId, long[] categoryIds)
8215 throws SystemException {
8216 Object[] finderArgs = new Object[] {
8217 groupId, StringUtil.merge(categoryIds)
8218 };
8219
8220 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C,
8221 finderArgs, this);
8222
8223 if (count == null) {
8224 StringBundler query = new StringBundler();
8225
8226 query.append(_SQL_COUNT_MBTHREAD_WHERE);
8227
8228 boolean conjunctionable = false;
8229
8230 if (conjunctionable) {
8231 query.append(WHERE_AND);
8232 }
8233
8234 query.append(_FINDER_COLUMN_G_C_GROUPID_5);
8235
8236 conjunctionable = true;
8237
8238 if ((categoryIds == null) || (categoryIds.length > 0)) {
8239 if (conjunctionable) {
8240 query.append(WHERE_AND);
8241 }
8242
8243 query.append(StringPool.OPEN_PARENTHESIS);
8244
8245 for (int i = 0; i < categoryIds.length; i++) {
8246 query.append(_FINDER_COLUMN_G_C_CATEGORYID_5);
8247
8248 if ((i + 1) < categoryIds.length) {
8249 query.append(WHERE_OR);
8250 }
8251 }
8252
8253 query.append(StringPool.CLOSE_PARENTHESIS);
8254
8255 conjunctionable = true;
8256 }
8257
8258 String sql = query.toString();
8259
8260 Session session = null;
8261
8262 try {
8263 session = openSession();
8264
8265 Query q = session.createQuery(sql);
8266
8267 QueryPos qPos = QueryPos.getInstance(q);
8268
8269 qPos.add(groupId);
8270
8271 if (categoryIds != null) {
8272 qPos.add(categoryIds);
8273 }
8274
8275 count = (Long)q.uniqueResult();
8276 }
8277 catch (Exception e) {
8278 throw processException(e);
8279 }
8280 finally {
8281 if (count == null) {
8282 count = Long.valueOf(0);
8283 }
8284
8285 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C,
8286 finderArgs, count);
8287
8288 closeSession(session);
8289 }
8290 }
8291
8292 return count.intValue();
8293 }
8294
8295
8303 public int filterCountByG_C(long groupId, long categoryId)
8304 throws SystemException {
8305 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8306 return countByG_C(groupId, categoryId);
8307 }
8308
8309 StringBundler query = new StringBundler(3);
8310
8311 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
8312
8313 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
8314
8315 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
8316
8317 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8318 MBThread.class.getName(),
8319 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8320
8321 Session session = null;
8322
8323 try {
8324 session = openSession();
8325
8326 SQLQuery q = session.createSQLQuery(sql);
8327
8328 q.addScalar(COUNT_COLUMN_NAME,
8329 com.liferay.portal.kernel.dao.orm.Type.LONG);
8330
8331 QueryPos qPos = QueryPos.getInstance(q);
8332
8333 qPos.add(groupId);
8334
8335 qPos.add(categoryId);
8336
8337 Long count = (Long)q.uniqueResult();
8338
8339 return count.intValue();
8340 }
8341 catch (Exception e) {
8342 throw processException(e);
8343 }
8344 finally {
8345 closeSession(session);
8346 }
8347 }
8348
8349
8357 public int filterCountByG_C(long groupId, long[] categoryIds)
8358 throws SystemException {
8359 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8360 return countByG_C(groupId, categoryIds);
8361 }
8362
8363 StringBundler query = new StringBundler();
8364
8365 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
8366
8367 boolean conjunctionable = false;
8368
8369 if (conjunctionable) {
8370 query.append(WHERE_AND);
8371 }
8372
8373 query.append(_FINDER_COLUMN_G_C_GROUPID_5);
8374
8375 conjunctionable = true;
8376
8377 if ((categoryIds == null) || (categoryIds.length > 0)) {
8378 if (conjunctionable) {
8379 query.append(WHERE_AND);
8380 }
8381
8382 query.append(StringPool.OPEN_PARENTHESIS);
8383
8384 for (int i = 0; i < categoryIds.length; i++) {
8385 query.append(_FINDER_COLUMN_G_C_CATEGORYID_5);
8386
8387 if ((i + 1) < categoryIds.length) {
8388 query.append(WHERE_OR);
8389 }
8390 }
8391
8392 query.append(StringPool.CLOSE_PARENTHESIS);
8393
8394 conjunctionable = true;
8395 }
8396
8397 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8398 MBThread.class.getName(),
8399 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8400
8401 Session session = null;
8402
8403 try {
8404 session = openSession();
8405
8406 SQLQuery q = session.createSQLQuery(sql);
8407
8408 q.addScalar(COUNT_COLUMN_NAME,
8409 com.liferay.portal.kernel.dao.orm.Type.LONG);
8410
8411 QueryPos qPos = QueryPos.getInstance(q);
8412
8413 qPos.add(groupId);
8414
8415 if (categoryIds != null) {
8416 qPos.add(categoryIds);
8417 }
8418
8419 Long count = (Long)q.uniqueResult();
8420
8421 return count.intValue();
8422 }
8423 catch (Exception e) {
8424 throw processException(e);
8425 }
8426 finally {
8427 closeSession(session);
8428 }
8429 }
8430
8431
8439 public int countByG_NotC(long groupId, long categoryId)
8440 throws SystemException {
8441 Object[] finderArgs = new Object[] { groupId, categoryId };
8442
8443 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTC,
8444 finderArgs, this);
8445
8446 if (count == null) {
8447 StringBundler query = new StringBundler(3);
8448
8449 query.append(_SQL_COUNT_MBTHREAD_WHERE);
8450
8451 query.append(_FINDER_COLUMN_G_NOTC_GROUPID_2);
8452
8453 query.append(_FINDER_COLUMN_G_NOTC_CATEGORYID_2);
8454
8455 String sql = query.toString();
8456
8457 Session session = null;
8458
8459 try {
8460 session = openSession();
8461
8462 Query q = session.createQuery(sql);
8463
8464 QueryPos qPos = QueryPos.getInstance(q);
8465
8466 qPos.add(groupId);
8467
8468 qPos.add(categoryId);
8469
8470 count = (Long)q.uniqueResult();
8471 }
8472 catch (Exception e) {
8473 throw processException(e);
8474 }
8475 finally {
8476 if (count == null) {
8477 count = Long.valueOf(0);
8478 }
8479
8480 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTC,
8481 finderArgs, count);
8482
8483 closeSession(session);
8484 }
8485 }
8486
8487 return count.intValue();
8488 }
8489
8490
8498 public int filterCountByG_NotC(long groupId, long categoryId)
8499 throws SystemException {
8500 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8501 return countByG_NotC(groupId, categoryId);
8502 }
8503
8504 StringBundler query = new StringBundler(3);
8505
8506 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
8507
8508 query.append(_FINDER_COLUMN_G_NOTC_GROUPID_2);
8509
8510 query.append(_FINDER_COLUMN_G_NOTC_CATEGORYID_2);
8511
8512 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8513 MBThread.class.getName(),
8514 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8515
8516 Session session = null;
8517
8518 try {
8519 session = openSession();
8520
8521 SQLQuery q = session.createSQLQuery(sql);
8522
8523 q.addScalar(COUNT_COLUMN_NAME,
8524 com.liferay.portal.kernel.dao.orm.Type.LONG);
8525
8526 QueryPos qPos = QueryPos.getInstance(q);
8527
8528 qPos.add(groupId);
8529
8530 qPos.add(categoryId);
8531
8532 Long count = (Long)q.uniqueResult();
8533
8534 return count.intValue();
8535 }
8536 catch (Exception e) {
8537 throw processException(e);
8538 }
8539 finally {
8540 closeSession(session);
8541 }
8542 }
8543
8544
8552 public int countByG_S(long groupId, int status) throws SystemException {
8553 Object[] finderArgs = new Object[] { groupId, status };
8554
8555 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_S,
8556 finderArgs, this);
8557
8558 if (count == null) {
8559 StringBundler query = new StringBundler(3);
8560
8561 query.append(_SQL_COUNT_MBTHREAD_WHERE);
8562
8563 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
8564
8565 query.append(_FINDER_COLUMN_G_S_STATUS_2);
8566
8567 String sql = query.toString();
8568
8569 Session session = null;
8570
8571 try {
8572 session = openSession();
8573
8574 Query q = session.createQuery(sql);
8575
8576 QueryPos qPos = QueryPos.getInstance(q);
8577
8578 qPos.add(groupId);
8579
8580 qPos.add(status);
8581
8582 count = (Long)q.uniqueResult();
8583 }
8584 catch (Exception e) {
8585 throw processException(e);
8586 }
8587 finally {
8588 if (count == null) {
8589 count = Long.valueOf(0);
8590 }
8591
8592 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_S, finderArgs,
8593 count);
8594
8595 closeSession(session);
8596 }
8597 }
8598
8599 return count.intValue();
8600 }
8601
8602
8610 public int filterCountByG_S(long groupId, int status)
8611 throws SystemException {
8612 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8613 return countByG_S(groupId, status);
8614 }
8615
8616 StringBundler query = new StringBundler(3);
8617
8618 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
8619
8620 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
8621
8622 query.append(_FINDER_COLUMN_G_S_STATUS_2);
8623
8624 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8625 MBThread.class.getName(),
8626 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8627
8628 Session session = null;
8629
8630 try {
8631 session = openSession();
8632
8633 SQLQuery q = session.createSQLQuery(sql);
8634
8635 q.addScalar(COUNT_COLUMN_NAME,
8636 com.liferay.portal.kernel.dao.orm.Type.LONG);
8637
8638 QueryPos qPos = QueryPos.getInstance(q);
8639
8640 qPos.add(groupId);
8641
8642 qPos.add(status);
8643
8644 Long count = (Long)q.uniqueResult();
8645
8646 return count.intValue();
8647 }
8648 catch (Exception e) {
8649 throw processException(e);
8650 }
8651 finally {
8652 closeSession(session);
8653 }
8654 }
8655
8656
8664 public int countByC_P(long categoryId, double priority)
8665 throws SystemException {
8666 Object[] finderArgs = new Object[] { categoryId, priority };
8667
8668 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_P,
8669 finderArgs, this);
8670
8671 if (count == null) {
8672 StringBundler query = new StringBundler(3);
8673
8674 query.append(_SQL_COUNT_MBTHREAD_WHERE);
8675
8676 query.append(_FINDER_COLUMN_C_P_CATEGORYID_2);
8677
8678 query.append(_FINDER_COLUMN_C_P_PRIORITY_2);
8679
8680 String sql = query.toString();
8681
8682 Session session = null;
8683
8684 try {
8685 session = openSession();
8686
8687 Query q = session.createQuery(sql);
8688
8689 QueryPos qPos = QueryPos.getInstance(q);
8690
8691 qPos.add(categoryId);
8692
8693 qPos.add(priority);
8694
8695 count = (Long)q.uniqueResult();
8696 }
8697 catch (Exception e) {
8698 throw processException(e);
8699 }
8700 finally {
8701 if (count == null) {
8702 count = Long.valueOf(0);
8703 }
8704
8705 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_P, finderArgs,
8706 count);
8707
8708 closeSession(session);
8709 }
8710 }
8711
8712 return count.intValue();
8713 }
8714
8715
8723 public int countByL_P(Date lastPostDate, double priority)
8724 throws SystemException {
8725 Object[] finderArgs = new Object[] { lastPostDate, priority };
8726
8727 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_L_P,
8728 finderArgs, this);
8729
8730 if (count == null) {
8731 StringBundler query = new StringBundler(3);
8732
8733 query.append(_SQL_COUNT_MBTHREAD_WHERE);
8734
8735 if (lastPostDate == null) {
8736 query.append(_FINDER_COLUMN_L_P_LASTPOSTDATE_1);
8737 }
8738 else {
8739 query.append(_FINDER_COLUMN_L_P_LASTPOSTDATE_2);
8740 }
8741
8742 query.append(_FINDER_COLUMN_L_P_PRIORITY_2);
8743
8744 String sql = query.toString();
8745
8746 Session session = null;
8747
8748 try {
8749 session = openSession();
8750
8751 Query q = session.createQuery(sql);
8752
8753 QueryPos qPos = QueryPos.getInstance(q);
8754
8755 if (lastPostDate != null) {
8756 qPos.add(CalendarUtil.getTimestamp(lastPostDate));
8757 }
8758
8759 qPos.add(priority);
8760
8761 count = (Long)q.uniqueResult();
8762 }
8763 catch (Exception e) {
8764 throw processException(e);
8765 }
8766 finally {
8767 if (count == null) {
8768 count = Long.valueOf(0);
8769 }
8770
8771 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_L_P, finderArgs,
8772 count);
8773
8774 closeSession(session);
8775 }
8776 }
8777
8778 return count.intValue();
8779 }
8780
8781
8790 public int countByG_C_L(long groupId, long categoryId, Date lastPostDate)
8791 throws SystemException {
8792 Object[] finderArgs = new Object[] { groupId, categoryId, lastPostDate };
8793
8794 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_L,
8795 finderArgs, this);
8796
8797 if (count == null) {
8798 StringBundler query = new StringBundler(4);
8799
8800 query.append(_SQL_COUNT_MBTHREAD_WHERE);
8801
8802 query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
8803
8804 query.append(_FINDER_COLUMN_G_C_L_CATEGORYID_2);
8805
8806 if (lastPostDate == null) {
8807 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1);
8808 }
8809 else {
8810 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_2);
8811 }
8812
8813 String sql = query.toString();
8814
8815 Session session = null;
8816
8817 try {
8818 session = openSession();
8819
8820 Query q = session.createQuery(sql);
8821
8822 QueryPos qPos = QueryPos.getInstance(q);
8823
8824 qPos.add(groupId);
8825
8826 qPos.add(categoryId);
8827
8828 if (lastPostDate != null) {
8829 qPos.add(CalendarUtil.getTimestamp(lastPostDate));
8830 }
8831
8832 count = (Long)q.uniqueResult();
8833 }
8834 catch (Exception e) {
8835 throw processException(e);
8836 }
8837 finally {
8838 if (count == null) {
8839 count = Long.valueOf(0);
8840 }
8841
8842 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_L,
8843 finderArgs, count);
8844
8845 closeSession(session);
8846 }
8847 }
8848
8849 return count.intValue();
8850 }
8851
8852
8861 public int filterCountByG_C_L(long groupId, long categoryId,
8862 Date lastPostDate) throws SystemException {
8863 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8864 return countByG_C_L(groupId, categoryId, lastPostDate);
8865 }
8866
8867 StringBundler query = new StringBundler(4);
8868
8869 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
8870
8871 query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
8872
8873 query.append(_FINDER_COLUMN_G_C_L_CATEGORYID_2);
8874
8875 if (lastPostDate == null) {
8876 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_1);
8877 }
8878 else {
8879 query.append(_FINDER_COLUMN_G_C_L_LASTPOSTDATE_2);
8880 }
8881
8882 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8883 MBThread.class.getName(),
8884 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8885
8886 Session session = null;
8887
8888 try {
8889 session = openSession();
8890
8891 SQLQuery q = session.createSQLQuery(sql);
8892
8893 q.addScalar(COUNT_COLUMN_NAME,
8894 com.liferay.portal.kernel.dao.orm.Type.LONG);
8895
8896 QueryPos qPos = QueryPos.getInstance(q);
8897
8898 qPos.add(groupId);
8899
8900 qPos.add(categoryId);
8901
8902 if (lastPostDate != null) {
8903 qPos.add(CalendarUtil.getTimestamp(lastPostDate));
8904 }
8905
8906 Long count = (Long)q.uniqueResult();
8907
8908 return count.intValue();
8909 }
8910 catch (Exception e) {
8911 throw processException(e);
8912 }
8913 finally {
8914 closeSession(session);
8915 }
8916 }
8917
8918
8927 public int countByG_C_S(long groupId, long categoryId, int status)
8928 throws SystemException {
8929 Object[] finderArgs = new Object[] { groupId, categoryId, status };
8930
8931 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_S,
8932 finderArgs, this);
8933
8934 if (count == null) {
8935 StringBundler query = new StringBundler(4);
8936
8937 query.append(_SQL_COUNT_MBTHREAD_WHERE);
8938
8939 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
8940
8941 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
8942
8943 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
8944
8945 String sql = query.toString();
8946
8947 Session session = null;
8948
8949 try {
8950 session = openSession();
8951
8952 Query q = session.createQuery(sql);
8953
8954 QueryPos qPos = QueryPos.getInstance(q);
8955
8956 qPos.add(groupId);
8957
8958 qPos.add(categoryId);
8959
8960 qPos.add(status);
8961
8962 count = (Long)q.uniqueResult();
8963 }
8964 catch (Exception e) {
8965 throw processException(e);
8966 }
8967 finally {
8968 if (count == null) {
8969 count = Long.valueOf(0);
8970 }
8971
8972 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S,
8973 finderArgs, count);
8974
8975 closeSession(session);
8976 }
8977 }
8978
8979 return count.intValue();
8980 }
8981
8982
8991 public int countByG_C_S(long groupId, long[] categoryIds, int status)
8992 throws SystemException {
8993 Object[] finderArgs = new Object[] {
8994 groupId, StringUtil.merge(categoryIds), status
8995 };
8996
8997 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C_S,
8998 finderArgs, this);
8999
9000 if (count == null) {
9001 StringBundler query = new StringBundler();
9002
9003 query.append(_SQL_COUNT_MBTHREAD_WHERE);
9004
9005 boolean conjunctionable = false;
9006
9007 if (conjunctionable) {
9008 query.append(WHERE_AND);
9009 }
9010
9011 query.append(_FINDER_COLUMN_G_C_S_GROUPID_5);
9012
9013 conjunctionable = true;
9014
9015 if ((categoryIds == null) || (categoryIds.length > 0)) {
9016 if (conjunctionable) {
9017 query.append(WHERE_AND);
9018 }
9019
9020 query.append(StringPool.OPEN_PARENTHESIS);
9021
9022 for (int i = 0; i < categoryIds.length; i++) {
9023 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_5);
9024
9025 if ((i + 1) < categoryIds.length) {
9026 query.append(WHERE_OR);
9027 }
9028 }
9029
9030 query.append(StringPool.CLOSE_PARENTHESIS);
9031
9032 conjunctionable = true;
9033 }
9034
9035 if (conjunctionable) {
9036 query.append(WHERE_AND);
9037 }
9038
9039 query.append(_FINDER_COLUMN_G_C_S_STATUS_5);
9040
9041 conjunctionable = true;
9042
9043 String sql = query.toString();
9044
9045 Session session = null;
9046
9047 try {
9048 session = openSession();
9049
9050 Query q = session.createQuery(sql);
9051
9052 QueryPos qPos = QueryPos.getInstance(q);
9053
9054 qPos.add(groupId);
9055
9056 if (categoryIds != null) {
9057 qPos.add(categoryIds);
9058 }
9059
9060 qPos.add(status);
9061
9062 count = (Long)q.uniqueResult();
9063 }
9064 catch (Exception e) {
9065 throw processException(e);
9066 }
9067 finally {
9068 if (count == null) {
9069 count = Long.valueOf(0);
9070 }
9071
9072 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_C_S,
9073 finderArgs, count);
9074
9075 closeSession(session);
9076 }
9077 }
9078
9079 return count.intValue();
9080 }
9081
9082
9091 public int filterCountByG_C_S(long groupId, long categoryId, int status)
9092 throws SystemException {
9093 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9094 return countByG_C_S(groupId, categoryId, status);
9095 }
9096
9097 StringBundler query = new StringBundler(4);
9098
9099 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
9100
9101 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
9102
9103 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
9104
9105 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
9106
9107 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9108 MBThread.class.getName(),
9109 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9110
9111 Session session = null;
9112
9113 try {
9114 session = openSession();
9115
9116 SQLQuery q = session.createSQLQuery(sql);
9117
9118 q.addScalar(COUNT_COLUMN_NAME,
9119 com.liferay.portal.kernel.dao.orm.Type.LONG);
9120
9121 QueryPos qPos = QueryPos.getInstance(q);
9122
9123 qPos.add(groupId);
9124
9125 qPos.add(categoryId);
9126
9127 qPos.add(status);
9128
9129 Long count = (Long)q.uniqueResult();
9130
9131 return count.intValue();
9132 }
9133 catch (Exception e) {
9134 throw processException(e);
9135 }
9136 finally {
9137 closeSession(session);
9138 }
9139 }
9140
9141
9150 public int filterCountByG_C_S(long groupId, long[] categoryIds, int status)
9151 throws SystemException {
9152 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9153 return countByG_C_S(groupId, categoryIds, status);
9154 }
9155
9156 StringBundler query = new StringBundler();
9157
9158 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
9159
9160 boolean conjunctionable = false;
9161
9162 if (conjunctionable) {
9163 query.append(WHERE_AND);
9164 }
9165
9166 query.append(_FINDER_COLUMN_G_C_S_GROUPID_5);
9167
9168 conjunctionable = true;
9169
9170 if ((categoryIds == null) || (categoryIds.length > 0)) {
9171 if (conjunctionable) {
9172 query.append(WHERE_AND);
9173 }
9174
9175 query.append(StringPool.OPEN_PARENTHESIS);
9176
9177 for (int i = 0; i < categoryIds.length; i++) {
9178 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_5);
9179
9180 if ((i + 1) < categoryIds.length) {
9181 query.append(WHERE_OR);
9182 }
9183 }
9184
9185 query.append(StringPool.CLOSE_PARENTHESIS);
9186
9187 conjunctionable = true;
9188 }
9189
9190 if (conjunctionable) {
9191 query.append(WHERE_AND);
9192 }
9193
9194 query.append(_FINDER_COLUMN_G_C_S_STATUS_5);
9195
9196 conjunctionable = true;
9197
9198 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9199 MBThread.class.getName(),
9200 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9201
9202 Session session = null;
9203
9204 try {
9205 session = openSession();
9206
9207 SQLQuery q = session.createSQLQuery(sql);
9208
9209 q.addScalar(COUNT_COLUMN_NAME,
9210 com.liferay.portal.kernel.dao.orm.Type.LONG);
9211
9212 QueryPos qPos = QueryPos.getInstance(q);
9213
9214 qPos.add(groupId);
9215
9216 if (categoryIds != null) {
9217 qPos.add(categoryIds);
9218 }
9219
9220 qPos.add(status);
9221
9222 Long count = (Long)q.uniqueResult();
9223
9224 return count.intValue();
9225 }
9226 catch (Exception e) {
9227 throw processException(e);
9228 }
9229 finally {
9230 closeSession(session);
9231 }
9232 }
9233
9234
9243 public int countByG_NotC_S(long groupId, long categoryId, int status)
9244 throws SystemException {
9245 Object[] finderArgs = new Object[] { groupId, categoryId, status };
9246
9247 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTC_S,
9248 finderArgs, this);
9249
9250 if (count == null) {
9251 StringBundler query = new StringBundler(4);
9252
9253 query.append(_SQL_COUNT_MBTHREAD_WHERE);
9254
9255 query.append(_FINDER_COLUMN_G_NOTC_S_GROUPID_2);
9256
9257 query.append(_FINDER_COLUMN_G_NOTC_S_CATEGORYID_2);
9258
9259 query.append(_FINDER_COLUMN_G_NOTC_S_STATUS_2);
9260
9261 String sql = query.toString();
9262
9263 Session session = null;
9264
9265 try {
9266 session = openSession();
9267
9268 Query q = session.createQuery(sql);
9269
9270 QueryPos qPos = QueryPos.getInstance(q);
9271
9272 qPos.add(groupId);
9273
9274 qPos.add(categoryId);
9275
9276 qPos.add(status);
9277
9278 count = (Long)q.uniqueResult();
9279 }
9280 catch (Exception e) {
9281 throw processException(e);
9282 }
9283 finally {
9284 if (count == null) {
9285 count = Long.valueOf(0);
9286 }
9287
9288 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTC_S,
9289 finderArgs, count);
9290
9291 closeSession(session);
9292 }
9293 }
9294
9295 return count.intValue();
9296 }
9297
9298
9307 public int filterCountByG_NotC_S(long groupId, long categoryId, int status)
9308 throws SystemException {
9309 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9310 return countByG_NotC_S(groupId, categoryId, status);
9311 }
9312
9313 StringBundler query = new StringBundler(4);
9314
9315 query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE);
9316
9317 query.append(_FINDER_COLUMN_G_NOTC_S_GROUPID_2);
9318
9319 query.append(_FINDER_COLUMN_G_NOTC_S_CATEGORYID_2);
9320
9321 query.append(_FINDER_COLUMN_G_NOTC_S_STATUS_2);
9322
9323 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9324 MBThread.class.getName(),
9325 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9326
9327 Session session = null;
9328
9329 try {
9330 session = openSession();
9331
9332 SQLQuery q = session.createSQLQuery(sql);
9333
9334 q.addScalar(COUNT_COLUMN_NAME,
9335 com.liferay.portal.kernel.dao.orm.Type.LONG);
9336
9337 QueryPos qPos = QueryPos.getInstance(q);
9338
9339 qPos.add(groupId);
9340
9341 qPos.add(categoryId);
9342
9343 qPos.add(status);
9344
9345 Long count = (Long)q.uniqueResult();
9346
9347 return count.intValue();
9348 }
9349 catch (Exception e) {
9350 throw processException(e);
9351 }
9352 finally {
9353 closeSession(session);
9354 }
9355 }
9356
9357
9363 public int countAll() throws SystemException {
9364 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
9365 FINDER_ARGS_EMPTY, this);
9366
9367 if (count == null) {
9368 Session session = null;
9369
9370 try {
9371 session = openSession();
9372
9373 Query q = session.createQuery(_SQL_COUNT_MBTHREAD);
9374
9375 count = (Long)q.uniqueResult();
9376 }
9377 catch (Exception e) {
9378 throw processException(e);
9379 }
9380 finally {
9381 if (count == null) {
9382 count = Long.valueOf(0);
9383 }
9384
9385 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
9386 FINDER_ARGS_EMPTY, count);
9387
9388 closeSession(session);
9389 }
9390 }
9391
9392 return count.intValue();
9393 }
9394
9395
9398 public void afterPropertiesSet() {
9399 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
9400 com.liferay.portal.util.PropsUtil.get(
9401 "value.object.listener.com.liferay.portlet.messageboards.model.MBThread")));
9402
9403 if (listenerClassNames.length > 0) {
9404 try {
9405 List<ModelListener<MBThread>> listenersList = new ArrayList<ModelListener<MBThread>>();
9406
9407 for (String listenerClassName : listenerClassNames) {
9408 Class<?> clazz = getClass();
9409
9410 listenersList.add((ModelListener<MBThread>)InstanceFactory.newInstance(
9411 clazz.getClassLoader(), listenerClassName));
9412 }
9413
9414 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
9415 }
9416 catch (Exception e) {
9417 _log.error(e);
9418 }
9419 }
9420 }
9421
9422 public void destroy() {
9423 EntityCacheUtil.removeCache(MBThreadImpl.class.getName());
9424 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
9425 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
9426 }
9427
9428 @BeanReference(type = MBBanPersistence.class)
9429 protected MBBanPersistence mbBanPersistence;
9430 @BeanReference(type = MBCategoryPersistence.class)
9431 protected MBCategoryPersistence mbCategoryPersistence;
9432 @BeanReference(type = MBDiscussionPersistence.class)
9433 protected MBDiscussionPersistence mbDiscussionPersistence;
9434 @BeanReference(type = MBMailingListPersistence.class)
9435 protected MBMailingListPersistence mbMailingListPersistence;
9436 @BeanReference(type = MBMessagePersistence.class)
9437 protected MBMessagePersistence mbMessagePersistence;
9438 @BeanReference(type = MBStatsUserPersistence.class)
9439 protected MBStatsUserPersistence mbStatsUserPersistence;
9440 @BeanReference(type = MBThreadPersistence.class)
9441 protected MBThreadPersistence mbThreadPersistence;
9442 @BeanReference(type = MBThreadFlagPersistence.class)
9443 protected MBThreadFlagPersistence mbThreadFlagPersistence;
9444 @BeanReference(type = LockPersistence.class)
9445 protected LockPersistence lockPersistence;
9446 @BeanReference(type = ResourcePersistence.class)
9447 protected ResourcePersistence resourcePersistence;
9448 @BeanReference(type = SubscriptionPersistence.class)
9449 protected SubscriptionPersistence subscriptionPersistence;
9450 @BeanReference(type = UserPersistence.class)
9451 protected UserPersistence userPersistence;
9452 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
9453 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
9454 @BeanReference(type = AssetEntryPersistence.class)
9455 protected AssetEntryPersistence assetEntryPersistence;
9456 @BeanReference(type = RatingsStatsPersistence.class)
9457 protected RatingsStatsPersistence ratingsStatsPersistence;
9458 @BeanReference(type = SocialActivityPersistence.class)
9459 protected SocialActivityPersistence socialActivityPersistence;
9460 private static final String _SQL_SELECT_MBTHREAD = "SELECT mbThread FROM MBThread mbThread";
9461 private static final String _SQL_SELECT_MBTHREAD_WHERE = "SELECT mbThread FROM MBThread mbThread WHERE ";
9462 private static final String _SQL_COUNT_MBTHREAD = "SELECT COUNT(mbThread) FROM MBThread mbThread";
9463 private static final String _SQL_COUNT_MBTHREAD_WHERE = "SELECT COUNT(mbThread) FROM MBThread mbThread WHERE ";
9464 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "mbThread.groupId = ? AND mbThread.categoryId != -1";
9465 private static final String _FINDER_COLUMN_ROOTMESSAGEID_ROOTMESSAGEID_2 = "mbThread.rootMessageId = ?";
9466 private static final String _FINDER_COLUMN_G_C_GROUPID_2 = "mbThread.groupId = ? AND ";
9467 private static final String _FINDER_COLUMN_G_C_GROUPID_5 = "(" +
9468 _removeConjunction(_FINDER_COLUMN_G_C_GROUPID_2) + ")";
9469 private static final String _FINDER_COLUMN_G_C_CATEGORYID_2 = "mbThread.categoryId = ?";
9470 private static final String _FINDER_COLUMN_G_C_CATEGORYID_5 = "(" +
9471 _removeConjunction(_FINDER_COLUMN_G_C_CATEGORYID_2) + ")";
9472 private static final String _FINDER_COLUMN_G_NOTC_GROUPID_2 = "mbThread.groupId = ? AND ";
9473 private static final String _FINDER_COLUMN_G_NOTC_CATEGORYID_2 = "mbThread.categoryId != ?";
9474 private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "mbThread.groupId = ? AND ";
9475 private static final String _FINDER_COLUMN_G_S_STATUS_2 = "mbThread.status = ? AND mbThread.categoryId != -1";
9476 private static final String _FINDER_COLUMN_C_P_CATEGORYID_2 = "mbThread.categoryId = ? AND ";
9477 private static final String _FINDER_COLUMN_C_P_PRIORITY_2 = "mbThread.priority = ?";
9478 private static final String _FINDER_COLUMN_L_P_LASTPOSTDATE_1 = "mbThread.lastPostDate IS NULL AND ";
9479 private static final String _FINDER_COLUMN_L_P_LASTPOSTDATE_2 = "mbThread.lastPostDate = ? AND ";
9480 private static final String _FINDER_COLUMN_L_P_PRIORITY_2 = "mbThread.priority = ? AND mbThread.categoryId != -1";
9481 private static final String _FINDER_COLUMN_G_C_L_GROUPID_2 = "mbThread.groupId = ? AND ";
9482 private static final String _FINDER_COLUMN_G_C_L_CATEGORYID_2 = "mbThread.categoryId = ? AND ";
9483 private static final String _FINDER_COLUMN_G_C_L_LASTPOSTDATE_1 = "mbThread.lastPostDate IS NULL";
9484 private static final String _FINDER_COLUMN_G_C_L_LASTPOSTDATE_2 = "mbThread.lastPostDate = ?";
9485 private static final String _FINDER_COLUMN_G_C_S_GROUPID_2 = "mbThread.groupId = ? AND ";
9486 private static final String _FINDER_COLUMN_G_C_S_GROUPID_5 = "(" +
9487 _removeConjunction(_FINDER_COLUMN_G_C_S_GROUPID_2) + ")";
9488 private static final String _FINDER_COLUMN_G_C_S_CATEGORYID_2 = "mbThread.categoryId = ? AND ";
9489 private static final String _FINDER_COLUMN_G_C_S_CATEGORYID_5 = "(" +
9490 _removeConjunction(_FINDER_COLUMN_G_C_S_CATEGORYID_2) + ")";
9491 private static final String _FINDER_COLUMN_G_C_S_STATUS_2 = "mbThread.status = ?";
9492 private static final String _FINDER_COLUMN_G_C_S_STATUS_5 = "(" +
9493 _removeConjunction(_FINDER_COLUMN_G_C_S_STATUS_2) + ")";
9494 private static final String _FINDER_COLUMN_G_NOTC_S_GROUPID_2 = "mbThread.groupId = ? AND ";
9495 private static final String _FINDER_COLUMN_G_NOTC_S_CATEGORYID_2 = "mbThread.categoryId != ? AND ";
9496 private static final String _FINDER_COLUMN_G_NOTC_S_STATUS_2 = "mbThread.status = ?";
9497
9498 private static String _removeConjunction(String sql) {
9499 int pos = sql.indexOf(" AND ");
9500
9501 if (pos != -1) {
9502 sql = sql.substring(0, pos);
9503 }
9504
9505 return sql;
9506 }
9507
9508 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "mbThread.threadId";
9509 private static final String _FILTER_SQL_SELECT_MBTHREAD_WHERE = "SELECT DISTINCT {mbThread.*} FROM MBThread mbThread WHERE ";
9510 private static final String _FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1 =
9511 "SELECT {MBThread.*} FROM (SELECT DISTINCT mbThread.threadId FROM MBThread mbThread WHERE ";
9512 private static final String _FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2 =
9513 ") TEMP_TABLE INNER JOIN MBThread ON TEMP_TABLE.threadId = MBThread.threadId";
9514 private static final String _FILTER_SQL_COUNT_MBTHREAD_WHERE = "SELECT COUNT(DISTINCT mbThread.threadId) AS COUNT_VALUE FROM MBThread mbThread WHERE ";
9515 private static final String _FILTER_ENTITY_ALIAS = "mbThread";
9516 private static final String _FILTER_ENTITY_TABLE = "MBThread";
9517 private static final String _ORDER_BY_ENTITY_ALIAS = "mbThread.";
9518 private static final String _ORDER_BY_ENTITY_TABLE = "MBThread.";
9519 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MBThread exists with the primary key ";
9520 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MBThread exists with the key {";
9521 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
9522 private static Log _log = LogFactoryUtil.getLog(MBThreadPersistenceImpl.class);
9523 private static MBThread _nullMBThread = new MBThreadImpl() {
9524 @Override
9525 public Object clone() {
9526 return this;
9527 }
9528
9529 @Override
9530 public CacheModel<MBThread> toCacheModel() {
9531 return _nullMBThreadCacheModel;
9532 }
9533 };
9534
9535 private static CacheModel<MBThread> _nullMBThreadCacheModel = new CacheModel<MBThread>() {
9536 public MBThread toEntityModel() {
9537 return _nullMBThread;
9538 }
9539 };
9540 }