1
14
15 package com.liferay.portlet.messageboards.service.persistence;
16
17 import com.liferay.portal.NoSuchModelException;
18 import com.liferay.portal.kernel.annotation.BeanReference;
19 import com.liferay.portal.kernel.cache.CacheRegistry;
20 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
21 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
22 import com.liferay.portal.kernel.dao.orm.FinderPath;
23 import com.liferay.portal.kernel.dao.orm.Query;
24 import com.liferay.portal.kernel.dao.orm.QueryPos;
25 import com.liferay.portal.kernel.dao.orm.QueryUtil;
26 import com.liferay.portal.kernel.dao.orm.SQLQuery;
27 import com.liferay.portal.kernel.dao.orm.Session;
28 import com.liferay.portal.kernel.dao.orm.Type;
29 import com.liferay.portal.kernel.exception.SystemException;
30 import com.liferay.portal.kernel.log.Log;
31 import com.liferay.portal.kernel.log.LogFactoryUtil;
32 import com.liferay.portal.kernel.util.GetterUtil;
33 import com.liferay.portal.kernel.util.InstanceFactory;
34 import com.liferay.portal.kernel.util.OrderByComparator;
35 import com.liferay.portal.kernel.util.StringBundler;
36 import com.liferay.portal.kernel.util.StringPool;
37 import com.liferay.portal.kernel.util.StringUtil;
38 import com.liferay.portal.kernel.util.Validator;
39 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
40 import com.liferay.portal.model.ModelListener;
41 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
42 import com.liferay.portal.service.persistence.BatchSessionUtil;
43 import com.liferay.portal.service.persistence.CompanyPersistence;
44 import com.liferay.portal.service.persistence.GroupPersistence;
45 import com.liferay.portal.service.persistence.LockPersistence;
46 import com.liferay.portal.service.persistence.PortletPreferencesPersistence;
47 import com.liferay.portal.service.persistence.ResourcePersistence;
48 import com.liferay.portal.service.persistence.SubscriptionPersistence;
49 import com.liferay.portal.service.persistence.UserPersistence;
50 import com.liferay.portal.service.persistence.WorkflowInstanceLinkPersistence;
51 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
52
53 import com.liferay.portlet.asset.service.persistence.AssetEntryPersistence;
54 import com.liferay.portlet.asset.service.persistence.AssetTagPersistence;
55 import com.liferay.portlet.blogs.service.persistence.BlogsEntryPersistence;
56 import com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence;
57 import com.liferay.portlet.messageboards.NoSuchMessageException;
58 import com.liferay.portlet.messageboards.model.MBMessage;
59 import com.liferay.portlet.messageboards.model.impl.MBMessageImpl;
60 import com.liferay.portlet.messageboards.model.impl.MBMessageModelImpl;
61 import com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence;
62 import com.liferay.portlet.social.service.persistence.SocialActivityPersistence;
63 import com.liferay.portlet.social.service.persistence.SocialEquityLogPersistence;
64
65 import java.io.Serializable;
66
67 import java.util.ArrayList;
68 import java.util.Collections;
69 import java.util.List;
70
71
84 public class MBMessagePersistenceImpl extends BasePersistenceImpl<MBMessage>
85 implements MBMessagePersistence {
86 public static final String FINDER_CLASS_NAME_ENTITY = MBMessageImpl.class.getName();
87 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
88 ".List";
89 public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
90 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
91 "findByUuid",
92 new String[] {
93 String.class.getName(),
94
95 "java.lang.Integer", "java.lang.Integer",
96 "com.liferay.portal.kernel.util.OrderByComparator"
97 });
98 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
99 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
100 "countByUuid", new String[] { String.class.getName() });
101 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
102 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
103 "fetchByUUID_G",
104 new String[] { String.class.getName(), Long.class.getName() });
105 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
106 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
107 "countByUUID_G",
108 new String[] { String.class.getName(), Long.class.getName() });
109 public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
110 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
111 "findByGroupId",
112 new String[] {
113 Long.class.getName(),
114
115 "java.lang.Integer", "java.lang.Integer",
116 "com.liferay.portal.kernel.util.OrderByComparator"
117 });
118 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
119 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
120 "countByGroupId", new String[] { Long.class.getName() });
121 public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
122 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
123 "findByCompanyId",
124 new String[] {
125 Long.class.getName(),
126
127 "java.lang.Integer", "java.lang.Integer",
128 "com.liferay.portal.kernel.util.OrderByComparator"
129 });
130 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
131 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
132 "countByCompanyId", new String[] { Long.class.getName() });
133 public static final FinderPath FINDER_PATH_FIND_BY_THREADID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
134 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
135 "findByThreadId",
136 new String[] {
137 Long.class.getName(),
138
139 "java.lang.Integer", "java.lang.Integer",
140 "com.liferay.portal.kernel.util.OrderByComparator"
141 });
142 public static final FinderPath FINDER_PATH_COUNT_BY_THREADID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
143 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
144 "countByThreadId", new String[] { Long.class.getName() });
145 public static final FinderPath FINDER_PATH_FIND_BY_THREADREPLIES = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
146 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
147 "findByThreadReplies",
148 new String[] {
149 Long.class.getName(),
150
151 "java.lang.Integer", "java.lang.Integer",
152 "com.liferay.portal.kernel.util.OrderByComparator"
153 });
154 public static final FinderPath FINDER_PATH_COUNT_BY_THREADREPLIES = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
155 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
156 "countByThreadReplies", new String[] { Long.class.getName() });
157 public static final FinderPath FINDER_PATH_FIND_BY_USERID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
158 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
159 "findByUserId",
160 new String[] {
161 Long.class.getName(),
162
163 "java.lang.Integer", "java.lang.Integer",
164 "com.liferay.portal.kernel.util.OrderByComparator"
165 });
166 public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
167 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
168 "countByUserId", new String[] { Long.class.getName() });
169 public static final FinderPath FINDER_PATH_FIND_BY_G_U = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
170 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
171 "findByG_U",
172 new String[] {
173 Long.class.getName(), Long.class.getName(),
174
175 "java.lang.Integer", "java.lang.Integer",
176 "com.liferay.portal.kernel.util.OrderByComparator"
177 });
178 public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
179 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
180 "countByG_U",
181 new String[] { Long.class.getName(), Long.class.getName() });
182 public static final FinderPath FINDER_PATH_FIND_BY_G_C = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
183 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
184 "findByG_C",
185 new String[] {
186 Long.class.getName(), Long.class.getName(),
187
188 "java.lang.Integer", "java.lang.Integer",
189 "com.liferay.portal.kernel.util.OrderByComparator"
190 });
191 public static final FinderPath FINDER_PATH_COUNT_BY_G_C = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
192 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
193 "countByG_C",
194 new String[] { Long.class.getName(), Long.class.getName() });
195 public static final FinderPath FINDER_PATH_FIND_BY_G_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
196 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
197 "findByG_S",
198 new String[] {
199 Long.class.getName(), Integer.class.getName(),
200
201 "java.lang.Integer", "java.lang.Integer",
202 "com.liferay.portal.kernel.util.OrderByComparator"
203 });
204 public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
205 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
206 "countByG_S",
207 new String[] { Long.class.getName(), Integer.class.getName() });
208 public static final FinderPath FINDER_PATH_FIND_BY_C_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
209 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
210 "findByC_S",
211 new String[] {
212 Long.class.getName(), Integer.class.getName(),
213
214 "java.lang.Integer", "java.lang.Integer",
215 "com.liferay.portal.kernel.util.OrderByComparator"
216 });
217 public static final FinderPath FINDER_PATH_COUNT_BY_C_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
218 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
219 "countByC_S",
220 new String[] { Long.class.getName(), Integer.class.getName() });
221 public static final FinderPath FINDER_PATH_FIND_BY_C_C = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
222 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
223 "findByC_C",
224 new String[] {
225 Long.class.getName(), Long.class.getName(),
226
227 "java.lang.Integer", "java.lang.Integer",
228 "com.liferay.portal.kernel.util.OrderByComparator"
229 });
230 public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
231 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
232 "countByC_C",
233 new String[] { Long.class.getName(), Long.class.getName() });
234 public static final FinderPath FINDER_PATH_FIND_BY_T_P = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
235 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
236 "findByT_P",
237 new String[] {
238 Long.class.getName(), Long.class.getName(),
239
240 "java.lang.Integer", "java.lang.Integer",
241 "com.liferay.portal.kernel.util.OrderByComparator"
242 });
243 public static final FinderPath FINDER_PATH_COUNT_BY_T_P = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
244 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
245 "countByT_P",
246 new String[] { Long.class.getName(), Long.class.getName() });
247 public static final FinderPath FINDER_PATH_FIND_BY_T_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
248 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
249 "findByT_S",
250 new String[] {
251 Long.class.getName(), Integer.class.getName(),
252
253 "java.lang.Integer", "java.lang.Integer",
254 "com.liferay.portal.kernel.util.OrderByComparator"
255 });
256 public static final FinderPath FINDER_PATH_COUNT_BY_T_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
257 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
258 "countByT_S",
259 new String[] { Long.class.getName(), Integer.class.getName() });
260 public static final FinderPath FINDER_PATH_FIND_BY_TR_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
261 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
262 "findByTR_S",
263 new String[] {
264 Long.class.getName(), Integer.class.getName(),
265
266 "java.lang.Integer", "java.lang.Integer",
267 "com.liferay.portal.kernel.util.OrderByComparator"
268 });
269 public static final FinderPath FINDER_PATH_COUNT_BY_TR_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
270 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
271 "countByTR_S",
272 new String[] { Long.class.getName(), Integer.class.getName() });
273 public static final FinderPath FINDER_PATH_FIND_BY_G_U_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
274 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
275 "findByG_U_S",
276 new String[] {
277 Long.class.getName(), Long.class.getName(),
278 Integer.class.getName(),
279
280 "java.lang.Integer", "java.lang.Integer",
281 "com.liferay.portal.kernel.util.OrderByComparator"
282 });
283 public static final FinderPath FINDER_PATH_COUNT_BY_G_U_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
284 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
285 "countByG_U_S",
286 new String[] {
287 Long.class.getName(), Long.class.getName(),
288 Integer.class.getName()
289 });
290 public static final FinderPath FINDER_PATH_FIND_BY_G_C_T = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
291 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
292 "findByG_C_T",
293 new String[] {
294 Long.class.getName(), Long.class.getName(), Long.class.getName(),
295
296 "java.lang.Integer", "java.lang.Integer",
297 "com.liferay.portal.kernel.util.OrderByComparator"
298 });
299 public static final FinderPath FINDER_PATH_COUNT_BY_G_C_T = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
300 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
301 "countByG_C_T",
302 new String[] {
303 Long.class.getName(), Long.class.getName(), Long.class.getName()
304 });
305 public static final FinderPath FINDER_PATH_FIND_BY_G_C_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
306 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
307 "findByG_C_S",
308 new String[] {
309 Long.class.getName(), Long.class.getName(),
310 Integer.class.getName(),
311
312 "java.lang.Integer", "java.lang.Integer",
313 "com.liferay.portal.kernel.util.OrderByComparator"
314 });
315 public static final FinderPath FINDER_PATH_COUNT_BY_G_C_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
316 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
317 "countByG_C_S",
318 new String[] {
319 Long.class.getName(), Long.class.getName(),
320 Integer.class.getName()
321 });
322 public static final FinderPath FINDER_PATH_FIND_BY_C_C_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
323 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
324 "findByC_C_S",
325 new String[] {
326 Long.class.getName(), Long.class.getName(),
327 Integer.class.getName(),
328
329 "java.lang.Integer", "java.lang.Integer",
330 "com.liferay.portal.kernel.util.OrderByComparator"
331 });
332 public static final FinderPath FINDER_PATH_COUNT_BY_C_C_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
333 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
334 "countByC_C_S",
335 new String[] {
336 Long.class.getName(), Long.class.getName(),
337 Integer.class.getName()
338 });
339 public static final FinderPath FINDER_PATH_FIND_BY_G_C_T_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
340 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
341 "findByG_C_T_S",
342 new String[] {
343 Long.class.getName(), Long.class.getName(), Long.class.getName(),
344 Integer.class.getName(),
345
346 "java.lang.Integer", "java.lang.Integer",
347 "com.liferay.portal.kernel.util.OrderByComparator"
348 });
349 public static final FinderPath FINDER_PATH_COUNT_BY_G_C_T_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
350 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
351 "countByG_C_T_S",
352 new String[] {
353 Long.class.getName(), Long.class.getName(), Long.class.getName(),
354 Integer.class.getName()
355 });
356 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
357 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
358 "findAll", new String[0]);
359 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
360 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
361 "countAll", new String[0]);
362
363 public void cacheResult(MBMessage mbMessage) {
364 EntityCacheUtil.putResult(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
365 MBMessageImpl.class, mbMessage.getPrimaryKey(), mbMessage);
366
367 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
368 new Object[] { mbMessage.getUuid(), new Long(mbMessage.getGroupId()) },
369 mbMessage);
370 }
371
372 public void cacheResult(List<MBMessage> mbMessages) {
373 for (MBMessage mbMessage : mbMessages) {
374 if (EntityCacheUtil.getResult(
375 MBMessageModelImpl.ENTITY_CACHE_ENABLED,
376 MBMessageImpl.class, mbMessage.getPrimaryKey(), this) == null) {
377 cacheResult(mbMessage);
378 }
379 }
380 }
381
382 public void clearCache() {
383 CacheRegistry.clear(MBMessageImpl.class.getName());
384 EntityCacheUtil.clearCache(MBMessageImpl.class.getName());
385 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
386 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
387 }
388
389 public void clearCache(MBMessage mbMessage) {
390 EntityCacheUtil.removeResult(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
391 MBMessageImpl.class, mbMessage.getPrimaryKey());
392
393 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
394 new Object[] { mbMessage.getUuid(), new Long(mbMessage.getGroupId()) });
395 }
396
397 public MBMessage create(long messageId) {
398 MBMessage mbMessage = new MBMessageImpl();
399
400 mbMessage.setNew(true);
401 mbMessage.setPrimaryKey(messageId);
402
403 String uuid = PortalUUIDUtil.generate();
404
405 mbMessage.setUuid(uuid);
406
407 return mbMessage;
408 }
409
410 public MBMessage remove(Serializable primaryKey)
411 throws NoSuchModelException, SystemException {
412 return remove(((Long)primaryKey).longValue());
413 }
414
415 public MBMessage remove(long messageId)
416 throws NoSuchMessageException, SystemException {
417 Session session = null;
418
419 try {
420 session = openSession();
421
422 MBMessage mbMessage = (MBMessage)session.get(MBMessageImpl.class,
423 new Long(messageId));
424
425 if (mbMessage == null) {
426 if (_log.isWarnEnabled()) {
427 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + messageId);
428 }
429
430 throw new NoSuchMessageException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
431 messageId);
432 }
433
434 return remove(mbMessage);
435 }
436 catch (NoSuchMessageException nsee) {
437 throw nsee;
438 }
439 catch (Exception e) {
440 throw processException(e);
441 }
442 finally {
443 closeSession(session);
444 }
445 }
446
447 public MBMessage remove(MBMessage mbMessage) throws SystemException {
448 for (ModelListener<MBMessage> listener : listeners) {
449 listener.onBeforeRemove(mbMessage);
450 }
451
452 mbMessage = removeImpl(mbMessage);
453
454 for (ModelListener<MBMessage> listener : listeners) {
455 listener.onAfterRemove(mbMessage);
456 }
457
458 return mbMessage;
459 }
460
461 protected MBMessage removeImpl(MBMessage mbMessage)
462 throws SystemException {
463 mbMessage = toUnwrappedModel(mbMessage);
464
465 Session session = null;
466
467 try {
468 session = openSession();
469
470 if (mbMessage.isCachedModel() || BatchSessionUtil.isEnabled()) {
471 Object staleObject = session.get(MBMessageImpl.class,
472 mbMessage.getPrimaryKeyObj());
473
474 if (staleObject != null) {
475 session.evict(staleObject);
476 }
477 }
478
479 session.delete(mbMessage);
480
481 session.flush();
482 }
483 catch (Exception e) {
484 throw processException(e);
485 }
486 finally {
487 closeSession(session);
488 }
489
490 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
491
492 MBMessageModelImpl mbMessageModelImpl = (MBMessageModelImpl)mbMessage;
493
494 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
495 new Object[] {
496 mbMessageModelImpl.getOriginalUuid(),
497 new Long(mbMessageModelImpl.getOriginalGroupId())
498 });
499
500 EntityCacheUtil.removeResult(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
501 MBMessageImpl.class, mbMessage.getPrimaryKey());
502
503 return mbMessage;
504 }
505
506 public MBMessage updateImpl(
507 com.liferay.portlet.messageboards.model.MBMessage mbMessage,
508 boolean merge) throws SystemException {
509 mbMessage = toUnwrappedModel(mbMessage);
510
511 boolean isNew = mbMessage.isNew();
512
513 MBMessageModelImpl mbMessageModelImpl = (MBMessageModelImpl)mbMessage;
514
515 if (Validator.isNull(mbMessage.getUuid())) {
516 String uuid = PortalUUIDUtil.generate();
517
518 mbMessage.setUuid(uuid);
519 }
520
521 Session session = null;
522
523 try {
524 session = openSession();
525
526 BatchSessionUtil.update(session, mbMessage, merge);
527
528 mbMessage.setNew(false);
529 }
530 catch (Exception e) {
531 throw processException(e);
532 }
533 finally {
534 closeSession(session);
535 }
536
537 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
538
539 EntityCacheUtil.putResult(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
540 MBMessageImpl.class, mbMessage.getPrimaryKey(), mbMessage);
541
542 if (!isNew &&
543 (!Validator.equals(mbMessage.getUuid(),
544 mbMessageModelImpl.getOriginalUuid()) ||
545 (mbMessage.getGroupId() != mbMessageModelImpl.getOriginalGroupId()))) {
546 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
547 new Object[] {
548 mbMessageModelImpl.getOriginalUuid(),
549 new Long(mbMessageModelImpl.getOriginalGroupId())
550 });
551 }
552
553 if (isNew ||
554 (!Validator.equals(mbMessage.getUuid(),
555 mbMessageModelImpl.getOriginalUuid()) ||
556 (mbMessage.getGroupId() != mbMessageModelImpl.getOriginalGroupId()))) {
557 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
558 new Object[] {
559 mbMessage.getUuid(), new Long(mbMessage.getGroupId())
560 }, mbMessage);
561 }
562
563 return mbMessage;
564 }
565
566 protected MBMessage toUnwrappedModel(MBMessage mbMessage) {
567 if (mbMessage instanceof MBMessageImpl) {
568 return mbMessage;
569 }
570
571 MBMessageImpl mbMessageImpl = new MBMessageImpl();
572
573 mbMessageImpl.setNew(mbMessage.isNew());
574 mbMessageImpl.setPrimaryKey(mbMessage.getPrimaryKey());
575
576 mbMessageImpl.setUuid(mbMessage.getUuid());
577 mbMessageImpl.setMessageId(mbMessage.getMessageId());
578 mbMessageImpl.setGroupId(mbMessage.getGroupId());
579 mbMessageImpl.setCompanyId(mbMessage.getCompanyId());
580 mbMessageImpl.setUserId(mbMessage.getUserId());
581 mbMessageImpl.setUserName(mbMessage.getUserName());
582 mbMessageImpl.setCreateDate(mbMessage.getCreateDate());
583 mbMessageImpl.setModifiedDate(mbMessage.getModifiedDate());
584 mbMessageImpl.setClassNameId(mbMessage.getClassNameId());
585 mbMessageImpl.setClassPK(mbMessage.getClassPK());
586 mbMessageImpl.setCategoryId(mbMessage.getCategoryId());
587 mbMessageImpl.setThreadId(mbMessage.getThreadId());
588 mbMessageImpl.setParentMessageId(mbMessage.getParentMessageId());
589 mbMessageImpl.setSubject(mbMessage.getSubject());
590 mbMessageImpl.setBody(mbMessage.getBody());
591 mbMessageImpl.setAttachments(mbMessage.isAttachments());
592 mbMessageImpl.setAnonymous(mbMessage.isAnonymous());
593 mbMessageImpl.setPriority(mbMessage.getPriority());
594 mbMessageImpl.setAllowPingbacks(mbMessage.isAllowPingbacks());
595 mbMessageImpl.setStatus(mbMessage.getStatus());
596 mbMessageImpl.setStatusByUserId(mbMessage.getStatusByUserId());
597 mbMessageImpl.setStatusByUserName(mbMessage.getStatusByUserName());
598 mbMessageImpl.setStatusDate(mbMessage.getStatusDate());
599
600 return mbMessageImpl;
601 }
602
603 public MBMessage findByPrimaryKey(Serializable primaryKey)
604 throws NoSuchModelException, SystemException {
605 return findByPrimaryKey(((Long)primaryKey).longValue());
606 }
607
608 public MBMessage findByPrimaryKey(long messageId)
609 throws NoSuchMessageException, SystemException {
610 MBMessage mbMessage = fetchByPrimaryKey(messageId);
611
612 if (mbMessage == null) {
613 if (_log.isWarnEnabled()) {
614 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + messageId);
615 }
616
617 throw new NoSuchMessageException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
618 messageId);
619 }
620
621 return mbMessage;
622 }
623
624 public MBMessage fetchByPrimaryKey(Serializable primaryKey)
625 throws SystemException {
626 return fetchByPrimaryKey(((Long)primaryKey).longValue());
627 }
628
629 public MBMessage fetchByPrimaryKey(long messageId)
630 throws SystemException {
631 MBMessage mbMessage = (MBMessage)EntityCacheUtil.getResult(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
632 MBMessageImpl.class, messageId, this);
633
634 if (mbMessage == null) {
635 Session session = null;
636
637 try {
638 session = openSession();
639
640 mbMessage = (MBMessage)session.get(MBMessageImpl.class,
641 new Long(messageId));
642 }
643 catch (Exception e) {
644 throw processException(e);
645 }
646 finally {
647 if (mbMessage != null) {
648 cacheResult(mbMessage);
649 }
650
651 closeSession(session);
652 }
653 }
654
655 return mbMessage;
656 }
657
658 public List<MBMessage> findByUuid(String uuid) throws SystemException {
659 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
660 }
661
662 public List<MBMessage> findByUuid(String uuid, int start, int end)
663 throws SystemException {
664 return findByUuid(uuid, start, end, null);
665 }
666
667 public List<MBMessage> findByUuid(String uuid, int start, int end,
668 OrderByComparator orderByComparator) throws SystemException {
669 Object[] finderArgs = new Object[] {
670 uuid,
671
672 String.valueOf(start), String.valueOf(end),
673 String.valueOf(orderByComparator)
674 };
675
676 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
677 finderArgs, this);
678
679 if (list == null) {
680 Session session = null;
681
682 try {
683 session = openSession();
684
685 StringBundler query = null;
686
687 if (orderByComparator != null) {
688 query = new StringBundler(3 +
689 (orderByComparator.getOrderByFields().length * 3));
690 }
691 else {
692 query = new StringBundler(3);
693 }
694
695 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
696
697 if (uuid == null) {
698 query.append(_FINDER_COLUMN_UUID_UUID_1);
699 }
700 else {
701 if (uuid.equals(StringPool.BLANK)) {
702 query.append(_FINDER_COLUMN_UUID_UUID_3);
703 }
704 else {
705 query.append(_FINDER_COLUMN_UUID_UUID_2);
706 }
707 }
708
709 if (orderByComparator != null) {
710 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
711 orderByComparator);
712 }
713
714 else {
715 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
716 }
717
718 String sql = query.toString();
719
720 Query q = session.createQuery(sql);
721
722 QueryPos qPos = QueryPos.getInstance(q);
723
724 if (uuid != null) {
725 qPos.add(uuid);
726 }
727
728 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
729 end);
730 }
731 catch (Exception e) {
732 throw processException(e);
733 }
734 finally {
735 if (list == null) {
736 list = new ArrayList<MBMessage>();
737 }
738
739 cacheResult(list);
740
741 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
742 list);
743
744 closeSession(session);
745 }
746 }
747
748 return list;
749 }
750
751 public MBMessage findByUuid_First(String uuid,
752 OrderByComparator orderByComparator)
753 throws NoSuchMessageException, SystemException {
754 List<MBMessage> list = findByUuid(uuid, 0, 1, orderByComparator);
755
756 if (list.isEmpty()) {
757 StringBundler msg = new StringBundler(4);
758
759 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
760
761 msg.append("uuid=");
762 msg.append(uuid);
763
764 msg.append(StringPool.CLOSE_CURLY_BRACE);
765
766 throw new NoSuchMessageException(msg.toString());
767 }
768 else {
769 return list.get(0);
770 }
771 }
772
773 public MBMessage findByUuid_Last(String uuid,
774 OrderByComparator orderByComparator)
775 throws NoSuchMessageException, SystemException {
776 int count = countByUuid(uuid);
777
778 List<MBMessage> list = findByUuid(uuid, count - 1, count,
779 orderByComparator);
780
781 if (list.isEmpty()) {
782 StringBundler msg = new StringBundler(4);
783
784 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
785
786 msg.append("uuid=");
787 msg.append(uuid);
788
789 msg.append(StringPool.CLOSE_CURLY_BRACE);
790
791 throw new NoSuchMessageException(msg.toString());
792 }
793 else {
794 return list.get(0);
795 }
796 }
797
798 public MBMessage[] findByUuid_PrevAndNext(long messageId, String uuid,
799 OrderByComparator orderByComparator)
800 throws NoSuchMessageException, SystemException {
801 MBMessage mbMessage = findByPrimaryKey(messageId);
802
803 Session session = null;
804
805 try {
806 session = openSession();
807
808 MBMessage[] array = new MBMessageImpl[3];
809
810 array[0] = getByUuid_PrevAndNext(session, mbMessage, uuid,
811 orderByComparator, true);
812
813 array[1] = mbMessage;
814
815 array[2] = getByUuid_PrevAndNext(session, mbMessage, uuid,
816 orderByComparator, false);
817
818 return array;
819 }
820 catch (Exception e) {
821 throw processException(e);
822 }
823 finally {
824 closeSession(session);
825 }
826 }
827
828 protected MBMessage getByUuid_PrevAndNext(Session session,
829 MBMessage mbMessage, String uuid, OrderByComparator orderByComparator,
830 boolean previous) {
831 StringBundler query = null;
832
833 if (orderByComparator != null) {
834 query = new StringBundler(6 +
835 (orderByComparator.getOrderByFields().length * 6));
836 }
837 else {
838 query = new StringBundler(3);
839 }
840
841 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
842
843 if (uuid == null) {
844 query.append(_FINDER_COLUMN_UUID_UUID_1);
845 }
846 else {
847 if (uuid.equals(StringPool.BLANK)) {
848 query.append(_FINDER_COLUMN_UUID_UUID_3);
849 }
850 else {
851 query.append(_FINDER_COLUMN_UUID_UUID_2);
852 }
853 }
854
855 if (orderByComparator != null) {
856 String[] orderByFields = orderByComparator.getOrderByFields();
857
858 if (orderByFields.length > 0) {
859 query.append(WHERE_AND);
860 }
861
862 for (int i = 0; i < orderByFields.length; i++) {
863 query.append(_ORDER_BY_ENTITY_ALIAS);
864 query.append(orderByFields[i]);
865
866 if ((i + 1) < orderByFields.length) {
867 if (orderByComparator.isAscending() ^ previous) {
868 query.append(WHERE_GREATER_THAN_HAS_NEXT);
869 }
870 else {
871 query.append(WHERE_LESSER_THAN_HAS_NEXT);
872 }
873 }
874 else {
875 if (orderByComparator.isAscending() ^ previous) {
876 query.append(WHERE_GREATER_THAN);
877 }
878 else {
879 query.append(WHERE_LESSER_THAN);
880 }
881 }
882 }
883
884 query.append(ORDER_BY_CLAUSE);
885
886 for (int i = 0; i < orderByFields.length; i++) {
887 query.append(_ORDER_BY_ENTITY_ALIAS);
888 query.append(orderByFields[i]);
889
890 if ((i + 1) < orderByFields.length) {
891 if (orderByComparator.isAscending() ^ previous) {
892 query.append(ORDER_BY_ASC_HAS_NEXT);
893 }
894 else {
895 query.append(ORDER_BY_DESC_HAS_NEXT);
896 }
897 }
898 else {
899 if (orderByComparator.isAscending() ^ previous) {
900 query.append(ORDER_BY_ASC);
901 }
902 else {
903 query.append(ORDER_BY_DESC);
904 }
905 }
906 }
907 }
908
909 else {
910 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
911 }
912
913 String sql = query.toString();
914
915 Query q = session.createQuery(sql);
916
917 q.setFirstResult(0);
918 q.setMaxResults(2);
919
920 QueryPos qPos = QueryPos.getInstance(q);
921
922 if (uuid != null) {
923 qPos.add(uuid);
924 }
925
926 if (orderByComparator != null) {
927 Object[] values = orderByComparator.getOrderByValues(mbMessage);
928
929 for (Object value : values) {
930 qPos.add(value);
931 }
932 }
933
934 List<MBMessage> list = q.list();
935
936 if (list.size() == 2) {
937 return list.get(1);
938 }
939 else {
940 return null;
941 }
942 }
943
944 public MBMessage findByUUID_G(String uuid, long groupId)
945 throws NoSuchMessageException, SystemException {
946 MBMessage mbMessage = fetchByUUID_G(uuid, groupId);
947
948 if (mbMessage == null) {
949 StringBundler msg = new StringBundler(6);
950
951 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
952
953 msg.append("uuid=");
954 msg.append(uuid);
955
956 msg.append(", groupId=");
957 msg.append(groupId);
958
959 msg.append(StringPool.CLOSE_CURLY_BRACE);
960
961 if (_log.isWarnEnabled()) {
962 _log.warn(msg.toString());
963 }
964
965 throw new NoSuchMessageException(msg.toString());
966 }
967
968 return mbMessage;
969 }
970
971 public MBMessage fetchByUUID_G(String uuid, long groupId)
972 throws SystemException {
973 return fetchByUUID_G(uuid, groupId, true);
974 }
975
976 public MBMessage fetchByUUID_G(String uuid, long groupId,
977 boolean retrieveFromCache) throws SystemException {
978 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
979
980 Object result = null;
981
982 if (retrieveFromCache) {
983 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
984 finderArgs, this);
985 }
986
987 if (result == null) {
988 Session session = null;
989
990 try {
991 session = openSession();
992
993 StringBundler query = new StringBundler(4);
994
995 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
996
997 if (uuid == null) {
998 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
999 }
1000 else {
1001 if (uuid.equals(StringPool.BLANK)) {
1002 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1003 }
1004 else {
1005 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1006 }
1007 }
1008
1009 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1010
1011 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
1012
1013 String sql = query.toString();
1014
1015 Query q = session.createQuery(sql);
1016
1017 QueryPos qPos = QueryPos.getInstance(q);
1018
1019 if (uuid != null) {
1020 qPos.add(uuid);
1021 }
1022
1023 qPos.add(groupId);
1024
1025 List<MBMessage> list = q.list();
1026
1027 result = list;
1028
1029 MBMessage mbMessage = null;
1030
1031 if (list.isEmpty()) {
1032 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1033 finderArgs, list);
1034 }
1035 else {
1036 mbMessage = list.get(0);
1037
1038 cacheResult(mbMessage);
1039
1040 if ((mbMessage.getUuid() == null) ||
1041 !mbMessage.getUuid().equals(uuid) ||
1042 (mbMessage.getGroupId() != groupId)) {
1043 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1044 finderArgs, mbMessage);
1045 }
1046 }
1047
1048 return mbMessage;
1049 }
1050 catch (Exception e) {
1051 throw processException(e);
1052 }
1053 finally {
1054 if (result == null) {
1055 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1056 finderArgs, new ArrayList<MBMessage>());
1057 }
1058
1059 closeSession(session);
1060 }
1061 }
1062 else {
1063 if (result instanceof List<?>) {
1064 return null;
1065 }
1066 else {
1067 return (MBMessage)result;
1068 }
1069 }
1070 }
1071
1072 public List<MBMessage> findByGroupId(long groupId)
1073 throws SystemException {
1074 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1075 }
1076
1077 public List<MBMessage> findByGroupId(long groupId, int start, int end)
1078 throws SystemException {
1079 return findByGroupId(groupId, start, end, null);
1080 }
1081
1082 public List<MBMessage> findByGroupId(long groupId, int start, int end,
1083 OrderByComparator orderByComparator) throws SystemException {
1084 Object[] finderArgs = new Object[] {
1085 new Long(groupId),
1086
1087 String.valueOf(start), String.valueOf(end),
1088 String.valueOf(orderByComparator)
1089 };
1090
1091 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
1092 finderArgs, this);
1093
1094 if (list == null) {
1095 Session session = null;
1096
1097 try {
1098 session = openSession();
1099
1100 StringBundler query = null;
1101
1102 if (orderByComparator != null) {
1103 query = new StringBundler(3 +
1104 (orderByComparator.getOrderByFields().length * 3));
1105 }
1106 else {
1107 query = new StringBundler(3);
1108 }
1109
1110 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
1111
1112 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1113
1114 if (orderByComparator != null) {
1115 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1116 orderByComparator);
1117 }
1118
1119 else {
1120 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
1121 }
1122
1123 String sql = query.toString();
1124
1125 Query q = session.createQuery(sql);
1126
1127 QueryPos qPos = QueryPos.getInstance(q);
1128
1129 qPos.add(groupId);
1130
1131 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
1132 end);
1133 }
1134 catch (Exception e) {
1135 throw processException(e);
1136 }
1137 finally {
1138 if (list == null) {
1139 list = new ArrayList<MBMessage>();
1140 }
1141
1142 cacheResult(list);
1143
1144 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
1145 finderArgs, list);
1146
1147 closeSession(session);
1148 }
1149 }
1150
1151 return list;
1152 }
1153
1154 public MBMessage findByGroupId_First(long groupId,
1155 OrderByComparator orderByComparator)
1156 throws NoSuchMessageException, SystemException {
1157 List<MBMessage> list = findByGroupId(groupId, 0, 1, orderByComparator);
1158
1159 if (list.isEmpty()) {
1160 StringBundler msg = new StringBundler(4);
1161
1162 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1163
1164 msg.append("groupId=");
1165 msg.append(groupId);
1166
1167 msg.append(StringPool.CLOSE_CURLY_BRACE);
1168
1169 throw new NoSuchMessageException(msg.toString());
1170 }
1171 else {
1172 return list.get(0);
1173 }
1174 }
1175
1176 public MBMessage findByGroupId_Last(long groupId,
1177 OrderByComparator orderByComparator)
1178 throws NoSuchMessageException, SystemException {
1179 int count = countByGroupId(groupId);
1180
1181 List<MBMessage> list = findByGroupId(groupId, count - 1, count,
1182 orderByComparator);
1183
1184 if (list.isEmpty()) {
1185 StringBundler msg = new StringBundler(4);
1186
1187 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1188
1189 msg.append("groupId=");
1190 msg.append(groupId);
1191
1192 msg.append(StringPool.CLOSE_CURLY_BRACE);
1193
1194 throw new NoSuchMessageException(msg.toString());
1195 }
1196 else {
1197 return list.get(0);
1198 }
1199 }
1200
1201 public MBMessage[] findByGroupId_PrevAndNext(long messageId, long groupId,
1202 OrderByComparator orderByComparator)
1203 throws NoSuchMessageException, SystemException {
1204 MBMessage mbMessage = findByPrimaryKey(messageId);
1205
1206 Session session = null;
1207
1208 try {
1209 session = openSession();
1210
1211 MBMessage[] array = new MBMessageImpl[3];
1212
1213 array[0] = getByGroupId_PrevAndNext(session, mbMessage, groupId,
1214 orderByComparator, true);
1215
1216 array[1] = mbMessage;
1217
1218 array[2] = getByGroupId_PrevAndNext(session, mbMessage, groupId,
1219 orderByComparator, false);
1220
1221 return array;
1222 }
1223 catch (Exception e) {
1224 throw processException(e);
1225 }
1226 finally {
1227 closeSession(session);
1228 }
1229 }
1230
1231 protected MBMessage getByGroupId_PrevAndNext(Session session,
1232 MBMessage mbMessage, long groupId, OrderByComparator orderByComparator,
1233 boolean previous) {
1234 StringBundler query = null;
1235
1236 if (orderByComparator != null) {
1237 query = new StringBundler(6 +
1238 (orderByComparator.getOrderByFields().length * 6));
1239 }
1240 else {
1241 query = new StringBundler(3);
1242 }
1243
1244 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
1245
1246 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1247
1248 if (orderByComparator != null) {
1249 String[] orderByFields = orderByComparator.getOrderByFields();
1250
1251 if (orderByFields.length > 0) {
1252 query.append(WHERE_AND);
1253 }
1254
1255 for (int i = 0; i < orderByFields.length; i++) {
1256 query.append(_ORDER_BY_ENTITY_ALIAS);
1257 query.append(orderByFields[i]);
1258
1259 if ((i + 1) < orderByFields.length) {
1260 if (orderByComparator.isAscending() ^ previous) {
1261 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1262 }
1263 else {
1264 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1265 }
1266 }
1267 else {
1268 if (orderByComparator.isAscending() ^ previous) {
1269 query.append(WHERE_GREATER_THAN);
1270 }
1271 else {
1272 query.append(WHERE_LESSER_THAN);
1273 }
1274 }
1275 }
1276
1277 query.append(ORDER_BY_CLAUSE);
1278
1279 for (int i = 0; i < orderByFields.length; i++) {
1280 query.append(_ORDER_BY_ENTITY_ALIAS);
1281 query.append(orderByFields[i]);
1282
1283 if ((i + 1) < orderByFields.length) {
1284 if (orderByComparator.isAscending() ^ previous) {
1285 query.append(ORDER_BY_ASC_HAS_NEXT);
1286 }
1287 else {
1288 query.append(ORDER_BY_DESC_HAS_NEXT);
1289 }
1290 }
1291 else {
1292 if (orderByComparator.isAscending() ^ previous) {
1293 query.append(ORDER_BY_ASC);
1294 }
1295 else {
1296 query.append(ORDER_BY_DESC);
1297 }
1298 }
1299 }
1300 }
1301
1302 else {
1303 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
1304 }
1305
1306 String sql = query.toString();
1307
1308 Query q = session.createQuery(sql);
1309
1310 q.setFirstResult(0);
1311 q.setMaxResults(2);
1312
1313 QueryPos qPos = QueryPos.getInstance(q);
1314
1315 qPos.add(groupId);
1316
1317 if (orderByComparator != null) {
1318 Object[] values = orderByComparator.getOrderByValues(mbMessage);
1319
1320 for (Object value : values) {
1321 qPos.add(value);
1322 }
1323 }
1324
1325 List<MBMessage> list = q.list();
1326
1327 if (list.size() == 2) {
1328 return list.get(1);
1329 }
1330 else {
1331 return null;
1332 }
1333 }
1334
1335 public List<MBMessage> filterFindByGroupId(long groupId)
1336 throws SystemException {
1337 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1338 QueryUtil.ALL_POS, null);
1339 }
1340
1341 public List<MBMessage> filterFindByGroupId(long groupId, int start, int end)
1342 throws SystemException {
1343 return filterFindByGroupId(groupId, start, end, null);
1344 }
1345
1346 public List<MBMessage> filterFindByGroupId(long groupId, int start,
1347 int end, OrderByComparator orderByComparator) throws SystemException {
1348 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1349 return findByGroupId(groupId, start, end, orderByComparator);
1350 }
1351
1352 Session session = null;
1353
1354 try {
1355 session = openSession();
1356
1357 StringBundler query = null;
1358
1359 if (orderByComparator != null) {
1360 query = new StringBundler(3 +
1361 (orderByComparator.getOrderByFields().length * 3));
1362 }
1363 else {
1364 query = new StringBundler(3);
1365 }
1366
1367 query.append(_FILTER_SQL_SELECT_MBMESSAGE_WHERE);
1368
1369 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1370
1371 if (orderByComparator != null) {
1372 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1373 orderByComparator);
1374 }
1375
1376 else {
1377 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
1378 }
1379
1380 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1381 MBMessage.class.getName(), _FILTER_COLUMN_MESSAGEID,
1382 _FILTER_COLUMN_USERID, groupId);
1383
1384 SQLQuery q = session.createSQLQuery(sql);
1385
1386 q.addEntity(_FILTER_ENTITY_ALIAS, MBMessageImpl.class);
1387
1388 QueryPos qPos = QueryPos.getInstance(q);
1389
1390 qPos.add(groupId);
1391
1392 return (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end);
1393 }
1394 catch (Exception e) {
1395 throw processException(e);
1396 }
1397 finally {
1398 closeSession(session);
1399 }
1400 }
1401
1402 public List<MBMessage> findByCompanyId(long companyId)
1403 throws SystemException {
1404 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1405 null);
1406 }
1407
1408 public List<MBMessage> findByCompanyId(long companyId, int start, int end)
1409 throws SystemException {
1410 return findByCompanyId(companyId, start, end, null);
1411 }
1412
1413 public List<MBMessage> findByCompanyId(long companyId, int start, int end,
1414 OrderByComparator orderByComparator) throws SystemException {
1415 Object[] finderArgs = new Object[] {
1416 new Long(companyId),
1417
1418 String.valueOf(start), String.valueOf(end),
1419 String.valueOf(orderByComparator)
1420 };
1421
1422 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
1423 finderArgs, this);
1424
1425 if (list == null) {
1426 Session session = null;
1427
1428 try {
1429 session = openSession();
1430
1431 StringBundler query = null;
1432
1433 if (orderByComparator != null) {
1434 query = new StringBundler(3 +
1435 (orderByComparator.getOrderByFields().length * 3));
1436 }
1437 else {
1438 query = new StringBundler(3);
1439 }
1440
1441 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
1442
1443 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1444
1445 if (orderByComparator != null) {
1446 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1447 orderByComparator);
1448 }
1449
1450 else {
1451 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
1452 }
1453
1454 String sql = query.toString();
1455
1456 Query q = session.createQuery(sql);
1457
1458 QueryPos qPos = QueryPos.getInstance(q);
1459
1460 qPos.add(companyId);
1461
1462 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
1463 end);
1464 }
1465 catch (Exception e) {
1466 throw processException(e);
1467 }
1468 finally {
1469 if (list == null) {
1470 list = new ArrayList<MBMessage>();
1471 }
1472
1473 cacheResult(list);
1474
1475 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
1476 finderArgs, list);
1477
1478 closeSession(session);
1479 }
1480 }
1481
1482 return list;
1483 }
1484
1485 public MBMessage findByCompanyId_First(long companyId,
1486 OrderByComparator orderByComparator)
1487 throws NoSuchMessageException, SystemException {
1488 List<MBMessage> list = findByCompanyId(companyId, 0, 1,
1489 orderByComparator);
1490
1491 if (list.isEmpty()) {
1492 StringBundler msg = new StringBundler(4);
1493
1494 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1495
1496 msg.append("companyId=");
1497 msg.append(companyId);
1498
1499 msg.append(StringPool.CLOSE_CURLY_BRACE);
1500
1501 throw new NoSuchMessageException(msg.toString());
1502 }
1503 else {
1504 return list.get(0);
1505 }
1506 }
1507
1508 public MBMessage findByCompanyId_Last(long companyId,
1509 OrderByComparator orderByComparator)
1510 throws NoSuchMessageException, SystemException {
1511 int count = countByCompanyId(companyId);
1512
1513 List<MBMessage> list = findByCompanyId(companyId, count - 1, count,
1514 orderByComparator);
1515
1516 if (list.isEmpty()) {
1517 StringBundler msg = new StringBundler(4);
1518
1519 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1520
1521 msg.append("companyId=");
1522 msg.append(companyId);
1523
1524 msg.append(StringPool.CLOSE_CURLY_BRACE);
1525
1526 throw new NoSuchMessageException(msg.toString());
1527 }
1528 else {
1529 return list.get(0);
1530 }
1531 }
1532
1533 public MBMessage[] findByCompanyId_PrevAndNext(long messageId,
1534 long companyId, OrderByComparator orderByComparator)
1535 throws NoSuchMessageException, SystemException {
1536 MBMessage mbMessage = findByPrimaryKey(messageId);
1537
1538 Session session = null;
1539
1540 try {
1541 session = openSession();
1542
1543 MBMessage[] array = new MBMessageImpl[3];
1544
1545 array[0] = getByCompanyId_PrevAndNext(session, mbMessage,
1546 companyId, orderByComparator, true);
1547
1548 array[1] = mbMessage;
1549
1550 array[2] = getByCompanyId_PrevAndNext(session, mbMessage,
1551 companyId, orderByComparator, false);
1552
1553 return array;
1554 }
1555 catch (Exception e) {
1556 throw processException(e);
1557 }
1558 finally {
1559 closeSession(session);
1560 }
1561 }
1562
1563 protected MBMessage getByCompanyId_PrevAndNext(Session session,
1564 MBMessage mbMessage, long companyId,
1565 OrderByComparator orderByComparator, boolean previous) {
1566 StringBundler query = null;
1567
1568 if (orderByComparator != null) {
1569 query = new StringBundler(6 +
1570 (orderByComparator.getOrderByFields().length * 6));
1571 }
1572 else {
1573 query = new StringBundler(3);
1574 }
1575
1576 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
1577
1578 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1579
1580 if (orderByComparator != null) {
1581 String[] orderByFields = orderByComparator.getOrderByFields();
1582
1583 if (orderByFields.length > 0) {
1584 query.append(WHERE_AND);
1585 }
1586
1587 for (int i = 0; i < orderByFields.length; i++) {
1588 query.append(_ORDER_BY_ENTITY_ALIAS);
1589 query.append(orderByFields[i]);
1590
1591 if ((i + 1) < orderByFields.length) {
1592 if (orderByComparator.isAscending() ^ previous) {
1593 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1594 }
1595 else {
1596 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1597 }
1598 }
1599 else {
1600 if (orderByComparator.isAscending() ^ previous) {
1601 query.append(WHERE_GREATER_THAN);
1602 }
1603 else {
1604 query.append(WHERE_LESSER_THAN);
1605 }
1606 }
1607 }
1608
1609 query.append(ORDER_BY_CLAUSE);
1610
1611 for (int i = 0; i < orderByFields.length; i++) {
1612 query.append(_ORDER_BY_ENTITY_ALIAS);
1613 query.append(orderByFields[i]);
1614
1615 if ((i + 1) < orderByFields.length) {
1616 if (orderByComparator.isAscending() ^ previous) {
1617 query.append(ORDER_BY_ASC_HAS_NEXT);
1618 }
1619 else {
1620 query.append(ORDER_BY_DESC_HAS_NEXT);
1621 }
1622 }
1623 else {
1624 if (orderByComparator.isAscending() ^ previous) {
1625 query.append(ORDER_BY_ASC);
1626 }
1627 else {
1628 query.append(ORDER_BY_DESC);
1629 }
1630 }
1631 }
1632 }
1633
1634 else {
1635 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
1636 }
1637
1638 String sql = query.toString();
1639
1640 Query q = session.createQuery(sql);
1641
1642 q.setFirstResult(0);
1643 q.setMaxResults(2);
1644
1645 QueryPos qPos = QueryPos.getInstance(q);
1646
1647 qPos.add(companyId);
1648
1649 if (orderByComparator != null) {
1650 Object[] values = orderByComparator.getOrderByValues(mbMessage);
1651
1652 for (Object value : values) {
1653 qPos.add(value);
1654 }
1655 }
1656
1657 List<MBMessage> list = q.list();
1658
1659 if (list.size() == 2) {
1660 return list.get(1);
1661 }
1662 else {
1663 return null;
1664 }
1665 }
1666
1667 public List<MBMessage> findByThreadId(long threadId)
1668 throws SystemException {
1669 return findByThreadId(threadId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1670 null);
1671 }
1672
1673 public List<MBMessage> findByThreadId(long threadId, int start, int end)
1674 throws SystemException {
1675 return findByThreadId(threadId, start, end, null);
1676 }
1677
1678 public List<MBMessage> findByThreadId(long threadId, int start, int end,
1679 OrderByComparator orderByComparator) throws SystemException {
1680 Object[] finderArgs = new Object[] {
1681 new Long(threadId),
1682
1683 String.valueOf(start), String.valueOf(end),
1684 String.valueOf(orderByComparator)
1685 };
1686
1687 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_THREADID,
1688 finderArgs, this);
1689
1690 if (list == null) {
1691 Session session = null;
1692
1693 try {
1694 session = openSession();
1695
1696 StringBundler query = null;
1697
1698 if (orderByComparator != null) {
1699 query = new StringBundler(3 +
1700 (orderByComparator.getOrderByFields().length * 3));
1701 }
1702 else {
1703 query = new StringBundler(3);
1704 }
1705
1706 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
1707
1708 query.append(_FINDER_COLUMN_THREADID_THREADID_2);
1709
1710 if (orderByComparator != null) {
1711 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1712 orderByComparator);
1713 }
1714
1715 else {
1716 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
1717 }
1718
1719 String sql = query.toString();
1720
1721 Query q = session.createQuery(sql);
1722
1723 QueryPos qPos = QueryPos.getInstance(q);
1724
1725 qPos.add(threadId);
1726
1727 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
1728 end);
1729 }
1730 catch (Exception e) {
1731 throw processException(e);
1732 }
1733 finally {
1734 if (list == null) {
1735 list = new ArrayList<MBMessage>();
1736 }
1737
1738 cacheResult(list);
1739
1740 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_THREADID,
1741 finderArgs, list);
1742
1743 closeSession(session);
1744 }
1745 }
1746
1747 return list;
1748 }
1749
1750 public MBMessage findByThreadId_First(long threadId,
1751 OrderByComparator orderByComparator)
1752 throws NoSuchMessageException, SystemException {
1753 List<MBMessage> list = findByThreadId(threadId, 0, 1, orderByComparator);
1754
1755 if (list.isEmpty()) {
1756 StringBundler msg = new StringBundler(4);
1757
1758 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1759
1760 msg.append("threadId=");
1761 msg.append(threadId);
1762
1763 msg.append(StringPool.CLOSE_CURLY_BRACE);
1764
1765 throw new NoSuchMessageException(msg.toString());
1766 }
1767 else {
1768 return list.get(0);
1769 }
1770 }
1771
1772 public MBMessage findByThreadId_Last(long threadId,
1773 OrderByComparator orderByComparator)
1774 throws NoSuchMessageException, SystemException {
1775 int count = countByThreadId(threadId);
1776
1777 List<MBMessage> list = findByThreadId(threadId, count - 1, count,
1778 orderByComparator);
1779
1780 if (list.isEmpty()) {
1781 StringBundler msg = new StringBundler(4);
1782
1783 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1784
1785 msg.append("threadId=");
1786 msg.append(threadId);
1787
1788 msg.append(StringPool.CLOSE_CURLY_BRACE);
1789
1790 throw new NoSuchMessageException(msg.toString());
1791 }
1792 else {
1793 return list.get(0);
1794 }
1795 }
1796
1797 public MBMessage[] findByThreadId_PrevAndNext(long messageId,
1798 long threadId, OrderByComparator orderByComparator)
1799 throws NoSuchMessageException, SystemException {
1800 MBMessage mbMessage = findByPrimaryKey(messageId);
1801
1802 Session session = null;
1803
1804 try {
1805 session = openSession();
1806
1807 MBMessage[] array = new MBMessageImpl[3];
1808
1809 array[0] = getByThreadId_PrevAndNext(session, mbMessage, threadId,
1810 orderByComparator, true);
1811
1812 array[1] = mbMessage;
1813
1814 array[2] = getByThreadId_PrevAndNext(session, mbMessage, threadId,
1815 orderByComparator, false);
1816
1817 return array;
1818 }
1819 catch (Exception e) {
1820 throw processException(e);
1821 }
1822 finally {
1823 closeSession(session);
1824 }
1825 }
1826
1827 protected MBMessage getByThreadId_PrevAndNext(Session session,
1828 MBMessage mbMessage, long threadId,
1829 OrderByComparator orderByComparator, boolean previous) {
1830 StringBundler query = null;
1831
1832 if (orderByComparator != null) {
1833 query = new StringBundler(6 +
1834 (orderByComparator.getOrderByFields().length * 6));
1835 }
1836 else {
1837 query = new StringBundler(3);
1838 }
1839
1840 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
1841
1842 query.append(_FINDER_COLUMN_THREADID_THREADID_2);
1843
1844 if (orderByComparator != null) {
1845 String[] orderByFields = orderByComparator.getOrderByFields();
1846
1847 if (orderByFields.length > 0) {
1848 query.append(WHERE_AND);
1849 }
1850
1851 for (int i = 0; i < orderByFields.length; i++) {
1852 query.append(_ORDER_BY_ENTITY_ALIAS);
1853 query.append(orderByFields[i]);
1854
1855 if ((i + 1) < orderByFields.length) {
1856 if (orderByComparator.isAscending() ^ previous) {
1857 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1858 }
1859 else {
1860 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1861 }
1862 }
1863 else {
1864 if (orderByComparator.isAscending() ^ previous) {
1865 query.append(WHERE_GREATER_THAN);
1866 }
1867 else {
1868 query.append(WHERE_LESSER_THAN);
1869 }
1870 }
1871 }
1872
1873 query.append(ORDER_BY_CLAUSE);
1874
1875 for (int i = 0; i < orderByFields.length; i++) {
1876 query.append(_ORDER_BY_ENTITY_ALIAS);
1877 query.append(orderByFields[i]);
1878
1879 if ((i + 1) < orderByFields.length) {
1880 if (orderByComparator.isAscending() ^ previous) {
1881 query.append(ORDER_BY_ASC_HAS_NEXT);
1882 }
1883 else {
1884 query.append(ORDER_BY_DESC_HAS_NEXT);
1885 }
1886 }
1887 else {
1888 if (orderByComparator.isAscending() ^ previous) {
1889 query.append(ORDER_BY_ASC);
1890 }
1891 else {
1892 query.append(ORDER_BY_DESC);
1893 }
1894 }
1895 }
1896 }
1897
1898 else {
1899 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
1900 }
1901
1902 String sql = query.toString();
1903
1904 Query q = session.createQuery(sql);
1905
1906 q.setFirstResult(0);
1907 q.setMaxResults(2);
1908
1909 QueryPos qPos = QueryPos.getInstance(q);
1910
1911 qPos.add(threadId);
1912
1913 if (orderByComparator != null) {
1914 Object[] values = orderByComparator.getOrderByValues(mbMessage);
1915
1916 for (Object value : values) {
1917 qPos.add(value);
1918 }
1919 }
1920
1921 List<MBMessage> list = q.list();
1922
1923 if (list.size() == 2) {
1924 return list.get(1);
1925 }
1926 else {
1927 return null;
1928 }
1929 }
1930
1931 public List<MBMessage> findByThreadReplies(long threadId)
1932 throws SystemException {
1933 return findByThreadReplies(threadId, QueryUtil.ALL_POS,
1934 QueryUtil.ALL_POS, null);
1935 }
1936
1937 public List<MBMessage> findByThreadReplies(long threadId, int start, int end)
1938 throws SystemException {
1939 return findByThreadReplies(threadId, start, end, null);
1940 }
1941
1942 public List<MBMessage> findByThreadReplies(long threadId, int start,
1943 int end, OrderByComparator orderByComparator) throws SystemException {
1944 Object[] finderArgs = new Object[] {
1945 new Long(threadId),
1946
1947 String.valueOf(start), String.valueOf(end),
1948 String.valueOf(orderByComparator)
1949 };
1950
1951 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_THREADREPLIES,
1952 finderArgs, this);
1953
1954 if (list == null) {
1955 Session session = null;
1956
1957 try {
1958 session = openSession();
1959
1960 StringBundler query = null;
1961
1962 if (orderByComparator != null) {
1963 query = new StringBundler(3 +
1964 (orderByComparator.getOrderByFields().length * 3));
1965 }
1966 else {
1967 query = new StringBundler(3);
1968 }
1969
1970 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
1971
1972 query.append(_FINDER_COLUMN_THREADREPLIES_THREADID_2);
1973
1974 if (orderByComparator != null) {
1975 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1976 orderByComparator);
1977 }
1978
1979 else {
1980 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
1981 }
1982
1983 String sql = query.toString();
1984
1985 Query q = session.createQuery(sql);
1986
1987 QueryPos qPos = QueryPos.getInstance(q);
1988
1989 qPos.add(threadId);
1990
1991 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
1992 end);
1993 }
1994 catch (Exception e) {
1995 throw processException(e);
1996 }
1997 finally {
1998 if (list == null) {
1999 list = new ArrayList<MBMessage>();
2000 }
2001
2002 cacheResult(list);
2003
2004 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_THREADREPLIES,
2005 finderArgs, list);
2006
2007 closeSession(session);
2008 }
2009 }
2010
2011 return list;
2012 }
2013
2014 public MBMessage findByThreadReplies_First(long threadId,
2015 OrderByComparator orderByComparator)
2016 throws NoSuchMessageException, SystemException {
2017 List<MBMessage> list = findByThreadReplies(threadId, 0, 1,
2018 orderByComparator);
2019
2020 if (list.isEmpty()) {
2021 StringBundler msg = new StringBundler(4);
2022
2023 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2024
2025 msg.append("threadId=");
2026 msg.append(threadId);
2027
2028 msg.append(StringPool.CLOSE_CURLY_BRACE);
2029
2030 throw new NoSuchMessageException(msg.toString());
2031 }
2032 else {
2033 return list.get(0);
2034 }
2035 }
2036
2037 public MBMessage findByThreadReplies_Last(long threadId,
2038 OrderByComparator orderByComparator)
2039 throws NoSuchMessageException, SystemException {
2040 int count = countByThreadReplies(threadId);
2041
2042 List<MBMessage> list = findByThreadReplies(threadId, count - 1, count,
2043 orderByComparator);
2044
2045 if (list.isEmpty()) {
2046 StringBundler msg = new StringBundler(4);
2047
2048 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2049
2050 msg.append("threadId=");
2051 msg.append(threadId);
2052
2053 msg.append(StringPool.CLOSE_CURLY_BRACE);
2054
2055 throw new NoSuchMessageException(msg.toString());
2056 }
2057 else {
2058 return list.get(0);
2059 }
2060 }
2061
2062 public MBMessage[] findByThreadReplies_PrevAndNext(long messageId,
2063 long threadId, OrderByComparator orderByComparator)
2064 throws NoSuchMessageException, SystemException {
2065 MBMessage mbMessage = findByPrimaryKey(messageId);
2066
2067 Session session = null;
2068
2069 try {
2070 session = openSession();
2071
2072 MBMessage[] array = new MBMessageImpl[3];
2073
2074 array[0] = getByThreadReplies_PrevAndNext(session, mbMessage,
2075 threadId, orderByComparator, true);
2076
2077 array[1] = mbMessage;
2078
2079 array[2] = getByThreadReplies_PrevAndNext(session, mbMessage,
2080 threadId, orderByComparator, false);
2081
2082 return array;
2083 }
2084 catch (Exception e) {
2085 throw processException(e);
2086 }
2087 finally {
2088 closeSession(session);
2089 }
2090 }
2091
2092 protected MBMessage getByThreadReplies_PrevAndNext(Session session,
2093 MBMessage mbMessage, long threadId,
2094 OrderByComparator orderByComparator, boolean previous) {
2095 StringBundler query = null;
2096
2097 if (orderByComparator != null) {
2098 query = new StringBundler(6 +
2099 (orderByComparator.getOrderByFields().length * 6));
2100 }
2101 else {
2102 query = new StringBundler(3);
2103 }
2104
2105 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
2106
2107 query.append(_FINDER_COLUMN_THREADREPLIES_THREADID_2);
2108
2109 if (orderByComparator != null) {
2110 String[] orderByFields = orderByComparator.getOrderByFields();
2111
2112 if (orderByFields.length > 0) {
2113 query.append(WHERE_AND);
2114 }
2115
2116 for (int i = 0; i < orderByFields.length; i++) {
2117 query.append(_ORDER_BY_ENTITY_ALIAS);
2118 query.append(orderByFields[i]);
2119
2120 if ((i + 1) < orderByFields.length) {
2121 if (orderByComparator.isAscending() ^ previous) {
2122 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2123 }
2124 else {
2125 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2126 }
2127 }
2128 else {
2129 if (orderByComparator.isAscending() ^ previous) {
2130 query.append(WHERE_GREATER_THAN);
2131 }
2132 else {
2133 query.append(WHERE_LESSER_THAN);
2134 }
2135 }
2136 }
2137
2138 query.append(ORDER_BY_CLAUSE);
2139
2140 for (int i = 0; i < orderByFields.length; i++) {
2141 query.append(_ORDER_BY_ENTITY_ALIAS);
2142 query.append(orderByFields[i]);
2143
2144 if ((i + 1) < orderByFields.length) {
2145 if (orderByComparator.isAscending() ^ previous) {
2146 query.append(ORDER_BY_ASC_HAS_NEXT);
2147 }
2148 else {
2149 query.append(ORDER_BY_DESC_HAS_NEXT);
2150 }
2151 }
2152 else {
2153 if (orderByComparator.isAscending() ^ previous) {
2154 query.append(ORDER_BY_ASC);
2155 }
2156 else {
2157 query.append(ORDER_BY_DESC);
2158 }
2159 }
2160 }
2161 }
2162
2163 else {
2164 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
2165 }
2166
2167 String sql = query.toString();
2168
2169 Query q = session.createQuery(sql);
2170
2171 q.setFirstResult(0);
2172 q.setMaxResults(2);
2173
2174 QueryPos qPos = QueryPos.getInstance(q);
2175
2176 qPos.add(threadId);
2177
2178 if (orderByComparator != null) {
2179 Object[] values = orderByComparator.getOrderByValues(mbMessage);
2180
2181 for (Object value : values) {
2182 qPos.add(value);
2183 }
2184 }
2185
2186 List<MBMessage> list = q.list();
2187
2188 if (list.size() == 2) {
2189 return list.get(1);
2190 }
2191 else {
2192 return null;
2193 }
2194 }
2195
2196 public List<MBMessage> findByUserId(long userId) throws SystemException {
2197 return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2198 }
2199
2200 public List<MBMessage> findByUserId(long userId, int start, int end)
2201 throws SystemException {
2202 return findByUserId(userId, start, end, null);
2203 }
2204
2205 public List<MBMessage> findByUserId(long userId, int start, int end,
2206 OrderByComparator orderByComparator) throws SystemException {
2207 Object[] finderArgs = new Object[] {
2208 new Long(userId),
2209
2210 String.valueOf(start), String.valueOf(end),
2211 String.valueOf(orderByComparator)
2212 };
2213
2214 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_USERID,
2215 finderArgs, this);
2216
2217 if (list == null) {
2218 Session session = null;
2219
2220 try {
2221 session = openSession();
2222
2223 StringBundler query = null;
2224
2225 if (orderByComparator != null) {
2226 query = new StringBundler(3 +
2227 (orderByComparator.getOrderByFields().length * 3));
2228 }
2229 else {
2230 query = new StringBundler(3);
2231 }
2232
2233 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
2234
2235 query.append(_FINDER_COLUMN_USERID_USERID_2);
2236
2237 if (orderByComparator != null) {
2238 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2239 orderByComparator);
2240 }
2241
2242 else {
2243 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
2244 }
2245
2246 String sql = query.toString();
2247
2248 Query q = session.createQuery(sql);
2249
2250 QueryPos qPos = QueryPos.getInstance(q);
2251
2252 qPos.add(userId);
2253
2254 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
2255 end);
2256 }
2257 catch (Exception e) {
2258 throw processException(e);
2259 }
2260 finally {
2261 if (list == null) {
2262 list = new ArrayList<MBMessage>();
2263 }
2264
2265 cacheResult(list);
2266
2267 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_USERID,
2268 finderArgs, list);
2269
2270 closeSession(session);
2271 }
2272 }
2273
2274 return list;
2275 }
2276
2277 public MBMessage findByUserId_First(long userId,
2278 OrderByComparator orderByComparator)
2279 throws NoSuchMessageException, SystemException {
2280 List<MBMessage> list = findByUserId(userId, 0, 1, orderByComparator);
2281
2282 if (list.isEmpty()) {
2283 StringBundler msg = new StringBundler(4);
2284
2285 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2286
2287 msg.append("userId=");
2288 msg.append(userId);
2289
2290 msg.append(StringPool.CLOSE_CURLY_BRACE);
2291
2292 throw new NoSuchMessageException(msg.toString());
2293 }
2294 else {
2295 return list.get(0);
2296 }
2297 }
2298
2299 public MBMessage findByUserId_Last(long userId,
2300 OrderByComparator orderByComparator)
2301 throws NoSuchMessageException, SystemException {
2302 int count = countByUserId(userId);
2303
2304 List<MBMessage> list = findByUserId(userId, count - 1, count,
2305 orderByComparator);
2306
2307 if (list.isEmpty()) {
2308 StringBundler msg = new StringBundler(4);
2309
2310 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2311
2312 msg.append("userId=");
2313 msg.append(userId);
2314
2315 msg.append(StringPool.CLOSE_CURLY_BRACE);
2316
2317 throw new NoSuchMessageException(msg.toString());
2318 }
2319 else {
2320 return list.get(0);
2321 }
2322 }
2323
2324 public MBMessage[] findByUserId_PrevAndNext(long messageId, long userId,
2325 OrderByComparator orderByComparator)
2326 throws NoSuchMessageException, SystemException {
2327 MBMessage mbMessage = findByPrimaryKey(messageId);
2328
2329 Session session = null;
2330
2331 try {
2332 session = openSession();
2333
2334 MBMessage[] array = new MBMessageImpl[3];
2335
2336 array[0] = getByUserId_PrevAndNext(session, mbMessage, userId,
2337 orderByComparator, true);
2338
2339 array[1] = mbMessage;
2340
2341 array[2] = getByUserId_PrevAndNext(session, mbMessage, userId,
2342 orderByComparator, false);
2343
2344 return array;
2345 }
2346 catch (Exception e) {
2347 throw processException(e);
2348 }
2349 finally {
2350 closeSession(session);
2351 }
2352 }
2353
2354 protected MBMessage getByUserId_PrevAndNext(Session session,
2355 MBMessage mbMessage, long userId, OrderByComparator orderByComparator,
2356 boolean previous) {
2357 StringBundler query = null;
2358
2359 if (orderByComparator != null) {
2360 query = new StringBundler(6 +
2361 (orderByComparator.getOrderByFields().length * 6));
2362 }
2363 else {
2364 query = new StringBundler(3);
2365 }
2366
2367 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
2368
2369 query.append(_FINDER_COLUMN_USERID_USERID_2);
2370
2371 if (orderByComparator != null) {
2372 String[] orderByFields = orderByComparator.getOrderByFields();
2373
2374 if (orderByFields.length > 0) {
2375 query.append(WHERE_AND);
2376 }
2377
2378 for (int i = 0; i < orderByFields.length; i++) {
2379 query.append(_ORDER_BY_ENTITY_ALIAS);
2380 query.append(orderByFields[i]);
2381
2382 if ((i + 1) < orderByFields.length) {
2383 if (orderByComparator.isAscending() ^ previous) {
2384 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2385 }
2386 else {
2387 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2388 }
2389 }
2390 else {
2391 if (orderByComparator.isAscending() ^ previous) {
2392 query.append(WHERE_GREATER_THAN);
2393 }
2394 else {
2395 query.append(WHERE_LESSER_THAN);
2396 }
2397 }
2398 }
2399
2400 query.append(ORDER_BY_CLAUSE);
2401
2402 for (int i = 0; i < orderByFields.length; i++) {
2403 query.append(_ORDER_BY_ENTITY_ALIAS);
2404 query.append(orderByFields[i]);
2405
2406 if ((i + 1) < orderByFields.length) {
2407 if (orderByComparator.isAscending() ^ previous) {
2408 query.append(ORDER_BY_ASC_HAS_NEXT);
2409 }
2410 else {
2411 query.append(ORDER_BY_DESC_HAS_NEXT);
2412 }
2413 }
2414 else {
2415 if (orderByComparator.isAscending() ^ previous) {
2416 query.append(ORDER_BY_ASC);
2417 }
2418 else {
2419 query.append(ORDER_BY_DESC);
2420 }
2421 }
2422 }
2423 }
2424
2425 else {
2426 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
2427 }
2428
2429 String sql = query.toString();
2430
2431 Query q = session.createQuery(sql);
2432
2433 q.setFirstResult(0);
2434 q.setMaxResults(2);
2435
2436 QueryPos qPos = QueryPos.getInstance(q);
2437
2438 qPos.add(userId);
2439
2440 if (orderByComparator != null) {
2441 Object[] values = orderByComparator.getOrderByValues(mbMessage);
2442
2443 for (Object value : values) {
2444 qPos.add(value);
2445 }
2446 }
2447
2448 List<MBMessage> list = q.list();
2449
2450 if (list.size() == 2) {
2451 return list.get(1);
2452 }
2453 else {
2454 return null;
2455 }
2456 }
2457
2458 public List<MBMessage> findByG_U(long groupId, long userId)
2459 throws SystemException {
2460 return findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2461 null);
2462 }
2463
2464 public List<MBMessage> findByG_U(long groupId, long userId, int start,
2465 int end) throws SystemException {
2466 return findByG_U(groupId, userId, start, end, null);
2467 }
2468
2469 public List<MBMessage> findByG_U(long groupId, long userId, int start,
2470 int end, OrderByComparator orderByComparator) throws SystemException {
2471 Object[] finderArgs = new Object[] {
2472 new Long(groupId), new Long(userId),
2473
2474 String.valueOf(start), String.valueOf(end),
2475 String.valueOf(orderByComparator)
2476 };
2477
2478 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_U,
2479 finderArgs, this);
2480
2481 if (list == null) {
2482 Session session = null;
2483
2484 try {
2485 session = openSession();
2486
2487 StringBundler query = null;
2488
2489 if (orderByComparator != null) {
2490 query = new StringBundler(4 +
2491 (orderByComparator.getOrderByFields().length * 3));
2492 }
2493 else {
2494 query = new StringBundler(4);
2495 }
2496
2497 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
2498
2499 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2500
2501 query.append(_FINDER_COLUMN_G_U_USERID_2);
2502
2503 if (orderByComparator != null) {
2504 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2505 orderByComparator);
2506 }
2507
2508 else {
2509 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
2510 }
2511
2512 String sql = query.toString();
2513
2514 Query q = session.createQuery(sql);
2515
2516 QueryPos qPos = QueryPos.getInstance(q);
2517
2518 qPos.add(groupId);
2519
2520 qPos.add(userId);
2521
2522 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
2523 end);
2524 }
2525 catch (Exception e) {
2526 throw processException(e);
2527 }
2528 finally {
2529 if (list == null) {
2530 list = new ArrayList<MBMessage>();
2531 }
2532
2533 cacheResult(list);
2534
2535 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_U, finderArgs,
2536 list);
2537
2538 closeSession(session);
2539 }
2540 }
2541
2542 return list;
2543 }
2544
2545 public MBMessage findByG_U_First(long groupId, long userId,
2546 OrderByComparator orderByComparator)
2547 throws NoSuchMessageException, SystemException {
2548 List<MBMessage> list = findByG_U(groupId, userId, 0, 1,
2549 orderByComparator);
2550
2551 if (list.isEmpty()) {
2552 StringBundler msg = new StringBundler(6);
2553
2554 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2555
2556 msg.append("groupId=");
2557 msg.append(groupId);
2558
2559 msg.append(", userId=");
2560 msg.append(userId);
2561
2562 msg.append(StringPool.CLOSE_CURLY_BRACE);
2563
2564 throw new NoSuchMessageException(msg.toString());
2565 }
2566 else {
2567 return list.get(0);
2568 }
2569 }
2570
2571 public MBMessage findByG_U_Last(long groupId, long userId,
2572 OrderByComparator orderByComparator)
2573 throws NoSuchMessageException, SystemException {
2574 int count = countByG_U(groupId, userId);
2575
2576 List<MBMessage> list = findByG_U(groupId, userId, count - 1, count,
2577 orderByComparator);
2578
2579 if (list.isEmpty()) {
2580 StringBundler msg = new StringBundler(6);
2581
2582 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2583
2584 msg.append("groupId=");
2585 msg.append(groupId);
2586
2587 msg.append(", userId=");
2588 msg.append(userId);
2589
2590 msg.append(StringPool.CLOSE_CURLY_BRACE);
2591
2592 throw new NoSuchMessageException(msg.toString());
2593 }
2594 else {
2595 return list.get(0);
2596 }
2597 }
2598
2599 public MBMessage[] findByG_U_PrevAndNext(long messageId, long groupId,
2600 long userId, OrderByComparator orderByComparator)
2601 throws NoSuchMessageException, SystemException {
2602 MBMessage mbMessage = findByPrimaryKey(messageId);
2603
2604 Session session = null;
2605
2606 try {
2607 session = openSession();
2608
2609 MBMessage[] array = new MBMessageImpl[3];
2610
2611 array[0] = getByG_U_PrevAndNext(session, mbMessage, groupId,
2612 userId, orderByComparator, true);
2613
2614 array[1] = mbMessage;
2615
2616 array[2] = getByG_U_PrevAndNext(session, mbMessage, groupId,
2617 userId, orderByComparator, false);
2618
2619 return array;
2620 }
2621 catch (Exception e) {
2622 throw processException(e);
2623 }
2624 finally {
2625 closeSession(session);
2626 }
2627 }
2628
2629 protected MBMessage getByG_U_PrevAndNext(Session session,
2630 MBMessage mbMessage, long groupId, long userId,
2631 OrderByComparator orderByComparator, boolean previous) {
2632 StringBundler query = null;
2633
2634 if (orderByComparator != null) {
2635 query = new StringBundler(6 +
2636 (orderByComparator.getOrderByFields().length * 6));
2637 }
2638 else {
2639 query = new StringBundler(3);
2640 }
2641
2642 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
2643
2644 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2645
2646 query.append(_FINDER_COLUMN_G_U_USERID_2);
2647
2648 if (orderByComparator != null) {
2649 String[] orderByFields = orderByComparator.getOrderByFields();
2650
2651 if (orderByFields.length > 0) {
2652 query.append(WHERE_AND);
2653 }
2654
2655 for (int i = 0; i < orderByFields.length; i++) {
2656 query.append(_ORDER_BY_ENTITY_ALIAS);
2657 query.append(orderByFields[i]);
2658
2659 if ((i + 1) < orderByFields.length) {
2660 if (orderByComparator.isAscending() ^ previous) {
2661 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2662 }
2663 else {
2664 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2665 }
2666 }
2667 else {
2668 if (orderByComparator.isAscending() ^ previous) {
2669 query.append(WHERE_GREATER_THAN);
2670 }
2671 else {
2672 query.append(WHERE_LESSER_THAN);
2673 }
2674 }
2675 }
2676
2677 query.append(ORDER_BY_CLAUSE);
2678
2679 for (int i = 0; i < orderByFields.length; i++) {
2680 query.append(_ORDER_BY_ENTITY_ALIAS);
2681 query.append(orderByFields[i]);
2682
2683 if ((i + 1) < orderByFields.length) {
2684 if (orderByComparator.isAscending() ^ previous) {
2685 query.append(ORDER_BY_ASC_HAS_NEXT);
2686 }
2687 else {
2688 query.append(ORDER_BY_DESC_HAS_NEXT);
2689 }
2690 }
2691 else {
2692 if (orderByComparator.isAscending() ^ previous) {
2693 query.append(ORDER_BY_ASC);
2694 }
2695 else {
2696 query.append(ORDER_BY_DESC);
2697 }
2698 }
2699 }
2700 }
2701
2702 else {
2703 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
2704 }
2705
2706 String sql = query.toString();
2707
2708 Query q = session.createQuery(sql);
2709
2710 q.setFirstResult(0);
2711 q.setMaxResults(2);
2712
2713 QueryPos qPos = QueryPos.getInstance(q);
2714
2715 qPos.add(groupId);
2716
2717 qPos.add(userId);
2718
2719 if (orderByComparator != null) {
2720 Object[] values = orderByComparator.getOrderByValues(mbMessage);
2721
2722 for (Object value : values) {
2723 qPos.add(value);
2724 }
2725 }
2726
2727 List<MBMessage> list = q.list();
2728
2729 if (list.size() == 2) {
2730 return list.get(1);
2731 }
2732 else {
2733 return null;
2734 }
2735 }
2736
2737 public List<MBMessage> filterFindByG_U(long groupId, long userId)
2738 throws SystemException {
2739 return filterFindByG_U(groupId, userId, QueryUtil.ALL_POS,
2740 QueryUtil.ALL_POS, null);
2741 }
2742
2743 public List<MBMessage> filterFindByG_U(long groupId, long userId,
2744 int start, int end) throws SystemException {
2745 return filterFindByG_U(groupId, userId, start, end, null);
2746 }
2747
2748 public List<MBMessage> filterFindByG_U(long groupId, long userId,
2749 int start, int end, OrderByComparator orderByComparator)
2750 throws SystemException {
2751 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2752 return findByG_U(groupId, userId, start, end, orderByComparator);
2753 }
2754
2755 Session session = null;
2756
2757 try {
2758 session = openSession();
2759
2760 StringBundler query = null;
2761
2762 if (orderByComparator != null) {
2763 query = new StringBundler(4 +
2764 (orderByComparator.getOrderByFields().length * 3));
2765 }
2766 else {
2767 query = new StringBundler(4);
2768 }
2769
2770 query.append(_FILTER_SQL_SELECT_MBMESSAGE_WHERE);
2771
2772 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2773
2774 query.append(_FINDER_COLUMN_G_U_USERID_2);
2775
2776 if (orderByComparator != null) {
2777 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2778 orderByComparator);
2779 }
2780
2781 else {
2782 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
2783 }
2784
2785 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2786 MBMessage.class.getName(), _FILTER_COLUMN_MESSAGEID,
2787 _FILTER_COLUMN_USERID, groupId);
2788
2789 SQLQuery q = session.createSQLQuery(sql);
2790
2791 q.addEntity(_FILTER_ENTITY_ALIAS, MBMessageImpl.class);
2792
2793 QueryPos qPos = QueryPos.getInstance(q);
2794
2795 qPos.add(groupId);
2796
2797 qPos.add(userId);
2798
2799 return (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end);
2800 }
2801 catch (Exception e) {
2802 throw processException(e);
2803 }
2804 finally {
2805 closeSession(session);
2806 }
2807 }
2808
2809 public List<MBMessage> findByG_C(long groupId, long categoryId)
2810 throws SystemException {
2811 return findByG_C(groupId, categoryId, QueryUtil.ALL_POS,
2812 QueryUtil.ALL_POS, null);
2813 }
2814
2815 public List<MBMessage> findByG_C(long groupId, long categoryId, int start,
2816 int end) throws SystemException {
2817 return findByG_C(groupId, categoryId, start, end, null);
2818 }
2819
2820 public List<MBMessage> findByG_C(long groupId, long categoryId, int start,
2821 int end, OrderByComparator orderByComparator) throws SystemException {
2822 Object[] finderArgs = new Object[] {
2823 new Long(groupId), new Long(categoryId),
2824
2825 String.valueOf(start), String.valueOf(end),
2826 String.valueOf(orderByComparator)
2827 };
2828
2829 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_C,
2830 finderArgs, this);
2831
2832 if (list == null) {
2833 Session session = null;
2834
2835 try {
2836 session = openSession();
2837
2838 StringBundler query = null;
2839
2840 if (orderByComparator != null) {
2841 query = new StringBundler(4 +
2842 (orderByComparator.getOrderByFields().length * 3));
2843 }
2844 else {
2845 query = new StringBundler(4);
2846 }
2847
2848 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
2849
2850 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
2851
2852 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
2853
2854 if (orderByComparator != null) {
2855 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2856 orderByComparator);
2857 }
2858
2859 else {
2860 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
2861 }
2862
2863 String sql = query.toString();
2864
2865 Query q = session.createQuery(sql);
2866
2867 QueryPos qPos = QueryPos.getInstance(q);
2868
2869 qPos.add(groupId);
2870
2871 qPos.add(categoryId);
2872
2873 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
2874 end);
2875 }
2876 catch (Exception e) {
2877 throw processException(e);
2878 }
2879 finally {
2880 if (list == null) {
2881 list = new ArrayList<MBMessage>();
2882 }
2883
2884 cacheResult(list);
2885
2886 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_C, finderArgs,
2887 list);
2888
2889 closeSession(session);
2890 }
2891 }
2892
2893 return list;
2894 }
2895
2896 public MBMessage findByG_C_First(long groupId, long categoryId,
2897 OrderByComparator orderByComparator)
2898 throws NoSuchMessageException, SystemException {
2899 List<MBMessage> list = findByG_C(groupId, categoryId, 0, 1,
2900 orderByComparator);
2901
2902 if (list.isEmpty()) {
2903 StringBundler msg = new StringBundler(6);
2904
2905 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2906
2907 msg.append("groupId=");
2908 msg.append(groupId);
2909
2910 msg.append(", categoryId=");
2911 msg.append(categoryId);
2912
2913 msg.append(StringPool.CLOSE_CURLY_BRACE);
2914
2915 throw new NoSuchMessageException(msg.toString());
2916 }
2917 else {
2918 return list.get(0);
2919 }
2920 }
2921
2922 public MBMessage findByG_C_Last(long groupId, long categoryId,
2923 OrderByComparator orderByComparator)
2924 throws NoSuchMessageException, SystemException {
2925 int count = countByG_C(groupId, categoryId);
2926
2927 List<MBMessage> list = findByG_C(groupId, categoryId, count - 1, count,
2928 orderByComparator);
2929
2930 if (list.isEmpty()) {
2931 StringBundler msg = new StringBundler(6);
2932
2933 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2934
2935 msg.append("groupId=");
2936 msg.append(groupId);
2937
2938 msg.append(", categoryId=");
2939 msg.append(categoryId);
2940
2941 msg.append(StringPool.CLOSE_CURLY_BRACE);
2942
2943 throw new NoSuchMessageException(msg.toString());
2944 }
2945 else {
2946 return list.get(0);
2947 }
2948 }
2949
2950 public MBMessage[] findByG_C_PrevAndNext(long messageId, long groupId,
2951 long categoryId, OrderByComparator orderByComparator)
2952 throws NoSuchMessageException, SystemException {
2953 MBMessage mbMessage = findByPrimaryKey(messageId);
2954
2955 Session session = null;
2956
2957 try {
2958 session = openSession();
2959
2960 MBMessage[] array = new MBMessageImpl[3];
2961
2962 array[0] = getByG_C_PrevAndNext(session, mbMessage, groupId,
2963 categoryId, orderByComparator, true);
2964
2965 array[1] = mbMessage;
2966
2967 array[2] = getByG_C_PrevAndNext(session, mbMessage, groupId,
2968 categoryId, orderByComparator, false);
2969
2970 return array;
2971 }
2972 catch (Exception e) {
2973 throw processException(e);
2974 }
2975 finally {
2976 closeSession(session);
2977 }
2978 }
2979
2980 protected MBMessage getByG_C_PrevAndNext(Session session,
2981 MBMessage mbMessage, long groupId, long categoryId,
2982 OrderByComparator orderByComparator, boolean previous) {
2983 StringBundler query = null;
2984
2985 if (orderByComparator != null) {
2986 query = new StringBundler(6 +
2987 (orderByComparator.getOrderByFields().length * 6));
2988 }
2989 else {
2990 query = new StringBundler(3);
2991 }
2992
2993 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
2994
2995 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
2996
2997 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
2998
2999 if (orderByComparator != null) {
3000 String[] orderByFields = orderByComparator.getOrderByFields();
3001
3002 if (orderByFields.length > 0) {
3003 query.append(WHERE_AND);
3004 }
3005
3006 for (int i = 0; i < orderByFields.length; i++) {
3007 query.append(_ORDER_BY_ENTITY_ALIAS);
3008 query.append(orderByFields[i]);
3009
3010 if ((i + 1) < orderByFields.length) {
3011 if (orderByComparator.isAscending() ^ previous) {
3012 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3013 }
3014 else {
3015 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3016 }
3017 }
3018 else {
3019 if (orderByComparator.isAscending() ^ previous) {
3020 query.append(WHERE_GREATER_THAN);
3021 }
3022 else {
3023 query.append(WHERE_LESSER_THAN);
3024 }
3025 }
3026 }
3027
3028 query.append(ORDER_BY_CLAUSE);
3029
3030 for (int i = 0; i < orderByFields.length; i++) {
3031 query.append(_ORDER_BY_ENTITY_ALIAS);
3032 query.append(orderByFields[i]);
3033
3034 if ((i + 1) < orderByFields.length) {
3035 if (orderByComparator.isAscending() ^ previous) {
3036 query.append(ORDER_BY_ASC_HAS_NEXT);
3037 }
3038 else {
3039 query.append(ORDER_BY_DESC_HAS_NEXT);
3040 }
3041 }
3042 else {
3043 if (orderByComparator.isAscending() ^ previous) {
3044 query.append(ORDER_BY_ASC);
3045 }
3046 else {
3047 query.append(ORDER_BY_DESC);
3048 }
3049 }
3050 }
3051 }
3052
3053 else {
3054 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
3055 }
3056
3057 String sql = query.toString();
3058
3059 Query q = session.createQuery(sql);
3060
3061 q.setFirstResult(0);
3062 q.setMaxResults(2);
3063
3064 QueryPos qPos = QueryPos.getInstance(q);
3065
3066 qPos.add(groupId);
3067
3068 qPos.add(categoryId);
3069
3070 if (orderByComparator != null) {
3071 Object[] values = orderByComparator.getOrderByValues(mbMessage);
3072
3073 for (Object value : values) {
3074 qPos.add(value);
3075 }
3076 }
3077
3078 List<MBMessage> list = q.list();
3079
3080 if (list.size() == 2) {
3081 return list.get(1);
3082 }
3083 else {
3084 return null;
3085 }
3086 }
3087
3088 public List<MBMessage> filterFindByG_C(long groupId, long categoryId)
3089 throws SystemException {
3090 return filterFindByG_C(groupId, categoryId, QueryUtil.ALL_POS,
3091 QueryUtil.ALL_POS, null);
3092 }
3093
3094 public List<MBMessage> filterFindByG_C(long groupId, long categoryId,
3095 int start, int end) throws SystemException {
3096 return filterFindByG_C(groupId, categoryId, start, end, null);
3097 }
3098
3099 public List<MBMessage> filterFindByG_C(long groupId, long categoryId,
3100 int start, int end, OrderByComparator orderByComparator)
3101 throws SystemException {
3102 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3103 return findByG_C(groupId, categoryId, start, end, orderByComparator);
3104 }
3105
3106 Session session = null;
3107
3108 try {
3109 session = openSession();
3110
3111 StringBundler query = null;
3112
3113 if (orderByComparator != null) {
3114 query = new StringBundler(4 +
3115 (orderByComparator.getOrderByFields().length * 3));
3116 }
3117 else {
3118 query = new StringBundler(4);
3119 }
3120
3121 query.append(_FILTER_SQL_SELECT_MBMESSAGE_WHERE);
3122
3123 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
3124
3125 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
3126
3127 if (orderByComparator != null) {
3128 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3129 orderByComparator);
3130 }
3131
3132 else {
3133 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
3134 }
3135
3136 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3137 MBMessage.class.getName(), _FILTER_COLUMN_MESSAGEID,
3138 _FILTER_COLUMN_USERID, groupId);
3139
3140 SQLQuery q = session.createSQLQuery(sql);
3141
3142 q.addEntity(_FILTER_ENTITY_ALIAS, MBMessageImpl.class);
3143
3144 QueryPos qPos = QueryPos.getInstance(q);
3145
3146 qPos.add(groupId);
3147
3148 qPos.add(categoryId);
3149
3150 return (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end);
3151 }
3152 catch (Exception e) {
3153 throw processException(e);
3154 }
3155 finally {
3156 closeSession(session);
3157 }
3158 }
3159
3160 public List<MBMessage> findByG_S(long groupId, int status)
3161 throws SystemException {
3162 return findByG_S(groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3163 null);
3164 }
3165
3166 public List<MBMessage> findByG_S(long groupId, int status, int start,
3167 int end) throws SystemException {
3168 return findByG_S(groupId, status, start, end, null);
3169 }
3170
3171 public List<MBMessage> findByG_S(long groupId, int status, int start,
3172 int end, OrderByComparator orderByComparator) throws SystemException {
3173 Object[] finderArgs = new Object[] {
3174 new Long(groupId), new Integer(status),
3175
3176 String.valueOf(start), String.valueOf(end),
3177 String.valueOf(orderByComparator)
3178 };
3179
3180 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_S,
3181 finderArgs, this);
3182
3183 if (list == null) {
3184 Session session = null;
3185
3186 try {
3187 session = openSession();
3188
3189 StringBundler query = null;
3190
3191 if (orderByComparator != null) {
3192 query = new StringBundler(4 +
3193 (orderByComparator.getOrderByFields().length * 3));
3194 }
3195 else {
3196 query = new StringBundler(4);
3197 }
3198
3199 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
3200
3201 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3202
3203 query.append(_FINDER_COLUMN_G_S_STATUS_2);
3204
3205 if (orderByComparator != null) {
3206 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3207 orderByComparator);
3208 }
3209
3210 else {
3211 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
3212 }
3213
3214 String sql = query.toString();
3215
3216 Query q = session.createQuery(sql);
3217
3218 QueryPos qPos = QueryPos.getInstance(q);
3219
3220 qPos.add(groupId);
3221
3222 qPos.add(status);
3223
3224 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
3225 end);
3226 }
3227 catch (Exception e) {
3228 throw processException(e);
3229 }
3230 finally {
3231 if (list == null) {
3232 list = new ArrayList<MBMessage>();
3233 }
3234
3235 cacheResult(list);
3236
3237 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_S, finderArgs,
3238 list);
3239
3240 closeSession(session);
3241 }
3242 }
3243
3244 return list;
3245 }
3246
3247 public MBMessage findByG_S_First(long groupId, int status,
3248 OrderByComparator orderByComparator)
3249 throws NoSuchMessageException, SystemException {
3250 List<MBMessage> list = findByG_S(groupId, status, 0, 1,
3251 orderByComparator);
3252
3253 if (list.isEmpty()) {
3254 StringBundler msg = new StringBundler(6);
3255
3256 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3257
3258 msg.append("groupId=");
3259 msg.append(groupId);
3260
3261 msg.append(", status=");
3262 msg.append(status);
3263
3264 msg.append(StringPool.CLOSE_CURLY_BRACE);
3265
3266 throw new NoSuchMessageException(msg.toString());
3267 }
3268 else {
3269 return list.get(0);
3270 }
3271 }
3272
3273 public MBMessage findByG_S_Last(long groupId, int status,
3274 OrderByComparator orderByComparator)
3275 throws NoSuchMessageException, SystemException {
3276 int count = countByG_S(groupId, status);
3277
3278 List<MBMessage> list = findByG_S(groupId, status, count - 1, count,
3279 orderByComparator);
3280
3281 if (list.isEmpty()) {
3282 StringBundler msg = new StringBundler(6);
3283
3284 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3285
3286 msg.append("groupId=");
3287 msg.append(groupId);
3288
3289 msg.append(", status=");
3290 msg.append(status);
3291
3292 msg.append(StringPool.CLOSE_CURLY_BRACE);
3293
3294 throw new NoSuchMessageException(msg.toString());
3295 }
3296 else {
3297 return list.get(0);
3298 }
3299 }
3300
3301 public MBMessage[] findByG_S_PrevAndNext(long messageId, long groupId,
3302 int status, OrderByComparator orderByComparator)
3303 throws NoSuchMessageException, SystemException {
3304 MBMessage mbMessage = findByPrimaryKey(messageId);
3305
3306 Session session = null;
3307
3308 try {
3309 session = openSession();
3310
3311 MBMessage[] array = new MBMessageImpl[3];
3312
3313 array[0] = getByG_S_PrevAndNext(session, mbMessage, groupId,
3314 status, orderByComparator, true);
3315
3316 array[1] = mbMessage;
3317
3318 array[2] = getByG_S_PrevAndNext(session, mbMessage, groupId,
3319 status, orderByComparator, false);
3320
3321 return array;
3322 }
3323 catch (Exception e) {
3324 throw processException(e);
3325 }
3326 finally {
3327 closeSession(session);
3328 }
3329 }
3330
3331 protected MBMessage getByG_S_PrevAndNext(Session session,
3332 MBMessage mbMessage, long groupId, int status,
3333 OrderByComparator orderByComparator, boolean previous) {
3334 StringBundler query = null;
3335
3336 if (orderByComparator != null) {
3337 query = new StringBundler(6 +
3338 (orderByComparator.getOrderByFields().length * 6));
3339 }
3340 else {
3341 query = new StringBundler(3);
3342 }
3343
3344 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
3345
3346 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3347
3348 query.append(_FINDER_COLUMN_G_S_STATUS_2);
3349
3350 if (orderByComparator != null) {
3351 String[] orderByFields = orderByComparator.getOrderByFields();
3352
3353 if (orderByFields.length > 0) {
3354 query.append(WHERE_AND);
3355 }
3356
3357 for (int i = 0; i < orderByFields.length; i++) {
3358 query.append(_ORDER_BY_ENTITY_ALIAS);
3359 query.append(orderByFields[i]);
3360
3361 if ((i + 1) < orderByFields.length) {
3362 if (orderByComparator.isAscending() ^ previous) {
3363 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3364 }
3365 else {
3366 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3367 }
3368 }
3369 else {
3370 if (orderByComparator.isAscending() ^ previous) {
3371 query.append(WHERE_GREATER_THAN);
3372 }
3373 else {
3374 query.append(WHERE_LESSER_THAN);
3375 }
3376 }
3377 }
3378
3379 query.append(ORDER_BY_CLAUSE);
3380
3381 for (int i = 0; i < orderByFields.length; i++) {
3382 query.append(_ORDER_BY_ENTITY_ALIAS);
3383 query.append(orderByFields[i]);
3384
3385 if ((i + 1) < orderByFields.length) {
3386 if (orderByComparator.isAscending() ^ previous) {
3387 query.append(ORDER_BY_ASC_HAS_NEXT);
3388 }
3389 else {
3390 query.append(ORDER_BY_DESC_HAS_NEXT);
3391 }
3392 }
3393 else {
3394 if (orderByComparator.isAscending() ^ previous) {
3395 query.append(ORDER_BY_ASC);
3396 }
3397 else {
3398 query.append(ORDER_BY_DESC);
3399 }
3400 }
3401 }
3402 }
3403
3404 else {
3405 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
3406 }
3407
3408 String sql = query.toString();
3409
3410 Query q = session.createQuery(sql);
3411
3412 q.setFirstResult(0);
3413 q.setMaxResults(2);
3414
3415 QueryPos qPos = QueryPos.getInstance(q);
3416
3417 qPos.add(groupId);
3418
3419 qPos.add(status);
3420
3421 if (orderByComparator != null) {
3422 Object[] values = orderByComparator.getOrderByValues(mbMessage);
3423
3424 for (Object value : values) {
3425 qPos.add(value);
3426 }
3427 }
3428
3429 List<MBMessage> list = q.list();
3430
3431 if (list.size() == 2) {
3432 return list.get(1);
3433 }
3434 else {
3435 return null;
3436 }
3437 }
3438
3439 public List<MBMessage> filterFindByG_S(long groupId, int status)
3440 throws SystemException {
3441 return filterFindByG_S(groupId, status, QueryUtil.ALL_POS,
3442 QueryUtil.ALL_POS, null);
3443 }
3444
3445 public List<MBMessage> filterFindByG_S(long groupId, int status, int start,
3446 int end) throws SystemException {
3447 return filterFindByG_S(groupId, status, start, end, null);
3448 }
3449
3450 public List<MBMessage> filterFindByG_S(long groupId, int status, int start,
3451 int end, OrderByComparator orderByComparator) throws SystemException {
3452 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3453 return findByG_S(groupId, status, start, end, orderByComparator);
3454 }
3455
3456 Session session = null;
3457
3458 try {
3459 session = openSession();
3460
3461 StringBundler query = null;
3462
3463 if (orderByComparator != null) {
3464 query = new StringBundler(4 +
3465 (orderByComparator.getOrderByFields().length * 3));
3466 }
3467 else {
3468 query = new StringBundler(4);
3469 }
3470
3471 query.append(_FILTER_SQL_SELECT_MBMESSAGE_WHERE);
3472
3473 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3474
3475 query.append(_FINDER_COLUMN_G_S_STATUS_2);
3476
3477 if (orderByComparator != null) {
3478 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3479 orderByComparator);
3480 }
3481
3482 else {
3483 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
3484 }
3485
3486 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3487 MBMessage.class.getName(), _FILTER_COLUMN_MESSAGEID,
3488 _FILTER_COLUMN_USERID, groupId);
3489
3490 SQLQuery q = session.createSQLQuery(sql);
3491
3492 q.addEntity(_FILTER_ENTITY_ALIAS, MBMessageImpl.class);
3493
3494 QueryPos qPos = QueryPos.getInstance(q);
3495
3496 qPos.add(groupId);
3497
3498 qPos.add(status);
3499
3500 return (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end);
3501 }
3502 catch (Exception e) {
3503 throw processException(e);
3504 }
3505 finally {
3506 closeSession(session);
3507 }
3508 }
3509
3510 public List<MBMessage> findByC_S(long companyId, int status)
3511 throws SystemException {
3512 return findByC_S(companyId, status, QueryUtil.ALL_POS,
3513 QueryUtil.ALL_POS, null);
3514 }
3515
3516 public List<MBMessage> findByC_S(long companyId, int status, int start,
3517 int end) throws SystemException {
3518 return findByC_S(companyId, status, start, end, null);
3519 }
3520
3521 public List<MBMessage> findByC_S(long companyId, int status, int start,
3522 int end, OrderByComparator orderByComparator) throws SystemException {
3523 Object[] finderArgs = new Object[] {
3524 new Long(companyId), new Integer(status),
3525
3526 String.valueOf(start), String.valueOf(end),
3527 String.valueOf(orderByComparator)
3528 };
3529
3530 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_S,
3531 finderArgs, this);
3532
3533 if (list == null) {
3534 Session session = null;
3535
3536 try {
3537 session = openSession();
3538
3539 StringBundler query = null;
3540
3541 if (orderByComparator != null) {
3542 query = new StringBundler(4 +
3543 (orderByComparator.getOrderByFields().length * 3));
3544 }
3545 else {
3546 query = new StringBundler(4);
3547 }
3548
3549 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
3550
3551 query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
3552
3553 query.append(_FINDER_COLUMN_C_S_STATUS_2);
3554
3555 if (orderByComparator != null) {
3556 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3557 orderByComparator);
3558 }
3559
3560 else {
3561 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
3562 }
3563
3564 String sql = query.toString();
3565
3566 Query q = session.createQuery(sql);
3567
3568 QueryPos qPos = QueryPos.getInstance(q);
3569
3570 qPos.add(companyId);
3571
3572 qPos.add(status);
3573
3574 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
3575 end);
3576 }
3577 catch (Exception e) {
3578 throw processException(e);
3579 }
3580 finally {
3581 if (list == null) {
3582 list = new ArrayList<MBMessage>();
3583 }
3584
3585 cacheResult(list);
3586
3587 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_S, finderArgs,
3588 list);
3589
3590 closeSession(session);
3591 }
3592 }
3593
3594 return list;
3595 }
3596
3597 public MBMessage findByC_S_First(long companyId, int status,
3598 OrderByComparator orderByComparator)
3599 throws NoSuchMessageException, SystemException {
3600 List<MBMessage> list = findByC_S(companyId, status, 0, 1,
3601 orderByComparator);
3602
3603 if (list.isEmpty()) {
3604 StringBundler msg = new StringBundler(6);
3605
3606 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3607
3608 msg.append("companyId=");
3609 msg.append(companyId);
3610
3611 msg.append(", status=");
3612 msg.append(status);
3613
3614 msg.append(StringPool.CLOSE_CURLY_BRACE);
3615
3616 throw new NoSuchMessageException(msg.toString());
3617 }
3618 else {
3619 return list.get(0);
3620 }
3621 }
3622
3623 public MBMessage findByC_S_Last(long companyId, int status,
3624 OrderByComparator orderByComparator)
3625 throws NoSuchMessageException, SystemException {
3626 int count = countByC_S(companyId, status);
3627
3628 List<MBMessage> list = findByC_S(companyId, status, count - 1, count,
3629 orderByComparator);
3630
3631 if (list.isEmpty()) {
3632 StringBundler msg = new StringBundler(6);
3633
3634 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3635
3636 msg.append("companyId=");
3637 msg.append(companyId);
3638
3639 msg.append(", status=");
3640 msg.append(status);
3641
3642 msg.append(StringPool.CLOSE_CURLY_BRACE);
3643
3644 throw new NoSuchMessageException(msg.toString());
3645 }
3646 else {
3647 return list.get(0);
3648 }
3649 }
3650
3651 public MBMessage[] findByC_S_PrevAndNext(long messageId, long companyId,
3652 int status, OrderByComparator orderByComparator)
3653 throws NoSuchMessageException, SystemException {
3654 MBMessage mbMessage = findByPrimaryKey(messageId);
3655
3656 Session session = null;
3657
3658 try {
3659 session = openSession();
3660
3661 MBMessage[] array = new MBMessageImpl[3];
3662
3663 array[0] = getByC_S_PrevAndNext(session, mbMessage, companyId,
3664 status, orderByComparator, true);
3665
3666 array[1] = mbMessage;
3667
3668 array[2] = getByC_S_PrevAndNext(session, mbMessage, companyId,
3669 status, orderByComparator, false);
3670
3671 return array;
3672 }
3673 catch (Exception e) {
3674 throw processException(e);
3675 }
3676 finally {
3677 closeSession(session);
3678 }
3679 }
3680
3681 protected MBMessage getByC_S_PrevAndNext(Session session,
3682 MBMessage mbMessage, long companyId, int status,
3683 OrderByComparator orderByComparator, boolean previous) {
3684 StringBundler query = null;
3685
3686 if (orderByComparator != null) {
3687 query = new StringBundler(6 +
3688 (orderByComparator.getOrderByFields().length * 6));
3689 }
3690 else {
3691 query = new StringBundler(3);
3692 }
3693
3694 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
3695
3696 query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
3697
3698 query.append(_FINDER_COLUMN_C_S_STATUS_2);
3699
3700 if (orderByComparator != null) {
3701 String[] orderByFields = orderByComparator.getOrderByFields();
3702
3703 if (orderByFields.length > 0) {
3704 query.append(WHERE_AND);
3705 }
3706
3707 for (int i = 0; i < orderByFields.length; i++) {
3708 query.append(_ORDER_BY_ENTITY_ALIAS);
3709 query.append(orderByFields[i]);
3710
3711 if ((i + 1) < orderByFields.length) {
3712 if (orderByComparator.isAscending() ^ previous) {
3713 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3714 }
3715 else {
3716 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3717 }
3718 }
3719 else {
3720 if (orderByComparator.isAscending() ^ previous) {
3721 query.append(WHERE_GREATER_THAN);
3722 }
3723 else {
3724 query.append(WHERE_LESSER_THAN);
3725 }
3726 }
3727 }
3728
3729 query.append(ORDER_BY_CLAUSE);
3730
3731 for (int i = 0; i < orderByFields.length; i++) {
3732 query.append(_ORDER_BY_ENTITY_ALIAS);
3733 query.append(orderByFields[i]);
3734
3735 if ((i + 1) < orderByFields.length) {
3736 if (orderByComparator.isAscending() ^ previous) {
3737 query.append(ORDER_BY_ASC_HAS_NEXT);
3738 }
3739 else {
3740 query.append(ORDER_BY_DESC_HAS_NEXT);
3741 }
3742 }
3743 else {
3744 if (orderByComparator.isAscending() ^ previous) {
3745 query.append(ORDER_BY_ASC);
3746 }
3747 else {
3748 query.append(ORDER_BY_DESC);
3749 }
3750 }
3751 }
3752 }
3753
3754 else {
3755 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
3756 }
3757
3758 String sql = query.toString();
3759
3760 Query q = session.createQuery(sql);
3761
3762 q.setFirstResult(0);
3763 q.setMaxResults(2);
3764
3765 QueryPos qPos = QueryPos.getInstance(q);
3766
3767 qPos.add(companyId);
3768
3769 qPos.add(status);
3770
3771 if (orderByComparator != null) {
3772 Object[] values = orderByComparator.getOrderByValues(mbMessage);
3773
3774 for (Object value : values) {
3775 qPos.add(value);
3776 }
3777 }
3778
3779 List<MBMessage> list = q.list();
3780
3781 if (list.size() == 2) {
3782 return list.get(1);
3783 }
3784 else {
3785 return null;
3786 }
3787 }
3788
3789 public List<MBMessage> findByC_C(long classNameId, long classPK)
3790 throws SystemException {
3791 return findByC_C(classNameId, classPK, QueryUtil.ALL_POS,
3792 QueryUtil.ALL_POS, null);
3793 }
3794
3795 public List<MBMessage> findByC_C(long classNameId, long classPK, int start,
3796 int end) throws SystemException {
3797 return findByC_C(classNameId, classPK, start, end, null);
3798 }
3799
3800 public List<MBMessage> findByC_C(long classNameId, long classPK, int start,
3801 int end, OrderByComparator orderByComparator) throws SystemException {
3802 Object[] finderArgs = new Object[] {
3803 new Long(classNameId), new Long(classPK),
3804
3805 String.valueOf(start), String.valueOf(end),
3806 String.valueOf(orderByComparator)
3807 };
3808
3809 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_C,
3810 finderArgs, this);
3811
3812 if (list == null) {
3813 Session session = null;
3814
3815 try {
3816 session = openSession();
3817
3818 StringBundler query = null;
3819
3820 if (orderByComparator != null) {
3821 query = new StringBundler(4 +
3822 (orderByComparator.getOrderByFields().length * 3));
3823 }
3824 else {
3825 query = new StringBundler(4);
3826 }
3827
3828 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
3829
3830 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3831
3832 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
3833
3834 if (orderByComparator != null) {
3835 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3836 orderByComparator);
3837 }
3838
3839 else {
3840 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
3841 }
3842
3843 String sql = query.toString();
3844
3845 Query q = session.createQuery(sql);
3846
3847 QueryPos qPos = QueryPos.getInstance(q);
3848
3849 qPos.add(classNameId);
3850
3851 qPos.add(classPK);
3852
3853 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
3854 end);
3855 }
3856 catch (Exception e) {
3857 throw processException(e);
3858 }
3859 finally {
3860 if (list == null) {
3861 list = new ArrayList<MBMessage>();
3862 }
3863
3864 cacheResult(list);
3865
3866 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_C, finderArgs,
3867 list);
3868
3869 closeSession(session);
3870 }
3871 }
3872
3873 return list;
3874 }
3875
3876 public MBMessage findByC_C_First(long classNameId, long classPK,
3877 OrderByComparator orderByComparator)
3878 throws NoSuchMessageException, SystemException {
3879 List<MBMessage> list = findByC_C(classNameId, classPK, 0, 1,
3880 orderByComparator);
3881
3882 if (list.isEmpty()) {
3883 StringBundler msg = new StringBundler(6);
3884
3885 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3886
3887 msg.append("classNameId=");
3888 msg.append(classNameId);
3889
3890 msg.append(", classPK=");
3891 msg.append(classPK);
3892
3893 msg.append(StringPool.CLOSE_CURLY_BRACE);
3894
3895 throw new NoSuchMessageException(msg.toString());
3896 }
3897 else {
3898 return list.get(0);
3899 }
3900 }
3901
3902 public MBMessage findByC_C_Last(long classNameId, long classPK,
3903 OrderByComparator orderByComparator)
3904 throws NoSuchMessageException, SystemException {
3905 int count = countByC_C(classNameId, classPK);
3906
3907 List<MBMessage> list = findByC_C(classNameId, classPK, count - 1,
3908 count, orderByComparator);
3909
3910 if (list.isEmpty()) {
3911 StringBundler msg = new StringBundler(6);
3912
3913 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3914
3915 msg.append("classNameId=");
3916 msg.append(classNameId);
3917
3918 msg.append(", classPK=");
3919 msg.append(classPK);
3920
3921 msg.append(StringPool.CLOSE_CURLY_BRACE);
3922
3923 throw new NoSuchMessageException(msg.toString());
3924 }
3925 else {
3926 return list.get(0);
3927 }
3928 }
3929
3930 public MBMessage[] findByC_C_PrevAndNext(long messageId, long classNameId,
3931 long classPK, OrderByComparator orderByComparator)
3932 throws NoSuchMessageException, SystemException {
3933 MBMessage mbMessage = findByPrimaryKey(messageId);
3934
3935 Session session = null;
3936
3937 try {
3938 session = openSession();
3939
3940 MBMessage[] array = new MBMessageImpl[3];
3941
3942 array[0] = getByC_C_PrevAndNext(session, mbMessage, classNameId,
3943 classPK, orderByComparator, true);
3944
3945 array[1] = mbMessage;
3946
3947 array[2] = getByC_C_PrevAndNext(session, mbMessage, classNameId,
3948 classPK, orderByComparator, false);
3949
3950 return array;
3951 }
3952 catch (Exception e) {
3953 throw processException(e);
3954 }
3955 finally {
3956 closeSession(session);
3957 }
3958 }
3959
3960 protected MBMessage getByC_C_PrevAndNext(Session session,
3961 MBMessage mbMessage, long classNameId, long classPK,
3962 OrderByComparator orderByComparator, boolean previous) {
3963 StringBundler query = null;
3964
3965 if (orderByComparator != null) {
3966 query = new StringBundler(6 +
3967 (orderByComparator.getOrderByFields().length * 6));
3968 }
3969 else {
3970 query = new StringBundler(3);
3971 }
3972
3973 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
3974
3975 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3976
3977 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
3978
3979 if (orderByComparator != null) {
3980 String[] orderByFields = orderByComparator.getOrderByFields();
3981
3982 if (orderByFields.length > 0) {
3983 query.append(WHERE_AND);
3984 }
3985
3986 for (int i = 0; i < orderByFields.length; i++) {
3987 query.append(_ORDER_BY_ENTITY_ALIAS);
3988 query.append(orderByFields[i]);
3989
3990 if ((i + 1) < orderByFields.length) {
3991 if (orderByComparator.isAscending() ^ previous) {
3992 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3993 }
3994 else {
3995 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3996 }
3997 }
3998 else {
3999 if (orderByComparator.isAscending() ^ previous) {
4000 query.append(WHERE_GREATER_THAN);
4001 }
4002 else {
4003 query.append(WHERE_LESSER_THAN);
4004 }
4005 }
4006 }
4007
4008 query.append(ORDER_BY_CLAUSE);
4009
4010 for (int i = 0; i < orderByFields.length; i++) {
4011 query.append(_ORDER_BY_ENTITY_ALIAS);
4012 query.append(orderByFields[i]);
4013
4014 if ((i + 1) < orderByFields.length) {
4015 if (orderByComparator.isAscending() ^ previous) {
4016 query.append(ORDER_BY_ASC_HAS_NEXT);
4017 }
4018 else {
4019 query.append(ORDER_BY_DESC_HAS_NEXT);
4020 }
4021 }
4022 else {
4023 if (orderByComparator.isAscending() ^ previous) {
4024 query.append(ORDER_BY_ASC);
4025 }
4026 else {
4027 query.append(ORDER_BY_DESC);
4028 }
4029 }
4030 }
4031 }
4032
4033 else {
4034 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
4035 }
4036
4037 String sql = query.toString();
4038
4039 Query q = session.createQuery(sql);
4040
4041 q.setFirstResult(0);
4042 q.setMaxResults(2);
4043
4044 QueryPos qPos = QueryPos.getInstance(q);
4045
4046 qPos.add(classNameId);
4047
4048 qPos.add(classPK);
4049
4050 if (orderByComparator != null) {
4051 Object[] values = orderByComparator.getOrderByValues(mbMessage);
4052
4053 for (Object value : values) {
4054 qPos.add(value);
4055 }
4056 }
4057
4058 List<MBMessage> list = q.list();
4059
4060 if (list.size() == 2) {
4061 return list.get(1);
4062 }
4063 else {
4064 return null;
4065 }
4066 }
4067
4068 public List<MBMessage> findByT_P(long threadId, long parentMessageId)
4069 throws SystemException {
4070 return findByT_P(threadId, parentMessageId, QueryUtil.ALL_POS,
4071 QueryUtil.ALL_POS, null);
4072 }
4073
4074 public List<MBMessage> findByT_P(long threadId, long parentMessageId,
4075 int start, int end) throws SystemException {
4076 return findByT_P(threadId, parentMessageId, start, end, null);
4077 }
4078
4079 public List<MBMessage> findByT_P(long threadId, long parentMessageId,
4080 int start, int end, OrderByComparator orderByComparator)
4081 throws SystemException {
4082 Object[] finderArgs = new Object[] {
4083 new Long(threadId), new Long(parentMessageId),
4084
4085 String.valueOf(start), String.valueOf(end),
4086 String.valueOf(orderByComparator)
4087 };
4088
4089 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_T_P,
4090 finderArgs, this);
4091
4092 if (list == null) {
4093 Session session = null;
4094
4095 try {
4096 session = openSession();
4097
4098 StringBundler query = null;
4099
4100 if (orderByComparator != null) {
4101 query = new StringBundler(4 +
4102 (orderByComparator.getOrderByFields().length * 3));
4103 }
4104 else {
4105 query = new StringBundler(4);
4106 }
4107
4108 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
4109
4110 query.append(_FINDER_COLUMN_T_P_THREADID_2);
4111
4112 query.append(_FINDER_COLUMN_T_P_PARENTMESSAGEID_2);
4113
4114 if (orderByComparator != null) {
4115 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4116 orderByComparator);
4117 }
4118
4119 else {
4120 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
4121 }
4122
4123 String sql = query.toString();
4124
4125 Query q = session.createQuery(sql);
4126
4127 QueryPos qPos = QueryPos.getInstance(q);
4128
4129 qPos.add(threadId);
4130
4131 qPos.add(parentMessageId);
4132
4133 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
4134 end);
4135 }
4136 catch (Exception e) {
4137 throw processException(e);
4138 }
4139 finally {
4140 if (list == null) {
4141 list = new ArrayList<MBMessage>();
4142 }
4143
4144 cacheResult(list);
4145
4146 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_T_P, finderArgs,
4147 list);
4148
4149 closeSession(session);
4150 }
4151 }
4152
4153 return list;
4154 }
4155
4156 public MBMessage findByT_P_First(long threadId, long parentMessageId,
4157 OrderByComparator orderByComparator)
4158 throws NoSuchMessageException, SystemException {
4159 List<MBMessage> list = findByT_P(threadId, parentMessageId, 0, 1,
4160 orderByComparator);
4161
4162 if (list.isEmpty()) {
4163 StringBundler msg = new StringBundler(6);
4164
4165 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4166
4167 msg.append("threadId=");
4168 msg.append(threadId);
4169
4170 msg.append(", parentMessageId=");
4171 msg.append(parentMessageId);
4172
4173 msg.append(StringPool.CLOSE_CURLY_BRACE);
4174
4175 throw new NoSuchMessageException(msg.toString());
4176 }
4177 else {
4178 return list.get(0);
4179 }
4180 }
4181
4182 public MBMessage findByT_P_Last(long threadId, long parentMessageId,
4183 OrderByComparator orderByComparator)
4184 throws NoSuchMessageException, SystemException {
4185 int count = countByT_P(threadId, parentMessageId);
4186
4187 List<MBMessage> list = findByT_P(threadId, parentMessageId, count - 1,
4188 count, orderByComparator);
4189
4190 if (list.isEmpty()) {
4191 StringBundler msg = new StringBundler(6);
4192
4193 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4194
4195 msg.append("threadId=");
4196 msg.append(threadId);
4197
4198 msg.append(", parentMessageId=");
4199 msg.append(parentMessageId);
4200
4201 msg.append(StringPool.CLOSE_CURLY_BRACE);
4202
4203 throw new NoSuchMessageException(msg.toString());
4204 }
4205 else {
4206 return list.get(0);
4207 }
4208 }
4209
4210 public MBMessage[] findByT_P_PrevAndNext(long messageId, long threadId,
4211 long parentMessageId, OrderByComparator orderByComparator)
4212 throws NoSuchMessageException, SystemException {
4213 MBMessage mbMessage = findByPrimaryKey(messageId);
4214
4215 Session session = null;
4216
4217 try {
4218 session = openSession();
4219
4220 MBMessage[] array = new MBMessageImpl[3];
4221
4222 array[0] = getByT_P_PrevAndNext(session, mbMessage, threadId,
4223 parentMessageId, orderByComparator, true);
4224
4225 array[1] = mbMessage;
4226
4227 array[2] = getByT_P_PrevAndNext(session, mbMessage, threadId,
4228 parentMessageId, orderByComparator, false);
4229
4230 return array;
4231 }
4232 catch (Exception e) {
4233 throw processException(e);
4234 }
4235 finally {
4236 closeSession(session);
4237 }
4238 }
4239
4240 protected MBMessage getByT_P_PrevAndNext(Session session,
4241 MBMessage mbMessage, long threadId, long parentMessageId,
4242 OrderByComparator orderByComparator, boolean previous) {
4243 StringBundler query = null;
4244
4245 if (orderByComparator != null) {
4246 query = new StringBundler(6 +
4247 (orderByComparator.getOrderByFields().length * 6));
4248 }
4249 else {
4250 query = new StringBundler(3);
4251 }
4252
4253 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
4254
4255 query.append(_FINDER_COLUMN_T_P_THREADID_2);
4256
4257 query.append(_FINDER_COLUMN_T_P_PARENTMESSAGEID_2);
4258
4259 if (orderByComparator != null) {
4260 String[] orderByFields = orderByComparator.getOrderByFields();
4261
4262 if (orderByFields.length > 0) {
4263 query.append(WHERE_AND);
4264 }
4265
4266 for (int i = 0; i < orderByFields.length; i++) {
4267 query.append(_ORDER_BY_ENTITY_ALIAS);
4268 query.append(orderByFields[i]);
4269
4270 if ((i + 1) < orderByFields.length) {
4271 if (orderByComparator.isAscending() ^ previous) {
4272 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4273 }
4274 else {
4275 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4276 }
4277 }
4278 else {
4279 if (orderByComparator.isAscending() ^ previous) {
4280 query.append(WHERE_GREATER_THAN);
4281 }
4282 else {
4283 query.append(WHERE_LESSER_THAN);
4284 }
4285 }
4286 }
4287
4288 query.append(ORDER_BY_CLAUSE);
4289
4290 for (int i = 0; i < orderByFields.length; i++) {
4291 query.append(_ORDER_BY_ENTITY_ALIAS);
4292 query.append(orderByFields[i]);
4293
4294 if ((i + 1) < orderByFields.length) {
4295 if (orderByComparator.isAscending() ^ previous) {
4296 query.append(ORDER_BY_ASC_HAS_NEXT);
4297 }
4298 else {
4299 query.append(ORDER_BY_DESC_HAS_NEXT);
4300 }
4301 }
4302 else {
4303 if (orderByComparator.isAscending() ^ previous) {
4304 query.append(ORDER_BY_ASC);
4305 }
4306 else {
4307 query.append(ORDER_BY_DESC);
4308 }
4309 }
4310 }
4311 }
4312
4313 else {
4314 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
4315 }
4316
4317 String sql = query.toString();
4318
4319 Query q = session.createQuery(sql);
4320
4321 q.setFirstResult(0);
4322 q.setMaxResults(2);
4323
4324 QueryPos qPos = QueryPos.getInstance(q);
4325
4326 qPos.add(threadId);
4327
4328 qPos.add(parentMessageId);
4329
4330 if (orderByComparator != null) {
4331 Object[] values = orderByComparator.getOrderByValues(mbMessage);
4332
4333 for (Object value : values) {
4334 qPos.add(value);
4335 }
4336 }
4337
4338 List<MBMessage> list = q.list();
4339
4340 if (list.size() == 2) {
4341 return list.get(1);
4342 }
4343 else {
4344 return null;
4345 }
4346 }
4347
4348 public List<MBMessage> findByT_S(long threadId, int status)
4349 throws SystemException {
4350 return findByT_S(threadId, status, QueryUtil.ALL_POS,
4351 QueryUtil.ALL_POS, null);
4352 }
4353
4354 public List<MBMessage> findByT_S(long threadId, int status, int start,
4355 int end) throws SystemException {
4356 return findByT_S(threadId, status, start, end, null);
4357 }
4358
4359 public List<MBMessage> findByT_S(long threadId, int status, int start,
4360 int end, OrderByComparator orderByComparator) throws SystemException {
4361 Object[] finderArgs = new Object[] {
4362 new Long(threadId), new Integer(status),
4363
4364 String.valueOf(start), String.valueOf(end),
4365 String.valueOf(orderByComparator)
4366 };
4367
4368 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_T_S,
4369 finderArgs, this);
4370
4371 if (list == null) {
4372 Session session = null;
4373
4374 try {
4375 session = openSession();
4376
4377 StringBundler query = null;
4378
4379 if (orderByComparator != null) {
4380 query = new StringBundler(4 +
4381 (orderByComparator.getOrderByFields().length * 3));
4382 }
4383 else {
4384 query = new StringBundler(4);
4385 }
4386
4387 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
4388
4389 query.append(_FINDER_COLUMN_T_S_THREADID_2);
4390
4391 query.append(_FINDER_COLUMN_T_S_STATUS_2);
4392
4393 if (orderByComparator != null) {
4394 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4395 orderByComparator);
4396 }
4397
4398 else {
4399 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
4400 }
4401
4402 String sql = query.toString();
4403
4404 Query q = session.createQuery(sql);
4405
4406 QueryPos qPos = QueryPos.getInstance(q);
4407
4408 qPos.add(threadId);
4409
4410 qPos.add(status);
4411
4412 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
4413 end);
4414 }
4415 catch (Exception e) {
4416 throw processException(e);
4417 }
4418 finally {
4419 if (list == null) {
4420 list = new ArrayList<MBMessage>();
4421 }
4422
4423 cacheResult(list);
4424
4425 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_T_S, finderArgs,
4426 list);
4427
4428 closeSession(session);
4429 }
4430 }
4431
4432 return list;
4433 }
4434
4435 public MBMessage findByT_S_First(long threadId, int status,
4436 OrderByComparator orderByComparator)
4437 throws NoSuchMessageException, SystemException {
4438 List<MBMessage> list = findByT_S(threadId, status, 0, 1,
4439 orderByComparator);
4440
4441 if (list.isEmpty()) {
4442 StringBundler msg = new StringBundler(6);
4443
4444 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4445
4446 msg.append("threadId=");
4447 msg.append(threadId);
4448
4449 msg.append(", status=");
4450 msg.append(status);
4451
4452 msg.append(StringPool.CLOSE_CURLY_BRACE);
4453
4454 throw new NoSuchMessageException(msg.toString());
4455 }
4456 else {
4457 return list.get(0);
4458 }
4459 }
4460
4461 public MBMessage findByT_S_Last(long threadId, int status,
4462 OrderByComparator orderByComparator)
4463 throws NoSuchMessageException, SystemException {
4464 int count = countByT_S(threadId, status);
4465
4466 List<MBMessage> list = findByT_S(threadId, status, count - 1, count,
4467 orderByComparator);
4468
4469 if (list.isEmpty()) {
4470 StringBundler msg = new StringBundler(6);
4471
4472 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4473
4474 msg.append("threadId=");
4475 msg.append(threadId);
4476
4477 msg.append(", status=");
4478 msg.append(status);
4479
4480 msg.append(StringPool.CLOSE_CURLY_BRACE);
4481
4482 throw new NoSuchMessageException(msg.toString());
4483 }
4484 else {
4485 return list.get(0);
4486 }
4487 }
4488
4489 public MBMessage[] findByT_S_PrevAndNext(long messageId, long threadId,
4490 int status, OrderByComparator orderByComparator)
4491 throws NoSuchMessageException, SystemException {
4492 MBMessage mbMessage = findByPrimaryKey(messageId);
4493
4494 Session session = null;
4495
4496 try {
4497 session = openSession();
4498
4499 MBMessage[] array = new MBMessageImpl[3];
4500
4501 array[0] = getByT_S_PrevAndNext(session, mbMessage, threadId,
4502 status, orderByComparator, true);
4503
4504 array[1] = mbMessage;
4505
4506 array[2] = getByT_S_PrevAndNext(session, mbMessage, threadId,
4507 status, orderByComparator, false);
4508
4509 return array;
4510 }
4511 catch (Exception e) {
4512 throw processException(e);
4513 }
4514 finally {
4515 closeSession(session);
4516 }
4517 }
4518
4519 protected MBMessage getByT_S_PrevAndNext(Session session,
4520 MBMessage mbMessage, long threadId, int status,
4521 OrderByComparator orderByComparator, boolean previous) {
4522 StringBundler query = null;
4523
4524 if (orderByComparator != null) {
4525 query = new StringBundler(6 +
4526 (orderByComparator.getOrderByFields().length * 6));
4527 }
4528 else {
4529 query = new StringBundler(3);
4530 }
4531
4532 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
4533
4534 query.append(_FINDER_COLUMN_T_S_THREADID_2);
4535
4536 query.append(_FINDER_COLUMN_T_S_STATUS_2);
4537
4538 if (orderByComparator != null) {
4539 String[] orderByFields = orderByComparator.getOrderByFields();
4540
4541 if (orderByFields.length > 0) {
4542 query.append(WHERE_AND);
4543 }
4544
4545 for (int i = 0; i < orderByFields.length; i++) {
4546 query.append(_ORDER_BY_ENTITY_ALIAS);
4547 query.append(orderByFields[i]);
4548
4549 if ((i + 1) < orderByFields.length) {
4550 if (orderByComparator.isAscending() ^ previous) {
4551 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4552 }
4553 else {
4554 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4555 }
4556 }
4557 else {
4558 if (orderByComparator.isAscending() ^ previous) {
4559 query.append(WHERE_GREATER_THAN);
4560 }
4561 else {
4562 query.append(WHERE_LESSER_THAN);
4563 }
4564 }
4565 }
4566
4567 query.append(ORDER_BY_CLAUSE);
4568
4569 for (int i = 0; i < orderByFields.length; i++) {
4570 query.append(_ORDER_BY_ENTITY_ALIAS);
4571 query.append(orderByFields[i]);
4572
4573 if ((i + 1) < orderByFields.length) {
4574 if (orderByComparator.isAscending() ^ previous) {
4575 query.append(ORDER_BY_ASC_HAS_NEXT);
4576 }
4577 else {
4578 query.append(ORDER_BY_DESC_HAS_NEXT);
4579 }
4580 }
4581 else {
4582 if (orderByComparator.isAscending() ^ previous) {
4583 query.append(ORDER_BY_ASC);
4584 }
4585 else {
4586 query.append(ORDER_BY_DESC);
4587 }
4588 }
4589 }
4590 }
4591
4592 else {
4593 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
4594 }
4595
4596 String sql = query.toString();
4597
4598 Query q = session.createQuery(sql);
4599
4600 q.setFirstResult(0);
4601 q.setMaxResults(2);
4602
4603 QueryPos qPos = QueryPos.getInstance(q);
4604
4605 qPos.add(threadId);
4606
4607 qPos.add(status);
4608
4609 if (orderByComparator != null) {
4610 Object[] values = orderByComparator.getOrderByValues(mbMessage);
4611
4612 for (Object value : values) {
4613 qPos.add(value);
4614 }
4615 }
4616
4617 List<MBMessage> list = q.list();
4618
4619 if (list.size() == 2) {
4620 return list.get(1);
4621 }
4622 else {
4623 return null;
4624 }
4625 }
4626
4627 public List<MBMessage> findByTR_S(long threadId, int status)
4628 throws SystemException {
4629 return findByTR_S(threadId, status, QueryUtil.ALL_POS,
4630 QueryUtil.ALL_POS, null);
4631 }
4632
4633 public List<MBMessage> findByTR_S(long threadId, int status, int start,
4634 int end) throws SystemException {
4635 return findByTR_S(threadId, status, start, end, null);
4636 }
4637
4638 public List<MBMessage> findByTR_S(long threadId, int status, int start,
4639 int end, OrderByComparator orderByComparator) throws SystemException {
4640 Object[] finderArgs = new Object[] {
4641 new Long(threadId), new Integer(status),
4642
4643 String.valueOf(start), String.valueOf(end),
4644 String.valueOf(orderByComparator)
4645 };
4646
4647 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_TR_S,
4648 finderArgs, this);
4649
4650 if (list == null) {
4651 Session session = null;
4652
4653 try {
4654 session = openSession();
4655
4656 StringBundler query = null;
4657
4658 if (orderByComparator != null) {
4659 query = new StringBundler(4 +
4660 (orderByComparator.getOrderByFields().length * 3));
4661 }
4662 else {
4663 query = new StringBundler(4);
4664 }
4665
4666 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
4667
4668 query.append(_FINDER_COLUMN_TR_S_THREADID_2);
4669
4670 query.append(_FINDER_COLUMN_TR_S_STATUS_2);
4671
4672 if (orderByComparator != null) {
4673 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4674 orderByComparator);
4675 }
4676
4677 else {
4678 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
4679 }
4680
4681 String sql = query.toString();
4682
4683 Query q = session.createQuery(sql);
4684
4685 QueryPos qPos = QueryPos.getInstance(q);
4686
4687 qPos.add(threadId);
4688
4689 qPos.add(status);
4690
4691 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
4692 end);
4693 }
4694 catch (Exception e) {
4695 throw processException(e);
4696 }
4697 finally {
4698 if (list == null) {
4699 list = new ArrayList<MBMessage>();
4700 }
4701
4702 cacheResult(list);
4703
4704 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_TR_S, finderArgs,
4705 list);
4706
4707 closeSession(session);
4708 }
4709 }
4710
4711 return list;
4712 }
4713
4714 public MBMessage findByTR_S_First(long threadId, int status,
4715 OrderByComparator orderByComparator)
4716 throws NoSuchMessageException, SystemException {
4717 List<MBMessage> list = findByTR_S(threadId, status, 0, 1,
4718 orderByComparator);
4719
4720 if (list.isEmpty()) {
4721 StringBundler msg = new StringBundler(6);
4722
4723 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4724
4725 msg.append("threadId=");
4726 msg.append(threadId);
4727
4728 msg.append(", status=");
4729 msg.append(status);
4730
4731 msg.append(StringPool.CLOSE_CURLY_BRACE);
4732
4733 throw new NoSuchMessageException(msg.toString());
4734 }
4735 else {
4736 return list.get(0);
4737 }
4738 }
4739
4740 public MBMessage findByTR_S_Last(long threadId, int status,
4741 OrderByComparator orderByComparator)
4742 throws NoSuchMessageException, SystemException {
4743 int count = countByTR_S(threadId, status);
4744
4745 List<MBMessage> list = findByTR_S(threadId, status, count - 1, count,
4746 orderByComparator);
4747
4748 if (list.isEmpty()) {
4749 StringBundler msg = new StringBundler(6);
4750
4751 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4752
4753 msg.append("threadId=");
4754 msg.append(threadId);
4755
4756 msg.append(", status=");
4757 msg.append(status);
4758
4759 msg.append(StringPool.CLOSE_CURLY_BRACE);
4760
4761 throw new NoSuchMessageException(msg.toString());
4762 }
4763 else {
4764 return list.get(0);
4765 }
4766 }
4767
4768 public MBMessage[] findByTR_S_PrevAndNext(long messageId, long threadId,
4769 int status, OrderByComparator orderByComparator)
4770 throws NoSuchMessageException, SystemException {
4771 MBMessage mbMessage = findByPrimaryKey(messageId);
4772
4773 Session session = null;
4774
4775 try {
4776 session = openSession();
4777
4778 MBMessage[] array = new MBMessageImpl[3];
4779
4780 array[0] = getByTR_S_PrevAndNext(session, mbMessage, threadId,
4781 status, orderByComparator, true);
4782
4783 array[1] = mbMessage;
4784
4785 array[2] = getByTR_S_PrevAndNext(session, mbMessage, threadId,
4786 status, orderByComparator, false);
4787
4788 return array;
4789 }
4790 catch (Exception e) {
4791 throw processException(e);
4792 }
4793 finally {
4794 closeSession(session);
4795 }
4796 }
4797
4798 protected MBMessage getByTR_S_PrevAndNext(Session session,
4799 MBMessage mbMessage, long threadId, int status,
4800 OrderByComparator orderByComparator, boolean previous) {
4801 StringBundler query = null;
4802
4803 if (orderByComparator != null) {
4804 query = new StringBundler(6 +
4805 (orderByComparator.getOrderByFields().length * 6));
4806 }
4807 else {
4808 query = new StringBundler(3);
4809 }
4810
4811 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
4812
4813 query.append(_FINDER_COLUMN_TR_S_THREADID_2);
4814
4815 query.append(_FINDER_COLUMN_TR_S_STATUS_2);
4816
4817 if (orderByComparator != null) {
4818 String[] orderByFields = orderByComparator.getOrderByFields();
4819
4820 if (orderByFields.length > 0) {
4821 query.append(WHERE_AND);
4822 }
4823
4824 for (int i = 0; i < orderByFields.length; i++) {
4825 query.append(_ORDER_BY_ENTITY_ALIAS);
4826 query.append(orderByFields[i]);
4827
4828 if ((i + 1) < orderByFields.length) {
4829 if (orderByComparator.isAscending() ^ previous) {
4830 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4831 }
4832 else {
4833 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4834 }
4835 }
4836 else {
4837 if (orderByComparator.isAscending() ^ previous) {
4838 query.append(WHERE_GREATER_THAN);
4839 }
4840 else {
4841 query.append(WHERE_LESSER_THAN);
4842 }
4843 }
4844 }
4845
4846 query.append(ORDER_BY_CLAUSE);
4847
4848 for (int i = 0; i < orderByFields.length; i++) {
4849 query.append(_ORDER_BY_ENTITY_ALIAS);
4850 query.append(orderByFields[i]);
4851
4852 if ((i + 1) < orderByFields.length) {
4853 if (orderByComparator.isAscending() ^ previous) {
4854 query.append(ORDER_BY_ASC_HAS_NEXT);
4855 }
4856 else {
4857 query.append(ORDER_BY_DESC_HAS_NEXT);
4858 }
4859 }
4860 else {
4861 if (orderByComparator.isAscending() ^ previous) {
4862 query.append(ORDER_BY_ASC);
4863 }
4864 else {
4865 query.append(ORDER_BY_DESC);
4866 }
4867 }
4868 }
4869 }
4870
4871 else {
4872 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
4873 }
4874
4875 String sql = query.toString();
4876
4877 Query q = session.createQuery(sql);
4878
4879 q.setFirstResult(0);
4880 q.setMaxResults(2);
4881
4882 QueryPos qPos = QueryPos.getInstance(q);
4883
4884 qPos.add(threadId);
4885
4886 qPos.add(status);
4887
4888 if (orderByComparator != null) {
4889 Object[] values = orderByComparator.getOrderByValues(mbMessage);
4890
4891 for (Object value : values) {
4892 qPos.add(value);
4893 }
4894 }
4895
4896 List<MBMessage> list = q.list();
4897
4898 if (list.size() == 2) {
4899 return list.get(1);
4900 }
4901 else {
4902 return null;
4903 }
4904 }
4905
4906 public List<MBMessage> findByG_U_S(long groupId, long userId, int status)
4907 throws SystemException {
4908 return findByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
4909 QueryUtil.ALL_POS, null);
4910 }
4911
4912 public List<MBMessage> findByG_U_S(long groupId, long userId, int status,
4913 int start, int end) throws SystemException {
4914 return findByG_U_S(groupId, userId, status, start, end, null);
4915 }
4916
4917 public List<MBMessage> findByG_U_S(long groupId, long userId, int status,
4918 int start, int end, OrderByComparator orderByComparator)
4919 throws SystemException {
4920 Object[] finderArgs = new Object[] {
4921 new Long(groupId), new Long(userId), new Integer(status),
4922
4923 String.valueOf(start), String.valueOf(end),
4924 String.valueOf(orderByComparator)
4925 };
4926
4927 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_U_S,
4928 finderArgs, this);
4929
4930 if (list == null) {
4931 Session session = null;
4932
4933 try {
4934 session = openSession();
4935
4936 StringBundler query = null;
4937
4938 if (orderByComparator != null) {
4939 query = new StringBundler(5 +
4940 (orderByComparator.getOrderByFields().length * 3));
4941 }
4942 else {
4943 query = new StringBundler(5);
4944 }
4945
4946 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
4947
4948 query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
4949
4950 query.append(_FINDER_COLUMN_G_U_S_USERID_2);
4951
4952 query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
4953
4954 if (orderByComparator != null) {
4955 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4956 orderByComparator);
4957 }
4958
4959 else {
4960 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
4961 }
4962
4963 String sql = query.toString();
4964
4965 Query q = session.createQuery(sql);
4966
4967 QueryPos qPos = QueryPos.getInstance(q);
4968
4969 qPos.add(groupId);
4970
4971 qPos.add(userId);
4972
4973 qPos.add(status);
4974
4975 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
4976 end);
4977 }
4978 catch (Exception e) {
4979 throw processException(e);
4980 }
4981 finally {
4982 if (list == null) {
4983 list = new ArrayList<MBMessage>();
4984 }
4985
4986 cacheResult(list);
4987
4988 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_U_S,
4989 finderArgs, list);
4990
4991 closeSession(session);
4992 }
4993 }
4994
4995 return list;
4996 }
4997
4998 public MBMessage findByG_U_S_First(long groupId, long userId, int status,
4999 OrderByComparator orderByComparator)
5000 throws NoSuchMessageException, SystemException {
5001 List<MBMessage> list = findByG_U_S(groupId, userId, status, 0, 1,
5002 orderByComparator);
5003
5004 if (list.isEmpty()) {
5005 StringBundler msg = new StringBundler(8);
5006
5007 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5008
5009 msg.append("groupId=");
5010 msg.append(groupId);
5011
5012 msg.append(", userId=");
5013 msg.append(userId);
5014
5015 msg.append(", status=");
5016 msg.append(status);
5017
5018 msg.append(StringPool.CLOSE_CURLY_BRACE);
5019
5020 throw new NoSuchMessageException(msg.toString());
5021 }
5022 else {
5023 return list.get(0);
5024 }
5025 }
5026
5027 public MBMessage findByG_U_S_Last(long groupId, long userId, int status,
5028 OrderByComparator orderByComparator)
5029 throws NoSuchMessageException, SystemException {
5030 int count = countByG_U_S(groupId, userId, status);
5031
5032 List<MBMessage> list = findByG_U_S(groupId, userId, status, count - 1,
5033 count, orderByComparator);
5034
5035 if (list.isEmpty()) {
5036 StringBundler msg = new StringBundler(8);
5037
5038 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5039
5040 msg.append("groupId=");
5041 msg.append(groupId);
5042
5043 msg.append(", userId=");
5044 msg.append(userId);
5045
5046 msg.append(", status=");
5047 msg.append(status);
5048
5049 msg.append(StringPool.CLOSE_CURLY_BRACE);
5050
5051 throw new NoSuchMessageException(msg.toString());
5052 }
5053 else {
5054 return list.get(0);
5055 }
5056 }
5057
5058 public MBMessage[] findByG_U_S_PrevAndNext(long messageId, long groupId,
5059 long userId, int status, OrderByComparator orderByComparator)
5060 throws NoSuchMessageException, SystemException {
5061 MBMessage mbMessage = findByPrimaryKey(messageId);
5062
5063 Session session = null;
5064
5065 try {
5066 session = openSession();
5067
5068 MBMessage[] array = new MBMessageImpl[3];
5069
5070 array[0] = getByG_U_S_PrevAndNext(session, mbMessage, groupId,
5071 userId, status, orderByComparator, true);
5072
5073 array[1] = mbMessage;
5074
5075 array[2] = getByG_U_S_PrevAndNext(session, mbMessage, groupId,
5076 userId, status, orderByComparator, false);
5077
5078 return array;
5079 }
5080 catch (Exception e) {
5081 throw processException(e);
5082 }
5083 finally {
5084 closeSession(session);
5085 }
5086 }
5087
5088 protected MBMessage getByG_U_S_PrevAndNext(Session session,
5089 MBMessage mbMessage, long groupId, long userId, int status,
5090 OrderByComparator orderByComparator, boolean previous) {
5091 StringBundler query = null;
5092
5093 if (orderByComparator != null) {
5094 query = new StringBundler(6 +
5095 (orderByComparator.getOrderByFields().length * 6));
5096 }
5097 else {
5098 query = new StringBundler(3);
5099 }
5100
5101 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
5102
5103 query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
5104
5105 query.append(_FINDER_COLUMN_G_U_S_USERID_2);
5106
5107 query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
5108
5109 if (orderByComparator != null) {
5110 String[] orderByFields = orderByComparator.getOrderByFields();
5111
5112 if (orderByFields.length > 0) {
5113 query.append(WHERE_AND);
5114 }
5115
5116 for (int i = 0; i < orderByFields.length; i++) {
5117 query.append(_ORDER_BY_ENTITY_ALIAS);
5118 query.append(orderByFields[i]);
5119
5120 if ((i + 1) < orderByFields.length) {
5121 if (orderByComparator.isAscending() ^ previous) {
5122 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5123 }
5124 else {
5125 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5126 }
5127 }
5128 else {
5129 if (orderByComparator.isAscending() ^ previous) {
5130 query.append(WHERE_GREATER_THAN);
5131 }
5132 else {
5133 query.append(WHERE_LESSER_THAN);
5134 }
5135 }
5136 }
5137
5138 query.append(ORDER_BY_CLAUSE);
5139
5140 for (int i = 0; i < orderByFields.length; i++) {
5141 query.append(_ORDER_BY_ENTITY_ALIAS);
5142 query.append(orderByFields[i]);
5143
5144 if ((i + 1) < orderByFields.length) {
5145 if (orderByComparator.isAscending() ^ previous) {
5146 query.append(ORDER_BY_ASC_HAS_NEXT);
5147 }
5148 else {
5149 query.append(ORDER_BY_DESC_HAS_NEXT);
5150 }
5151 }
5152 else {
5153 if (orderByComparator.isAscending() ^ previous) {
5154 query.append(ORDER_BY_ASC);
5155 }
5156 else {
5157 query.append(ORDER_BY_DESC);
5158 }
5159 }
5160 }
5161 }
5162
5163 else {
5164 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
5165 }
5166
5167 String sql = query.toString();
5168
5169 Query q = session.createQuery(sql);
5170
5171 q.setFirstResult(0);
5172 q.setMaxResults(2);
5173
5174 QueryPos qPos = QueryPos.getInstance(q);
5175
5176 qPos.add(groupId);
5177
5178 qPos.add(userId);
5179
5180 qPos.add(status);
5181
5182 if (orderByComparator != null) {
5183 Object[] values = orderByComparator.getOrderByValues(mbMessage);
5184
5185 for (Object value : values) {
5186 qPos.add(value);
5187 }
5188 }
5189
5190 List<MBMessage> list = q.list();
5191
5192 if (list.size() == 2) {
5193 return list.get(1);
5194 }
5195 else {
5196 return null;
5197 }
5198 }
5199
5200 public List<MBMessage> filterFindByG_U_S(long groupId, long userId,
5201 int status) throws SystemException {
5202 return filterFindByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
5203 QueryUtil.ALL_POS, null);
5204 }
5205
5206 public List<MBMessage> filterFindByG_U_S(long groupId, long userId,
5207 int status, int start, int end) throws SystemException {
5208 return filterFindByG_U_S(groupId, userId, status, start, end, null);
5209 }
5210
5211 public List<MBMessage> filterFindByG_U_S(long groupId, long userId,
5212 int status, int start, int end, OrderByComparator orderByComparator)
5213 throws SystemException {
5214 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5215 return findByG_U_S(groupId, userId, status, start, end,
5216 orderByComparator);
5217 }
5218
5219 Session session = null;
5220
5221 try {
5222 session = openSession();
5223
5224 StringBundler query = null;
5225
5226 if (orderByComparator != null) {
5227 query = new StringBundler(5 +
5228 (orderByComparator.getOrderByFields().length * 3));
5229 }
5230 else {
5231 query = new StringBundler(5);
5232 }
5233
5234 query.append(_FILTER_SQL_SELECT_MBMESSAGE_WHERE);
5235
5236 query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
5237
5238 query.append(_FINDER_COLUMN_G_U_S_USERID_2);
5239
5240 query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
5241
5242 if (orderByComparator != null) {
5243 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5244 orderByComparator);
5245 }
5246
5247 else {
5248 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
5249 }
5250
5251 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5252 MBMessage.class.getName(), _FILTER_COLUMN_MESSAGEID,
5253 _FILTER_COLUMN_USERID, groupId);
5254
5255 SQLQuery q = session.createSQLQuery(sql);
5256
5257 q.addEntity(_FILTER_ENTITY_ALIAS, MBMessageImpl.class);
5258
5259 QueryPos qPos = QueryPos.getInstance(q);
5260
5261 qPos.add(groupId);
5262
5263 qPos.add(userId);
5264
5265 qPos.add(status);
5266
5267 return (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end);
5268 }
5269 catch (Exception e) {
5270 throw processException(e);
5271 }
5272 finally {
5273 closeSession(session);
5274 }
5275 }
5276
5277 public List<MBMessage> findByG_C_T(long groupId, long categoryId,
5278 long threadId) throws SystemException {
5279 return findByG_C_T(groupId, categoryId, threadId, QueryUtil.ALL_POS,
5280 QueryUtil.ALL_POS, null);
5281 }
5282
5283 public List<MBMessage> findByG_C_T(long groupId, long categoryId,
5284 long threadId, int start, int end) throws SystemException {
5285 return findByG_C_T(groupId, categoryId, threadId, start, end, null);
5286 }
5287
5288 public List<MBMessage> findByG_C_T(long groupId, long categoryId,
5289 long threadId, int start, int end, OrderByComparator orderByComparator)
5290 throws SystemException {
5291 Object[] finderArgs = new Object[] {
5292 new Long(groupId), new Long(categoryId), new Long(threadId),
5293
5294 String.valueOf(start), String.valueOf(end),
5295 String.valueOf(orderByComparator)
5296 };
5297
5298 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_C_T,
5299 finderArgs, this);
5300
5301 if (list == null) {
5302 Session session = null;
5303
5304 try {
5305 session = openSession();
5306
5307 StringBundler query = null;
5308
5309 if (orderByComparator != null) {
5310 query = new StringBundler(5 +
5311 (orderByComparator.getOrderByFields().length * 3));
5312 }
5313 else {
5314 query = new StringBundler(5);
5315 }
5316
5317 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
5318
5319 query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
5320
5321 query.append(_FINDER_COLUMN_G_C_T_CATEGORYID_2);
5322
5323 query.append(_FINDER_COLUMN_G_C_T_THREADID_2);
5324
5325 if (orderByComparator != null) {
5326 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5327 orderByComparator);
5328 }
5329
5330 else {
5331 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
5332 }
5333
5334 String sql = query.toString();
5335
5336 Query q = session.createQuery(sql);
5337
5338 QueryPos qPos = QueryPos.getInstance(q);
5339
5340 qPos.add(groupId);
5341
5342 qPos.add(categoryId);
5343
5344 qPos.add(threadId);
5345
5346 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
5347 end);
5348 }
5349 catch (Exception e) {
5350 throw processException(e);
5351 }
5352 finally {
5353 if (list == null) {
5354 list = new ArrayList<MBMessage>();
5355 }
5356
5357 cacheResult(list);
5358
5359 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_C_T,
5360 finderArgs, list);
5361
5362 closeSession(session);
5363 }
5364 }
5365
5366 return list;
5367 }
5368
5369 public MBMessage findByG_C_T_First(long groupId, long categoryId,
5370 long threadId, OrderByComparator orderByComparator)
5371 throws NoSuchMessageException, SystemException {
5372 List<MBMessage> list = findByG_C_T(groupId, categoryId, threadId, 0, 1,
5373 orderByComparator);
5374
5375 if (list.isEmpty()) {
5376 StringBundler msg = new StringBundler(8);
5377
5378 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5379
5380 msg.append("groupId=");
5381 msg.append(groupId);
5382
5383 msg.append(", categoryId=");
5384 msg.append(categoryId);
5385
5386 msg.append(", threadId=");
5387 msg.append(threadId);
5388
5389 msg.append(StringPool.CLOSE_CURLY_BRACE);
5390
5391 throw new NoSuchMessageException(msg.toString());
5392 }
5393 else {
5394 return list.get(0);
5395 }
5396 }
5397
5398 public MBMessage findByG_C_T_Last(long groupId, long categoryId,
5399 long threadId, OrderByComparator orderByComparator)
5400 throws NoSuchMessageException, SystemException {
5401 int count = countByG_C_T(groupId, categoryId, threadId);
5402
5403 List<MBMessage> list = findByG_C_T(groupId, categoryId, threadId,
5404 count - 1, count, orderByComparator);
5405
5406 if (list.isEmpty()) {
5407 StringBundler msg = new StringBundler(8);
5408
5409 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5410
5411 msg.append("groupId=");
5412 msg.append(groupId);
5413
5414 msg.append(", categoryId=");
5415 msg.append(categoryId);
5416
5417 msg.append(", threadId=");
5418 msg.append(threadId);
5419
5420 msg.append(StringPool.CLOSE_CURLY_BRACE);
5421
5422 throw new NoSuchMessageException(msg.toString());
5423 }
5424 else {
5425 return list.get(0);
5426 }
5427 }
5428
5429 public MBMessage[] findByG_C_T_PrevAndNext(long messageId, long groupId,
5430 long categoryId, long threadId, OrderByComparator orderByComparator)
5431 throws NoSuchMessageException, SystemException {
5432 MBMessage mbMessage = findByPrimaryKey(messageId);
5433
5434 Session session = null;
5435
5436 try {
5437 session = openSession();
5438
5439 MBMessage[] array = new MBMessageImpl[3];
5440
5441 array[0] = getByG_C_T_PrevAndNext(session, mbMessage, groupId,
5442 categoryId, threadId, orderByComparator, true);
5443
5444 array[1] = mbMessage;
5445
5446 array[2] = getByG_C_T_PrevAndNext(session, mbMessage, groupId,
5447 categoryId, threadId, orderByComparator, false);
5448
5449 return array;
5450 }
5451 catch (Exception e) {
5452 throw processException(e);
5453 }
5454 finally {
5455 closeSession(session);
5456 }
5457 }
5458
5459 protected MBMessage getByG_C_T_PrevAndNext(Session session,
5460 MBMessage mbMessage, long groupId, long categoryId, long threadId,
5461 OrderByComparator orderByComparator, boolean previous) {
5462 StringBundler query = null;
5463
5464 if (orderByComparator != null) {
5465 query = new StringBundler(6 +
5466 (orderByComparator.getOrderByFields().length * 6));
5467 }
5468 else {
5469 query = new StringBundler(3);
5470 }
5471
5472 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
5473
5474 query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
5475
5476 query.append(_FINDER_COLUMN_G_C_T_CATEGORYID_2);
5477
5478 query.append(_FINDER_COLUMN_G_C_T_THREADID_2);
5479
5480 if (orderByComparator != null) {
5481 String[] orderByFields = orderByComparator.getOrderByFields();
5482
5483 if (orderByFields.length > 0) {
5484 query.append(WHERE_AND);
5485 }
5486
5487 for (int i = 0; i < orderByFields.length; i++) {
5488 query.append(_ORDER_BY_ENTITY_ALIAS);
5489 query.append(orderByFields[i]);
5490
5491 if ((i + 1) < orderByFields.length) {
5492 if (orderByComparator.isAscending() ^ previous) {
5493 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5494 }
5495 else {
5496 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5497 }
5498 }
5499 else {
5500 if (orderByComparator.isAscending() ^ previous) {
5501 query.append(WHERE_GREATER_THAN);
5502 }
5503 else {
5504 query.append(WHERE_LESSER_THAN);
5505 }
5506 }
5507 }
5508
5509 query.append(ORDER_BY_CLAUSE);
5510
5511 for (int i = 0; i < orderByFields.length; i++) {
5512 query.append(_ORDER_BY_ENTITY_ALIAS);
5513 query.append(orderByFields[i]);
5514
5515 if ((i + 1) < orderByFields.length) {
5516 if (orderByComparator.isAscending() ^ previous) {
5517 query.append(ORDER_BY_ASC_HAS_NEXT);
5518 }
5519 else {
5520 query.append(ORDER_BY_DESC_HAS_NEXT);
5521 }
5522 }
5523 else {
5524 if (orderByComparator.isAscending() ^ previous) {
5525 query.append(ORDER_BY_ASC);
5526 }
5527 else {
5528 query.append(ORDER_BY_DESC);
5529 }
5530 }
5531 }
5532 }
5533
5534 else {
5535 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
5536 }
5537
5538 String sql = query.toString();
5539
5540 Query q = session.createQuery(sql);
5541
5542 q.setFirstResult(0);
5543 q.setMaxResults(2);
5544
5545 QueryPos qPos = QueryPos.getInstance(q);
5546
5547 qPos.add(groupId);
5548
5549 qPos.add(categoryId);
5550
5551 qPos.add(threadId);
5552
5553 if (orderByComparator != null) {
5554 Object[] values = orderByComparator.getOrderByValues(mbMessage);
5555
5556 for (Object value : values) {
5557 qPos.add(value);
5558 }
5559 }
5560
5561 List<MBMessage> list = q.list();
5562
5563 if (list.size() == 2) {
5564 return list.get(1);
5565 }
5566 else {
5567 return null;
5568 }
5569 }
5570
5571 public List<MBMessage> filterFindByG_C_T(long groupId, long categoryId,
5572 long threadId) throws SystemException {
5573 return filterFindByG_C_T(groupId, categoryId, threadId,
5574 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5575 }
5576
5577 public List<MBMessage> filterFindByG_C_T(long groupId, long categoryId,
5578 long threadId, int start, int end) throws SystemException {
5579 return filterFindByG_C_T(groupId, categoryId, threadId, start, end, null);
5580 }
5581
5582 public List<MBMessage> filterFindByG_C_T(long groupId, long categoryId,
5583 long threadId, int start, int end, OrderByComparator orderByComparator)
5584 throws SystemException {
5585 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5586 return findByG_C_T(groupId, categoryId, threadId, start, end,
5587 orderByComparator);
5588 }
5589
5590 Session session = null;
5591
5592 try {
5593 session = openSession();
5594
5595 StringBundler query = null;
5596
5597 if (orderByComparator != null) {
5598 query = new StringBundler(5 +
5599 (orderByComparator.getOrderByFields().length * 3));
5600 }
5601 else {
5602 query = new StringBundler(5);
5603 }
5604
5605 query.append(_FILTER_SQL_SELECT_MBMESSAGE_WHERE);
5606
5607 query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
5608
5609 query.append(_FINDER_COLUMN_G_C_T_CATEGORYID_2);
5610
5611 query.append(_FINDER_COLUMN_G_C_T_THREADID_2);
5612
5613 if (orderByComparator != null) {
5614 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5615 orderByComparator);
5616 }
5617
5618 else {
5619 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
5620 }
5621
5622 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5623 MBMessage.class.getName(), _FILTER_COLUMN_MESSAGEID,
5624 _FILTER_COLUMN_USERID, groupId);
5625
5626 SQLQuery q = session.createSQLQuery(sql);
5627
5628 q.addEntity(_FILTER_ENTITY_ALIAS, MBMessageImpl.class);
5629
5630 QueryPos qPos = QueryPos.getInstance(q);
5631
5632 qPos.add(groupId);
5633
5634 qPos.add(categoryId);
5635
5636 qPos.add(threadId);
5637
5638 return (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end);
5639 }
5640 catch (Exception e) {
5641 throw processException(e);
5642 }
5643 finally {
5644 closeSession(session);
5645 }
5646 }
5647
5648 public List<MBMessage> findByG_C_S(long groupId, long categoryId, int status)
5649 throws SystemException {
5650 return findByG_C_S(groupId, categoryId, status, QueryUtil.ALL_POS,
5651 QueryUtil.ALL_POS, null);
5652 }
5653
5654 public List<MBMessage> findByG_C_S(long groupId, long categoryId,
5655 int status, int start, int end) throws SystemException {
5656 return findByG_C_S(groupId, categoryId, status, start, end, null);
5657 }
5658
5659 public List<MBMessage> findByG_C_S(long groupId, long categoryId,
5660 int status, int start, int end, OrderByComparator orderByComparator)
5661 throws SystemException {
5662 Object[] finderArgs = new Object[] {
5663 new Long(groupId), new Long(categoryId), new Integer(status),
5664
5665 String.valueOf(start), String.valueOf(end),
5666 String.valueOf(orderByComparator)
5667 };
5668
5669 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_C_S,
5670 finderArgs, this);
5671
5672 if (list == null) {
5673 Session session = null;
5674
5675 try {
5676 session = openSession();
5677
5678 StringBundler query = null;
5679
5680 if (orderByComparator != null) {
5681 query = new StringBundler(5 +
5682 (orderByComparator.getOrderByFields().length * 3));
5683 }
5684 else {
5685 query = new StringBundler(5);
5686 }
5687
5688 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
5689
5690 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
5691
5692 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
5693
5694 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
5695
5696 if (orderByComparator != null) {
5697 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5698 orderByComparator);
5699 }
5700
5701 else {
5702 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
5703 }
5704
5705 String sql = query.toString();
5706
5707 Query q = session.createQuery(sql);
5708
5709 QueryPos qPos = QueryPos.getInstance(q);
5710
5711 qPos.add(groupId);
5712
5713 qPos.add(categoryId);
5714
5715 qPos.add(status);
5716
5717 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
5718 end);
5719 }
5720 catch (Exception e) {
5721 throw processException(e);
5722 }
5723 finally {
5724 if (list == null) {
5725 list = new ArrayList<MBMessage>();
5726 }
5727
5728 cacheResult(list);
5729
5730 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_C_S,
5731 finderArgs, list);
5732
5733 closeSession(session);
5734 }
5735 }
5736
5737 return list;
5738 }
5739
5740 public MBMessage findByG_C_S_First(long groupId, long categoryId,
5741 int status, OrderByComparator orderByComparator)
5742 throws NoSuchMessageException, SystemException {
5743 List<MBMessage> list = findByG_C_S(groupId, categoryId, status, 0, 1,
5744 orderByComparator);
5745
5746 if (list.isEmpty()) {
5747 StringBundler msg = new StringBundler(8);
5748
5749 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5750
5751 msg.append("groupId=");
5752 msg.append(groupId);
5753
5754 msg.append(", categoryId=");
5755 msg.append(categoryId);
5756
5757 msg.append(", status=");
5758 msg.append(status);
5759
5760 msg.append(StringPool.CLOSE_CURLY_BRACE);
5761
5762 throw new NoSuchMessageException(msg.toString());
5763 }
5764 else {
5765 return list.get(0);
5766 }
5767 }
5768
5769 public MBMessage findByG_C_S_Last(long groupId, long categoryId,
5770 int status, OrderByComparator orderByComparator)
5771 throws NoSuchMessageException, SystemException {
5772 int count = countByG_C_S(groupId, categoryId, status);
5773
5774 List<MBMessage> list = findByG_C_S(groupId, categoryId, status,
5775 count - 1, count, orderByComparator);
5776
5777 if (list.isEmpty()) {
5778 StringBundler msg = new StringBundler(8);
5779
5780 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5781
5782 msg.append("groupId=");
5783 msg.append(groupId);
5784
5785 msg.append(", categoryId=");
5786 msg.append(categoryId);
5787
5788 msg.append(", status=");
5789 msg.append(status);
5790
5791 msg.append(StringPool.CLOSE_CURLY_BRACE);
5792
5793 throw new NoSuchMessageException(msg.toString());
5794 }
5795 else {
5796 return list.get(0);
5797 }
5798 }
5799
5800 public MBMessage[] findByG_C_S_PrevAndNext(long messageId, long groupId,
5801 long categoryId, int status, OrderByComparator orderByComparator)
5802 throws NoSuchMessageException, SystemException {
5803 MBMessage mbMessage = findByPrimaryKey(messageId);
5804
5805 Session session = null;
5806
5807 try {
5808 session = openSession();
5809
5810 MBMessage[] array = new MBMessageImpl[3];
5811
5812 array[0] = getByG_C_S_PrevAndNext(session, mbMessage, groupId,
5813 categoryId, status, orderByComparator, true);
5814
5815 array[1] = mbMessage;
5816
5817 array[2] = getByG_C_S_PrevAndNext(session, mbMessage, groupId,
5818 categoryId, status, orderByComparator, false);
5819
5820 return array;
5821 }
5822 catch (Exception e) {
5823 throw processException(e);
5824 }
5825 finally {
5826 closeSession(session);
5827 }
5828 }
5829
5830 protected MBMessage getByG_C_S_PrevAndNext(Session session,
5831 MBMessage mbMessage, long groupId, long categoryId, int status,
5832 OrderByComparator orderByComparator, boolean previous) {
5833 StringBundler query = null;
5834
5835 if (orderByComparator != null) {
5836 query = new StringBundler(6 +
5837 (orderByComparator.getOrderByFields().length * 6));
5838 }
5839 else {
5840 query = new StringBundler(3);
5841 }
5842
5843 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
5844
5845 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
5846
5847 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
5848
5849 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
5850
5851 if (orderByComparator != null) {
5852 String[] orderByFields = orderByComparator.getOrderByFields();
5853
5854 if (orderByFields.length > 0) {
5855 query.append(WHERE_AND);
5856 }
5857
5858 for (int i = 0; i < orderByFields.length; i++) {
5859 query.append(_ORDER_BY_ENTITY_ALIAS);
5860 query.append(orderByFields[i]);
5861
5862 if ((i + 1) < orderByFields.length) {
5863 if (orderByComparator.isAscending() ^ previous) {
5864 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5865 }
5866 else {
5867 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5868 }
5869 }
5870 else {
5871 if (orderByComparator.isAscending() ^ previous) {
5872 query.append(WHERE_GREATER_THAN);
5873 }
5874 else {
5875 query.append(WHERE_LESSER_THAN);
5876 }
5877 }
5878 }
5879
5880 query.append(ORDER_BY_CLAUSE);
5881
5882 for (int i = 0; i < orderByFields.length; i++) {
5883 query.append(_ORDER_BY_ENTITY_ALIAS);
5884 query.append(orderByFields[i]);
5885
5886 if ((i + 1) < orderByFields.length) {
5887 if (orderByComparator.isAscending() ^ previous) {
5888 query.append(ORDER_BY_ASC_HAS_NEXT);
5889 }
5890 else {
5891 query.append(ORDER_BY_DESC_HAS_NEXT);
5892 }
5893 }
5894 else {
5895 if (orderByComparator.isAscending() ^ previous) {
5896 query.append(ORDER_BY_ASC);
5897 }
5898 else {
5899 query.append(ORDER_BY_DESC);
5900 }
5901 }
5902 }
5903 }
5904
5905 else {
5906 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
5907 }
5908
5909 String sql = query.toString();
5910
5911 Query q = session.createQuery(sql);
5912
5913 q.setFirstResult(0);
5914 q.setMaxResults(2);
5915
5916 QueryPos qPos = QueryPos.getInstance(q);
5917
5918 qPos.add(groupId);
5919
5920 qPos.add(categoryId);
5921
5922 qPos.add(status);
5923
5924 if (orderByComparator != null) {
5925 Object[] values = orderByComparator.getOrderByValues(mbMessage);
5926
5927 for (Object value : values) {
5928 qPos.add(value);
5929 }
5930 }
5931
5932 List<MBMessage> list = q.list();
5933
5934 if (list.size() == 2) {
5935 return list.get(1);
5936 }
5937 else {
5938 return null;
5939 }
5940 }
5941
5942 public List<MBMessage> filterFindByG_C_S(long groupId, long categoryId,
5943 int status) throws SystemException {
5944 return filterFindByG_C_S(groupId, categoryId, status,
5945 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5946 }
5947
5948 public List<MBMessage> filterFindByG_C_S(long groupId, long categoryId,
5949 int status, int start, int end) throws SystemException {
5950 return filterFindByG_C_S(groupId, categoryId, status, start, end, null);
5951 }
5952
5953 public List<MBMessage> filterFindByG_C_S(long groupId, long categoryId,
5954 int status, int start, int end, OrderByComparator orderByComparator)
5955 throws SystemException {
5956 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5957 return findByG_C_S(groupId, categoryId, status, start, end,
5958 orderByComparator);
5959 }
5960
5961 Session session = null;
5962
5963 try {
5964 session = openSession();
5965
5966 StringBundler query = null;
5967
5968 if (orderByComparator != null) {
5969 query = new StringBundler(5 +
5970 (orderByComparator.getOrderByFields().length * 3));
5971 }
5972 else {
5973 query = new StringBundler(5);
5974 }
5975
5976 query.append(_FILTER_SQL_SELECT_MBMESSAGE_WHERE);
5977
5978 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
5979
5980 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
5981
5982 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
5983
5984 if (orderByComparator != null) {
5985 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5986 orderByComparator);
5987 }
5988
5989 else {
5990 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
5991 }
5992
5993 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5994 MBMessage.class.getName(), _FILTER_COLUMN_MESSAGEID,
5995 _FILTER_COLUMN_USERID, groupId);
5996
5997 SQLQuery q = session.createSQLQuery(sql);
5998
5999 q.addEntity(_FILTER_ENTITY_ALIAS, MBMessageImpl.class);
6000
6001 QueryPos qPos = QueryPos.getInstance(q);
6002
6003 qPos.add(groupId);
6004
6005 qPos.add(categoryId);
6006
6007 qPos.add(status);
6008
6009 return (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end);
6010 }
6011 catch (Exception e) {
6012 throw processException(e);
6013 }
6014 finally {
6015 closeSession(session);
6016 }
6017 }
6018
6019 public List<MBMessage> findByC_C_S(long classNameId, long classPK,
6020 int status) throws SystemException {
6021 return findByC_C_S(classNameId, classPK, status, QueryUtil.ALL_POS,
6022 QueryUtil.ALL_POS, null);
6023 }
6024
6025 public List<MBMessage> findByC_C_S(long classNameId, long classPK,
6026 int status, int start, int end) throws SystemException {
6027 return findByC_C_S(classNameId, classPK, status, start, end, null);
6028 }
6029
6030 public List<MBMessage> findByC_C_S(long classNameId, long classPK,
6031 int status, int start, int end, OrderByComparator orderByComparator)
6032 throws SystemException {
6033 Object[] finderArgs = new Object[] {
6034 new Long(classNameId), new Long(classPK), new Integer(status),
6035
6036 String.valueOf(start), String.valueOf(end),
6037 String.valueOf(orderByComparator)
6038 };
6039
6040 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_C_S,
6041 finderArgs, this);
6042
6043 if (list == null) {
6044 Session session = null;
6045
6046 try {
6047 session = openSession();
6048
6049 StringBundler query = null;
6050
6051 if (orderByComparator != null) {
6052 query = new StringBundler(5 +
6053 (orderByComparator.getOrderByFields().length * 3));
6054 }
6055 else {
6056 query = new StringBundler(5);
6057 }
6058
6059 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
6060
6061 query.append(_FINDER_COLUMN_C_C_S_CLASSNAMEID_2);
6062
6063 query.append(_FINDER_COLUMN_C_C_S_CLASSPK_2);
6064
6065 query.append(_FINDER_COLUMN_C_C_S_STATUS_2);
6066
6067 if (orderByComparator != null) {
6068 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6069 orderByComparator);
6070 }
6071
6072 else {
6073 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
6074 }
6075
6076 String sql = query.toString();
6077
6078 Query q = session.createQuery(sql);
6079
6080 QueryPos qPos = QueryPos.getInstance(q);
6081
6082 qPos.add(classNameId);
6083
6084 qPos.add(classPK);
6085
6086 qPos.add(status);
6087
6088 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
6089 end);
6090 }
6091 catch (Exception e) {
6092 throw processException(e);
6093 }
6094 finally {
6095 if (list == null) {
6096 list = new ArrayList<MBMessage>();
6097 }
6098
6099 cacheResult(list);
6100
6101 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_C_S,
6102 finderArgs, list);
6103
6104 closeSession(session);
6105 }
6106 }
6107
6108 return list;
6109 }
6110
6111 public MBMessage findByC_C_S_First(long classNameId, long classPK,
6112 int status, OrderByComparator orderByComparator)
6113 throws NoSuchMessageException, SystemException {
6114 List<MBMessage> list = findByC_C_S(classNameId, classPK, status, 0, 1,
6115 orderByComparator);
6116
6117 if (list.isEmpty()) {
6118 StringBundler msg = new StringBundler(8);
6119
6120 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6121
6122 msg.append("classNameId=");
6123 msg.append(classNameId);
6124
6125 msg.append(", classPK=");
6126 msg.append(classPK);
6127
6128 msg.append(", status=");
6129 msg.append(status);
6130
6131 msg.append(StringPool.CLOSE_CURLY_BRACE);
6132
6133 throw new NoSuchMessageException(msg.toString());
6134 }
6135 else {
6136 return list.get(0);
6137 }
6138 }
6139
6140 public MBMessage findByC_C_S_Last(long classNameId, long classPK,
6141 int status, OrderByComparator orderByComparator)
6142 throws NoSuchMessageException, SystemException {
6143 int count = countByC_C_S(classNameId, classPK, status);
6144
6145 List<MBMessage> list = findByC_C_S(classNameId, classPK, status,
6146 count - 1, count, orderByComparator);
6147
6148 if (list.isEmpty()) {
6149 StringBundler msg = new StringBundler(8);
6150
6151 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6152
6153 msg.append("classNameId=");
6154 msg.append(classNameId);
6155
6156 msg.append(", classPK=");
6157 msg.append(classPK);
6158
6159 msg.append(", status=");
6160 msg.append(status);
6161
6162 msg.append(StringPool.CLOSE_CURLY_BRACE);
6163
6164 throw new NoSuchMessageException(msg.toString());
6165 }
6166 else {
6167 return list.get(0);
6168 }
6169 }
6170
6171 public MBMessage[] findByC_C_S_PrevAndNext(long messageId,
6172 long classNameId, long classPK, int status,
6173 OrderByComparator orderByComparator)
6174 throws NoSuchMessageException, SystemException {
6175 MBMessage mbMessage = findByPrimaryKey(messageId);
6176
6177 Session session = null;
6178
6179 try {
6180 session = openSession();
6181
6182 MBMessage[] array = new MBMessageImpl[3];
6183
6184 array[0] = getByC_C_S_PrevAndNext(session, mbMessage, classNameId,
6185 classPK, status, orderByComparator, true);
6186
6187 array[1] = mbMessage;
6188
6189 array[2] = getByC_C_S_PrevAndNext(session, mbMessage, classNameId,
6190 classPK, status, orderByComparator, false);
6191
6192 return array;
6193 }
6194 catch (Exception e) {
6195 throw processException(e);
6196 }
6197 finally {
6198 closeSession(session);
6199 }
6200 }
6201
6202 protected MBMessage getByC_C_S_PrevAndNext(Session session,
6203 MBMessage mbMessage, long classNameId, long classPK, int status,
6204 OrderByComparator orderByComparator, boolean previous) {
6205 StringBundler query = null;
6206
6207 if (orderByComparator != null) {
6208 query = new StringBundler(6 +
6209 (orderByComparator.getOrderByFields().length * 6));
6210 }
6211 else {
6212 query = new StringBundler(3);
6213 }
6214
6215 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
6216
6217 query.append(_FINDER_COLUMN_C_C_S_CLASSNAMEID_2);
6218
6219 query.append(_FINDER_COLUMN_C_C_S_CLASSPK_2);
6220
6221 query.append(_FINDER_COLUMN_C_C_S_STATUS_2);
6222
6223 if (orderByComparator != null) {
6224 String[] orderByFields = orderByComparator.getOrderByFields();
6225
6226 if (orderByFields.length > 0) {
6227 query.append(WHERE_AND);
6228 }
6229
6230 for (int i = 0; i < orderByFields.length; i++) {
6231 query.append(_ORDER_BY_ENTITY_ALIAS);
6232 query.append(orderByFields[i]);
6233
6234 if ((i + 1) < orderByFields.length) {
6235 if (orderByComparator.isAscending() ^ previous) {
6236 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6237 }
6238 else {
6239 query.append(WHERE_LESSER_THAN_HAS_NEXT);
6240 }
6241 }
6242 else {
6243 if (orderByComparator.isAscending() ^ previous) {
6244 query.append(WHERE_GREATER_THAN);
6245 }
6246 else {
6247 query.append(WHERE_LESSER_THAN);
6248 }
6249 }
6250 }
6251
6252 query.append(ORDER_BY_CLAUSE);
6253
6254 for (int i = 0; i < orderByFields.length; i++) {
6255 query.append(_ORDER_BY_ENTITY_ALIAS);
6256 query.append(orderByFields[i]);
6257
6258 if ((i + 1) < orderByFields.length) {
6259 if (orderByComparator.isAscending() ^ previous) {
6260 query.append(ORDER_BY_ASC_HAS_NEXT);
6261 }
6262 else {
6263 query.append(ORDER_BY_DESC_HAS_NEXT);
6264 }
6265 }
6266 else {
6267 if (orderByComparator.isAscending() ^ previous) {
6268 query.append(ORDER_BY_ASC);
6269 }
6270 else {
6271 query.append(ORDER_BY_DESC);
6272 }
6273 }
6274 }
6275 }
6276
6277 else {
6278 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
6279 }
6280
6281 String sql = query.toString();
6282
6283 Query q = session.createQuery(sql);
6284
6285 q.setFirstResult(0);
6286 q.setMaxResults(2);
6287
6288 QueryPos qPos = QueryPos.getInstance(q);
6289
6290 qPos.add(classNameId);
6291
6292 qPos.add(classPK);
6293
6294 qPos.add(status);
6295
6296 if (orderByComparator != null) {
6297 Object[] values = orderByComparator.getOrderByValues(mbMessage);
6298
6299 for (Object value : values) {
6300 qPos.add(value);
6301 }
6302 }
6303
6304 List<MBMessage> list = q.list();
6305
6306 if (list.size() == 2) {
6307 return list.get(1);
6308 }
6309 else {
6310 return null;
6311 }
6312 }
6313
6314 public List<MBMessage> findByG_C_T_S(long groupId, long categoryId,
6315 long threadId, int status) throws SystemException {
6316 return findByG_C_T_S(groupId, categoryId, threadId, status,
6317 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6318 }
6319
6320 public List<MBMessage> findByG_C_T_S(long groupId, long categoryId,
6321 long threadId, int status, int start, int end)
6322 throws SystemException {
6323 return findByG_C_T_S(groupId, categoryId, threadId, status, start, end,
6324 null);
6325 }
6326
6327 public List<MBMessage> findByG_C_T_S(long groupId, long categoryId,
6328 long threadId, int status, int start, int end,
6329 OrderByComparator orderByComparator) throws SystemException {
6330 Object[] finderArgs = new Object[] {
6331 new Long(groupId), new Long(categoryId), new Long(threadId),
6332 new Integer(status),
6333
6334 String.valueOf(start), String.valueOf(end),
6335 String.valueOf(orderByComparator)
6336 };
6337
6338 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_C_T_S,
6339 finderArgs, this);
6340
6341 if (list == null) {
6342 Session session = null;
6343
6344 try {
6345 session = openSession();
6346
6347 StringBundler query = null;
6348
6349 if (orderByComparator != null) {
6350 query = new StringBundler(6 +
6351 (orderByComparator.getOrderByFields().length * 3));
6352 }
6353 else {
6354 query = new StringBundler(6);
6355 }
6356
6357 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
6358
6359 query.append(_FINDER_COLUMN_G_C_T_S_GROUPID_2);
6360
6361 query.append(_FINDER_COLUMN_G_C_T_S_CATEGORYID_2);
6362
6363 query.append(_FINDER_COLUMN_G_C_T_S_THREADID_2);
6364
6365 query.append(_FINDER_COLUMN_G_C_T_S_STATUS_2);
6366
6367 if (orderByComparator != null) {
6368 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6369 orderByComparator);
6370 }
6371
6372 else {
6373 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
6374 }
6375
6376 String sql = query.toString();
6377
6378 Query q = session.createQuery(sql);
6379
6380 QueryPos qPos = QueryPos.getInstance(q);
6381
6382 qPos.add(groupId);
6383
6384 qPos.add(categoryId);
6385
6386 qPos.add(threadId);
6387
6388 qPos.add(status);
6389
6390 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
6391 end);
6392 }
6393 catch (Exception e) {
6394 throw processException(e);
6395 }
6396 finally {
6397 if (list == null) {
6398 list = new ArrayList<MBMessage>();
6399 }
6400
6401 cacheResult(list);
6402
6403 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_C_T_S,
6404 finderArgs, list);
6405
6406 closeSession(session);
6407 }
6408 }
6409
6410 return list;
6411 }
6412
6413 public MBMessage findByG_C_T_S_First(long groupId, long categoryId,
6414 long threadId, int status, OrderByComparator orderByComparator)
6415 throws NoSuchMessageException, SystemException {
6416 List<MBMessage> list = findByG_C_T_S(groupId, categoryId, threadId,
6417 status, 0, 1, orderByComparator);
6418
6419 if (list.isEmpty()) {
6420 StringBundler msg = new StringBundler(10);
6421
6422 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6423
6424 msg.append("groupId=");
6425 msg.append(groupId);
6426
6427 msg.append(", categoryId=");
6428 msg.append(categoryId);
6429
6430 msg.append(", threadId=");
6431 msg.append(threadId);
6432
6433 msg.append(", status=");
6434 msg.append(status);
6435
6436 msg.append(StringPool.CLOSE_CURLY_BRACE);
6437
6438 throw new NoSuchMessageException(msg.toString());
6439 }
6440 else {
6441 return list.get(0);
6442 }
6443 }
6444
6445 public MBMessage findByG_C_T_S_Last(long groupId, long categoryId,
6446 long threadId, int status, OrderByComparator orderByComparator)
6447 throws NoSuchMessageException, SystemException {
6448 int count = countByG_C_T_S(groupId, categoryId, threadId, status);
6449
6450 List<MBMessage> list = findByG_C_T_S(groupId, categoryId, threadId,
6451 status, count - 1, count, orderByComparator);
6452
6453 if (list.isEmpty()) {
6454 StringBundler msg = new StringBundler(10);
6455
6456 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6457
6458 msg.append("groupId=");
6459 msg.append(groupId);
6460
6461 msg.append(", categoryId=");
6462 msg.append(categoryId);
6463
6464 msg.append(", threadId=");
6465 msg.append(threadId);
6466
6467 msg.append(", status=");
6468 msg.append(status);
6469
6470 msg.append(StringPool.CLOSE_CURLY_BRACE);
6471
6472 throw new NoSuchMessageException(msg.toString());
6473 }
6474 else {
6475 return list.get(0);
6476 }
6477 }
6478
6479 public MBMessage[] findByG_C_T_S_PrevAndNext(long messageId, long groupId,
6480 long categoryId, long threadId, int status,
6481 OrderByComparator orderByComparator)
6482 throws NoSuchMessageException, SystemException {
6483 MBMessage mbMessage = findByPrimaryKey(messageId);
6484
6485 Session session = null;
6486
6487 try {
6488 session = openSession();
6489
6490 MBMessage[] array = new MBMessageImpl[3];
6491
6492 array[0] = getByG_C_T_S_PrevAndNext(session, mbMessage, groupId,
6493 categoryId, threadId, status, orderByComparator, true);
6494
6495 array[1] = mbMessage;
6496
6497 array[2] = getByG_C_T_S_PrevAndNext(session, mbMessage, groupId,
6498 categoryId, threadId, status, orderByComparator, false);
6499
6500 return array;
6501 }
6502 catch (Exception e) {
6503 throw processException(e);
6504 }
6505 finally {
6506 closeSession(session);
6507 }
6508 }
6509
6510 protected MBMessage getByG_C_T_S_PrevAndNext(Session session,
6511 MBMessage mbMessage, long groupId, long categoryId, long threadId,
6512 int status, OrderByComparator orderByComparator, boolean previous) {
6513 StringBundler query = null;
6514
6515 if (orderByComparator != null) {
6516 query = new StringBundler(6 +
6517 (orderByComparator.getOrderByFields().length * 6));
6518 }
6519 else {
6520 query = new StringBundler(3);
6521 }
6522
6523 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
6524
6525 query.append(_FINDER_COLUMN_G_C_T_S_GROUPID_2);
6526
6527 query.append(_FINDER_COLUMN_G_C_T_S_CATEGORYID_2);
6528
6529 query.append(_FINDER_COLUMN_G_C_T_S_THREADID_2);
6530
6531 query.append(_FINDER_COLUMN_G_C_T_S_STATUS_2);
6532
6533 if (orderByComparator != null) {
6534 String[] orderByFields = orderByComparator.getOrderByFields();
6535
6536 if (orderByFields.length > 0) {
6537 query.append(WHERE_AND);
6538 }
6539
6540 for (int i = 0; i < orderByFields.length; i++) {
6541 query.append(_ORDER_BY_ENTITY_ALIAS);
6542 query.append(orderByFields[i]);
6543
6544 if ((i + 1) < orderByFields.length) {
6545 if (orderByComparator.isAscending() ^ previous) {
6546 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6547 }
6548 else {
6549 query.append(WHERE_LESSER_THAN_HAS_NEXT);
6550 }
6551 }
6552 else {
6553 if (orderByComparator.isAscending() ^ previous) {
6554 query.append(WHERE_GREATER_THAN);
6555 }
6556 else {
6557 query.append(WHERE_LESSER_THAN);
6558 }
6559 }
6560 }
6561
6562 query.append(ORDER_BY_CLAUSE);
6563
6564 for (int i = 0; i < orderByFields.length; i++) {
6565 query.append(_ORDER_BY_ENTITY_ALIAS);
6566 query.append(orderByFields[i]);
6567
6568 if ((i + 1) < orderByFields.length) {
6569 if (orderByComparator.isAscending() ^ previous) {
6570 query.append(ORDER_BY_ASC_HAS_NEXT);
6571 }
6572 else {
6573 query.append(ORDER_BY_DESC_HAS_NEXT);
6574 }
6575 }
6576 else {
6577 if (orderByComparator.isAscending() ^ previous) {
6578 query.append(ORDER_BY_ASC);
6579 }
6580 else {
6581 query.append(ORDER_BY_DESC);
6582 }
6583 }
6584 }
6585 }
6586
6587 else {
6588 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
6589 }
6590
6591 String sql = query.toString();
6592
6593 Query q = session.createQuery(sql);
6594
6595 q.setFirstResult(0);
6596 q.setMaxResults(2);
6597
6598 QueryPos qPos = QueryPos.getInstance(q);
6599
6600 qPos.add(groupId);
6601
6602 qPos.add(categoryId);
6603
6604 qPos.add(threadId);
6605
6606 qPos.add(status);
6607
6608 if (orderByComparator != null) {
6609 Object[] values = orderByComparator.getOrderByValues(mbMessage);
6610
6611 for (Object value : values) {
6612 qPos.add(value);
6613 }
6614 }
6615
6616 List<MBMessage> list = q.list();
6617
6618 if (list.size() == 2) {
6619 return list.get(1);
6620 }
6621 else {
6622 return null;
6623 }
6624 }
6625
6626 public List<MBMessage> filterFindByG_C_T_S(long groupId, long categoryId,
6627 long threadId, int status) throws SystemException {
6628 return filterFindByG_C_T_S(groupId, categoryId, threadId, status,
6629 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6630 }
6631
6632 public List<MBMessage> filterFindByG_C_T_S(long groupId, long categoryId,
6633 long threadId, int status, int start, int end)
6634 throws SystemException {
6635 return filterFindByG_C_T_S(groupId, categoryId, threadId, status,
6636 start, end, null);
6637 }
6638
6639 public List<MBMessage> filterFindByG_C_T_S(long groupId, long categoryId,
6640 long threadId, int status, int start, int end,
6641 OrderByComparator orderByComparator) throws SystemException {
6642 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6643 return findByG_C_T_S(groupId, categoryId, threadId, status, start,
6644 end, orderByComparator);
6645 }
6646
6647 Session session = null;
6648
6649 try {
6650 session = openSession();
6651
6652 StringBundler query = null;
6653
6654 if (orderByComparator != null) {
6655 query = new StringBundler(6 +
6656 (orderByComparator.getOrderByFields().length * 3));
6657 }
6658 else {
6659 query = new StringBundler(6);
6660 }
6661
6662 query.append(_FILTER_SQL_SELECT_MBMESSAGE_WHERE);
6663
6664 query.append(_FINDER_COLUMN_G_C_T_S_GROUPID_2);
6665
6666 query.append(_FINDER_COLUMN_G_C_T_S_CATEGORYID_2);
6667
6668 query.append(_FINDER_COLUMN_G_C_T_S_THREADID_2);
6669
6670 query.append(_FINDER_COLUMN_G_C_T_S_STATUS_2);
6671
6672 if (orderByComparator != null) {
6673 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6674 orderByComparator);
6675 }
6676
6677 else {
6678 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
6679 }
6680
6681 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6682 MBMessage.class.getName(), _FILTER_COLUMN_MESSAGEID,
6683 _FILTER_COLUMN_USERID, groupId);
6684
6685 SQLQuery q = session.createSQLQuery(sql);
6686
6687 q.addEntity(_FILTER_ENTITY_ALIAS, MBMessageImpl.class);
6688
6689 QueryPos qPos = QueryPos.getInstance(q);
6690
6691 qPos.add(groupId);
6692
6693 qPos.add(categoryId);
6694
6695 qPos.add(threadId);
6696
6697 qPos.add(status);
6698
6699 return (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end);
6700 }
6701 catch (Exception e) {
6702 throw processException(e);
6703 }
6704 finally {
6705 closeSession(session);
6706 }
6707 }
6708
6709 public List<MBMessage> findAll() throws SystemException {
6710 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6711 }
6712
6713 public List<MBMessage> findAll(int start, int end)
6714 throws SystemException {
6715 return findAll(start, end, null);
6716 }
6717
6718 public List<MBMessage> findAll(int start, int end,
6719 OrderByComparator orderByComparator) throws SystemException {
6720 Object[] finderArgs = new Object[] {
6721 String.valueOf(start), String.valueOf(end),
6722 String.valueOf(orderByComparator)
6723 };
6724
6725 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
6726 finderArgs, this);
6727
6728 if (list == null) {
6729 Session session = null;
6730
6731 try {
6732 session = openSession();
6733
6734 StringBundler query = null;
6735 String sql = null;
6736
6737 if (orderByComparator != null) {
6738 query = new StringBundler(2 +
6739 (orderByComparator.getOrderByFields().length * 3));
6740
6741 query.append(_SQL_SELECT_MBMESSAGE);
6742
6743 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6744 orderByComparator);
6745
6746 sql = query.toString();
6747 }
6748
6749 else {
6750 sql = _SQL_SELECT_MBMESSAGE.concat(MBMessageModelImpl.ORDER_BY_JPQL);
6751 }
6752
6753 Query q = session.createQuery(sql);
6754
6755 if (orderByComparator == null) {
6756 list = (List<MBMessage>)QueryUtil.list(q, getDialect(),
6757 start, end, false);
6758
6759 Collections.sort(list);
6760 }
6761 else {
6762 list = (List<MBMessage>)QueryUtil.list(q, getDialect(),
6763 start, end);
6764 }
6765 }
6766 catch (Exception e) {
6767 throw processException(e);
6768 }
6769 finally {
6770 if (list == null) {
6771 list = new ArrayList<MBMessage>();
6772 }
6773
6774 cacheResult(list);
6775
6776 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
6777
6778 closeSession(session);
6779 }
6780 }
6781
6782 return list;
6783 }
6784
6785 public void removeByUuid(String uuid) throws SystemException {
6786 for (MBMessage mbMessage : findByUuid(uuid)) {
6787 remove(mbMessage);
6788 }
6789 }
6790
6791 public void removeByUUID_G(String uuid, long groupId)
6792 throws NoSuchMessageException, SystemException {
6793 MBMessage mbMessage = findByUUID_G(uuid, groupId);
6794
6795 remove(mbMessage);
6796 }
6797
6798 public void removeByGroupId(long groupId) throws SystemException {
6799 for (MBMessage mbMessage : findByGroupId(groupId)) {
6800 remove(mbMessage);
6801 }
6802 }
6803
6804 public void removeByCompanyId(long companyId) throws SystemException {
6805 for (MBMessage mbMessage : findByCompanyId(companyId)) {
6806 remove(mbMessage);
6807 }
6808 }
6809
6810 public void removeByThreadId(long threadId) throws SystemException {
6811 for (MBMessage mbMessage : findByThreadId(threadId)) {
6812 remove(mbMessage);
6813 }
6814 }
6815
6816 public void removeByThreadReplies(long threadId) throws SystemException {
6817 for (MBMessage mbMessage : findByThreadReplies(threadId)) {
6818 remove(mbMessage);
6819 }
6820 }
6821
6822 public void removeByUserId(long userId) throws SystemException {
6823 for (MBMessage mbMessage : findByUserId(userId)) {
6824 remove(mbMessage);
6825 }
6826 }
6827
6828 public void removeByG_U(long groupId, long userId)
6829 throws SystemException {
6830 for (MBMessage mbMessage : findByG_U(groupId, userId)) {
6831 remove(mbMessage);
6832 }
6833 }
6834
6835 public void removeByG_C(long groupId, long categoryId)
6836 throws SystemException {
6837 for (MBMessage mbMessage : findByG_C(groupId, categoryId)) {
6838 remove(mbMessage);
6839 }
6840 }
6841
6842 public void removeByG_S(long groupId, int status) throws SystemException {
6843 for (MBMessage mbMessage : findByG_S(groupId, status)) {
6844 remove(mbMessage);
6845 }
6846 }
6847
6848 public void removeByC_S(long companyId, int status)
6849 throws SystemException {
6850 for (MBMessage mbMessage : findByC_S(companyId, status)) {
6851 remove(mbMessage);
6852 }
6853 }
6854
6855 public void removeByC_C(long classNameId, long classPK)
6856 throws SystemException {
6857 for (MBMessage mbMessage : findByC_C(classNameId, classPK)) {
6858 remove(mbMessage);
6859 }
6860 }
6861
6862 public void removeByT_P(long threadId, long parentMessageId)
6863 throws SystemException {
6864 for (MBMessage mbMessage : findByT_P(threadId, parentMessageId)) {
6865 remove(mbMessage);
6866 }
6867 }
6868
6869 public void removeByT_S(long threadId, int status)
6870 throws SystemException {
6871 for (MBMessage mbMessage : findByT_S(threadId, status)) {
6872 remove(mbMessage);
6873 }
6874 }
6875
6876 public void removeByTR_S(long threadId, int status)
6877 throws SystemException {
6878 for (MBMessage mbMessage : findByTR_S(threadId, status)) {
6879 remove(mbMessage);
6880 }
6881 }
6882
6883 public void removeByG_U_S(long groupId, long userId, int status)
6884 throws SystemException {
6885 for (MBMessage mbMessage : findByG_U_S(groupId, userId, status)) {
6886 remove(mbMessage);
6887 }
6888 }
6889
6890 public void removeByG_C_T(long groupId, long categoryId, long threadId)
6891 throws SystemException {
6892 for (MBMessage mbMessage : findByG_C_T(groupId, categoryId, threadId)) {
6893 remove(mbMessage);
6894 }
6895 }
6896
6897 public void removeByG_C_S(long groupId, long categoryId, int status)
6898 throws SystemException {
6899 for (MBMessage mbMessage : findByG_C_S(groupId, categoryId, status)) {
6900 remove(mbMessage);
6901 }
6902 }
6903
6904 public void removeByC_C_S(long classNameId, long classPK, int status)
6905 throws SystemException {
6906 for (MBMessage mbMessage : findByC_C_S(classNameId, classPK, status)) {
6907 remove(mbMessage);
6908 }
6909 }
6910
6911 public void removeByG_C_T_S(long groupId, long categoryId, long threadId,
6912 int status) throws SystemException {
6913 for (MBMessage mbMessage : findByG_C_T_S(groupId, categoryId, threadId,
6914 status)) {
6915 remove(mbMessage);
6916 }
6917 }
6918
6919 public void removeAll() throws SystemException {
6920 for (MBMessage mbMessage : findAll()) {
6921 remove(mbMessage);
6922 }
6923 }
6924
6925 public int countByUuid(String uuid) throws SystemException {
6926 Object[] finderArgs = new Object[] { uuid };
6927
6928 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
6929 finderArgs, this);
6930
6931 if (count == null) {
6932 Session session = null;
6933
6934 try {
6935 session = openSession();
6936
6937 StringBundler query = new StringBundler(2);
6938
6939 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
6940
6941 if (uuid == null) {
6942 query.append(_FINDER_COLUMN_UUID_UUID_1);
6943 }
6944 else {
6945 if (uuid.equals(StringPool.BLANK)) {
6946 query.append(_FINDER_COLUMN_UUID_UUID_3);
6947 }
6948 else {
6949 query.append(_FINDER_COLUMN_UUID_UUID_2);
6950 }
6951 }
6952
6953 String sql = query.toString();
6954
6955 Query q = session.createQuery(sql);
6956
6957 QueryPos qPos = QueryPos.getInstance(q);
6958
6959 if (uuid != null) {
6960 qPos.add(uuid);
6961 }
6962
6963 count = (Long)q.uniqueResult();
6964 }
6965 catch (Exception e) {
6966 throw processException(e);
6967 }
6968 finally {
6969 if (count == null) {
6970 count = Long.valueOf(0);
6971 }
6972
6973 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
6974 finderArgs, count);
6975
6976 closeSession(session);
6977 }
6978 }
6979
6980 return count.intValue();
6981 }
6982
6983 public int countByUUID_G(String uuid, long groupId)
6984 throws SystemException {
6985 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
6986
6987 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
6988 finderArgs, this);
6989
6990 if (count == null) {
6991 Session session = null;
6992
6993 try {
6994 session = openSession();
6995
6996 StringBundler query = new StringBundler(3);
6997
6998 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
6999
7000 if (uuid == null) {
7001 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
7002 }
7003 else {
7004 if (uuid.equals(StringPool.BLANK)) {
7005 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
7006 }
7007 else {
7008 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
7009 }
7010 }
7011
7012 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
7013
7014 String sql = query.toString();
7015
7016 Query q = session.createQuery(sql);
7017
7018 QueryPos qPos = QueryPos.getInstance(q);
7019
7020 if (uuid != null) {
7021 qPos.add(uuid);
7022 }
7023
7024 qPos.add(groupId);
7025
7026 count = (Long)q.uniqueResult();
7027 }
7028 catch (Exception e) {
7029 throw processException(e);
7030 }
7031 finally {
7032 if (count == null) {
7033 count = Long.valueOf(0);
7034 }
7035
7036 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
7037 finderArgs, count);
7038
7039 closeSession(session);
7040 }
7041 }
7042
7043 return count.intValue();
7044 }
7045
7046 public int countByGroupId(long groupId) throws SystemException {
7047 Object[] finderArgs = new Object[] { new Long(groupId) };
7048
7049 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
7050 finderArgs, this);
7051
7052 if (count == null) {
7053 Session session = null;
7054
7055 try {
7056 session = openSession();
7057
7058 StringBundler query = new StringBundler(2);
7059
7060 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
7061
7062 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
7063
7064 String sql = query.toString();
7065
7066 Query q = session.createQuery(sql);
7067
7068 QueryPos qPos = QueryPos.getInstance(q);
7069
7070 qPos.add(groupId);
7071
7072 count = (Long)q.uniqueResult();
7073 }
7074 catch (Exception e) {
7075 throw processException(e);
7076 }
7077 finally {
7078 if (count == null) {
7079 count = Long.valueOf(0);
7080 }
7081
7082 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
7083 finderArgs, count);
7084
7085 closeSession(session);
7086 }
7087 }
7088
7089 return count.intValue();
7090 }
7091
7092 public int filterCountByGroupId(long groupId) throws SystemException {
7093 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7094 return countByGroupId(groupId);
7095 }
7096
7097 Session session = null;
7098
7099 try {
7100 session = openSession();
7101
7102 StringBundler query = new StringBundler(2);
7103
7104 query.append(_FILTER_SQL_COUNT_MBMESSAGE_WHERE);
7105
7106 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
7107
7108 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7109 MBMessage.class.getName(), _FILTER_COLUMN_MESSAGEID,
7110 _FILTER_COLUMN_USERID, groupId);
7111
7112 SQLQuery q = session.createSQLQuery(sql);
7113
7114 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
7115
7116 QueryPos qPos = QueryPos.getInstance(q);
7117
7118 qPos.add(groupId);
7119
7120 Long count = (Long)q.uniqueResult();
7121
7122 return count.intValue();
7123 }
7124 catch (Exception e) {
7125 throw processException(e);
7126 }
7127 finally {
7128 closeSession(session);
7129 }
7130 }
7131
7132 public int countByCompanyId(long companyId) throws SystemException {
7133 Object[] finderArgs = new Object[] { new Long(companyId) };
7134
7135 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
7136 finderArgs, this);
7137
7138 if (count == null) {
7139 Session session = null;
7140
7141 try {
7142 session = openSession();
7143
7144 StringBundler query = new StringBundler(2);
7145
7146 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
7147
7148 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
7149
7150 String sql = query.toString();
7151
7152 Query q = session.createQuery(sql);
7153
7154 QueryPos qPos = QueryPos.getInstance(q);
7155
7156 qPos.add(companyId);
7157
7158 count = (Long)q.uniqueResult();
7159 }
7160 catch (Exception e) {
7161 throw processException(e);
7162 }
7163 finally {
7164 if (count == null) {
7165 count = Long.valueOf(0);
7166 }
7167
7168 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
7169 finderArgs, count);
7170
7171 closeSession(session);
7172 }
7173 }
7174
7175 return count.intValue();
7176 }
7177
7178 public int countByThreadId(long threadId) throws SystemException {
7179 Object[] finderArgs = new Object[] { new Long(threadId) };
7180
7181 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_THREADID,
7182 finderArgs, this);
7183
7184 if (count == null) {
7185 Session session = null;
7186
7187 try {
7188 session = openSession();
7189
7190 StringBundler query = new StringBundler(2);
7191
7192 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
7193
7194 query.append(_FINDER_COLUMN_THREADID_THREADID_2);
7195
7196 String sql = query.toString();
7197
7198 Query q = session.createQuery(sql);
7199
7200 QueryPos qPos = QueryPos.getInstance(q);
7201
7202 qPos.add(threadId);
7203
7204 count = (Long)q.uniqueResult();
7205 }
7206 catch (Exception e) {
7207 throw processException(e);
7208 }
7209 finally {
7210 if (count == null) {
7211 count = Long.valueOf(0);
7212 }
7213
7214 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_THREADID,
7215 finderArgs, count);
7216
7217 closeSession(session);
7218 }
7219 }
7220
7221 return count.intValue();
7222 }
7223
7224 public int countByThreadReplies(long threadId) throws SystemException {
7225 Object[] finderArgs = new Object[] { new Long(threadId) };
7226
7227 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_THREADREPLIES,
7228 finderArgs, this);
7229
7230 if (count == null) {
7231 Session session = null;
7232
7233 try {
7234 session = openSession();
7235
7236 StringBundler query = new StringBundler(2);
7237
7238 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
7239
7240 query.append(_FINDER_COLUMN_THREADREPLIES_THREADID_2);
7241
7242 String sql = query.toString();
7243
7244 Query q = session.createQuery(sql);
7245
7246 QueryPos qPos = QueryPos.getInstance(q);
7247
7248 qPos.add(threadId);
7249
7250 count = (Long)q.uniqueResult();
7251 }
7252 catch (Exception e) {
7253 throw processException(e);
7254 }
7255 finally {
7256 if (count == null) {
7257 count = Long.valueOf(0);
7258 }
7259
7260 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_THREADREPLIES,
7261 finderArgs, count);
7262
7263 closeSession(session);
7264 }
7265 }
7266
7267 return count.intValue();
7268 }
7269
7270 public int countByUserId(long userId) throws SystemException {
7271 Object[] finderArgs = new Object[] { new Long(userId) };
7272
7273 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
7274 finderArgs, this);
7275
7276 if (count == null) {
7277 Session session = null;
7278
7279 try {
7280 session = openSession();
7281
7282 StringBundler query = new StringBundler(2);
7283
7284 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
7285
7286 query.append(_FINDER_COLUMN_USERID_USERID_2);
7287
7288 String sql = query.toString();
7289
7290 Query q = session.createQuery(sql);
7291
7292 QueryPos qPos = QueryPos.getInstance(q);
7293
7294 qPos.add(userId);
7295
7296 count = (Long)q.uniqueResult();
7297 }
7298 catch (Exception e) {
7299 throw processException(e);
7300 }
7301 finally {
7302 if (count == null) {
7303 count = Long.valueOf(0);
7304 }
7305
7306 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
7307 finderArgs, count);
7308
7309 closeSession(session);
7310 }
7311 }
7312
7313 return count.intValue();
7314 }
7315
7316 public int countByG_U(long groupId, long userId) throws SystemException {
7317 Object[] finderArgs = new Object[] { new Long(groupId), new Long(userId) };
7318
7319 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U,
7320 finderArgs, this);
7321
7322 if (count == null) {
7323 Session session = null;
7324
7325 try {
7326 session = openSession();
7327
7328 StringBundler query = new StringBundler(3);
7329
7330 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
7331
7332 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7333
7334 query.append(_FINDER_COLUMN_G_U_USERID_2);
7335
7336 String sql = query.toString();
7337
7338 Query q = session.createQuery(sql);
7339
7340 QueryPos qPos = QueryPos.getInstance(q);
7341
7342 qPos.add(groupId);
7343
7344 qPos.add(userId);
7345
7346 count = (Long)q.uniqueResult();
7347 }
7348 catch (Exception e) {
7349 throw processException(e);
7350 }
7351 finally {
7352 if (count == null) {
7353 count = Long.valueOf(0);
7354 }
7355
7356 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U, finderArgs,
7357 count);
7358
7359 closeSession(session);
7360 }
7361 }
7362
7363 return count.intValue();
7364 }
7365
7366 public int filterCountByG_U(long groupId, long userId)
7367 throws SystemException {
7368 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7369 return countByG_U(groupId, userId);
7370 }
7371
7372 Session session = null;
7373
7374 try {
7375 session = openSession();
7376
7377 StringBundler query = new StringBundler(3);
7378
7379 query.append(_FILTER_SQL_COUNT_MBMESSAGE_WHERE);
7380
7381 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7382
7383 query.append(_FINDER_COLUMN_G_U_USERID_2);
7384
7385 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7386 MBMessage.class.getName(), _FILTER_COLUMN_MESSAGEID,
7387 _FILTER_COLUMN_USERID, groupId);
7388
7389 SQLQuery q = session.createSQLQuery(sql);
7390
7391 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
7392
7393 QueryPos qPos = QueryPos.getInstance(q);
7394
7395 qPos.add(groupId);
7396
7397 qPos.add(userId);
7398
7399 Long count = (Long)q.uniqueResult();
7400
7401 return count.intValue();
7402 }
7403 catch (Exception e) {
7404 throw processException(e);
7405 }
7406 finally {
7407 closeSession(session);
7408 }
7409 }
7410
7411 public int countByG_C(long groupId, long categoryId)
7412 throws SystemException {
7413 Object[] finderArgs = new Object[] {
7414 new Long(groupId), new Long(categoryId)
7415 };
7416
7417 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C,
7418 finderArgs, this);
7419
7420 if (count == null) {
7421 Session session = null;
7422
7423 try {
7424 session = openSession();
7425
7426 StringBundler query = new StringBundler(3);
7427
7428 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
7429
7430 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
7431
7432 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
7433
7434 String sql = query.toString();
7435
7436 Query q = session.createQuery(sql);
7437
7438 QueryPos qPos = QueryPos.getInstance(q);
7439
7440 qPos.add(groupId);
7441
7442 qPos.add(categoryId);
7443
7444 count = (Long)q.uniqueResult();
7445 }
7446 catch (Exception e) {
7447 throw processException(e);
7448 }
7449 finally {
7450 if (count == null) {
7451 count = Long.valueOf(0);
7452 }
7453
7454 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C, finderArgs,
7455 count);
7456
7457 closeSession(session);
7458 }
7459 }
7460
7461 return count.intValue();
7462 }
7463
7464 public int filterCountByG_C(long groupId, long categoryId)
7465 throws SystemException {
7466 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7467 return countByG_C(groupId, categoryId);
7468 }
7469
7470 Session session = null;
7471
7472 try {
7473 session = openSession();
7474
7475 StringBundler query = new StringBundler(3);
7476
7477 query.append(_FILTER_SQL_COUNT_MBMESSAGE_WHERE);
7478
7479 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
7480
7481 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
7482
7483 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7484 MBMessage.class.getName(), _FILTER_COLUMN_MESSAGEID,
7485 _FILTER_COLUMN_USERID, groupId);
7486
7487 SQLQuery q = session.createSQLQuery(sql);
7488
7489 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
7490
7491 QueryPos qPos = QueryPos.getInstance(q);
7492
7493 qPos.add(groupId);
7494
7495 qPos.add(categoryId);
7496
7497 Long count = (Long)q.uniqueResult();
7498
7499 return count.intValue();
7500 }
7501 catch (Exception e) {
7502 throw processException(e);
7503 }
7504 finally {
7505 closeSession(session);
7506 }
7507 }
7508
7509 public int countByG_S(long groupId, int status) throws SystemException {
7510 Object[] finderArgs = new Object[] {
7511 new Long(groupId), new Integer(status)
7512 };
7513
7514 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_S,
7515 finderArgs, this);
7516
7517 if (count == null) {
7518 Session session = null;
7519
7520 try {
7521 session = openSession();
7522
7523 StringBundler query = new StringBundler(3);
7524
7525 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
7526
7527 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
7528
7529 query.append(_FINDER_COLUMN_G_S_STATUS_2);
7530
7531 String sql = query.toString();
7532
7533 Query q = session.createQuery(sql);
7534
7535 QueryPos qPos = QueryPos.getInstance(q);
7536
7537 qPos.add(groupId);
7538
7539 qPos.add(status);
7540
7541 count = (Long)q.uniqueResult();
7542 }
7543 catch (Exception e) {
7544 throw processException(e);
7545 }
7546 finally {
7547 if (count == null) {
7548 count = Long.valueOf(0);
7549 }
7550
7551 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_S, finderArgs,
7552 count);
7553
7554 closeSession(session);
7555 }
7556 }
7557
7558 return count.intValue();
7559 }
7560
7561 public int filterCountByG_S(long groupId, int status)
7562 throws SystemException {
7563 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7564 return countByG_S(groupId, status);
7565 }
7566
7567 Session session = null;
7568
7569 try {
7570 session = openSession();
7571
7572 StringBundler query = new StringBundler(3);
7573
7574 query.append(_FILTER_SQL_COUNT_MBMESSAGE_WHERE);
7575
7576 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
7577
7578 query.append(_FINDER_COLUMN_G_S_STATUS_2);
7579
7580 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7581 MBMessage.class.getName(), _FILTER_COLUMN_MESSAGEID,
7582 _FILTER_COLUMN_USERID, groupId);
7583
7584 SQLQuery q = session.createSQLQuery(sql);
7585
7586 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
7587
7588 QueryPos qPos = QueryPos.getInstance(q);
7589
7590 qPos.add(groupId);
7591
7592 qPos.add(status);
7593
7594 Long count = (Long)q.uniqueResult();
7595
7596 return count.intValue();
7597 }
7598 catch (Exception e) {
7599 throw processException(e);
7600 }
7601 finally {
7602 closeSession(session);
7603 }
7604 }
7605
7606 public int countByC_S(long companyId, int status) throws SystemException {
7607 Object[] finderArgs = new Object[] {
7608 new Long(companyId), new Integer(status)
7609 };
7610
7611 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_S,
7612 finderArgs, this);
7613
7614 if (count == null) {
7615 Session session = null;
7616
7617 try {
7618 session = openSession();
7619
7620 StringBundler query = new StringBundler(3);
7621
7622 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
7623
7624 query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
7625
7626 query.append(_FINDER_COLUMN_C_S_STATUS_2);
7627
7628 String sql = query.toString();
7629
7630 Query q = session.createQuery(sql);
7631
7632 QueryPos qPos = QueryPos.getInstance(q);
7633
7634 qPos.add(companyId);
7635
7636 qPos.add(status);
7637
7638 count = (Long)q.uniqueResult();
7639 }
7640 catch (Exception e) {
7641 throw processException(e);
7642 }
7643 finally {
7644 if (count == null) {
7645 count = Long.valueOf(0);
7646 }
7647
7648 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_S, finderArgs,
7649 count);
7650
7651 closeSession(session);
7652 }
7653 }
7654
7655 return count.intValue();
7656 }
7657
7658 public int countByC_C(long classNameId, long classPK)
7659 throws SystemException {
7660 Object[] finderArgs = new Object[] {
7661 new Long(classNameId), new Long(classPK)
7662 };
7663
7664 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
7665 finderArgs, this);
7666
7667 if (count == null) {
7668 Session session = null;
7669
7670 try {
7671 session = openSession();
7672
7673 StringBundler query = new StringBundler(3);
7674
7675 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
7676
7677 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
7678
7679 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
7680
7681 String sql = query.toString();
7682
7683 Query q = session.createQuery(sql);
7684
7685 QueryPos qPos = QueryPos.getInstance(q);
7686
7687 qPos.add(classNameId);
7688
7689 qPos.add(classPK);
7690
7691 count = (Long)q.uniqueResult();
7692 }
7693 catch (Exception e) {
7694 throw processException(e);
7695 }
7696 finally {
7697 if (count == null) {
7698 count = Long.valueOf(0);
7699 }
7700
7701 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
7702 count);
7703
7704 closeSession(session);
7705 }
7706 }
7707
7708 return count.intValue();
7709 }
7710
7711 public int countByT_P(long threadId, long parentMessageId)
7712 throws SystemException {
7713 Object[] finderArgs = new Object[] {
7714 new Long(threadId), new Long(parentMessageId)
7715 };
7716
7717 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_T_P,
7718 finderArgs, this);
7719
7720 if (count == null) {
7721 Session session = null;
7722
7723 try {
7724 session = openSession();
7725
7726 StringBundler query = new StringBundler(3);
7727
7728 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
7729
7730 query.append(_FINDER_COLUMN_T_P_THREADID_2);
7731
7732 query.append(_FINDER_COLUMN_T_P_PARENTMESSAGEID_2);
7733
7734 String sql = query.toString();
7735
7736 Query q = session.createQuery(sql);
7737
7738 QueryPos qPos = QueryPos.getInstance(q);
7739
7740 qPos.add(threadId);
7741
7742 qPos.add(parentMessageId);
7743
7744 count = (Long)q.uniqueResult();
7745 }
7746 catch (Exception e) {
7747 throw processException(e);
7748 }
7749 finally {
7750 if (count == null) {
7751 count = Long.valueOf(0);
7752 }
7753
7754 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_T_P, finderArgs,
7755 count);
7756
7757 closeSession(session);
7758 }
7759 }
7760
7761 return count.intValue();
7762 }
7763
7764 public int countByT_S(long threadId, int status) throws SystemException {
7765 Object[] finderArgs = new Object[] {
7766 new Long(threadId), new Integer(status)
7767 };
7768
7769 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_T_S,
7770 finderArgs, this);
7771
7772 if (count == null) {
7773 Session session = null;
7774
7775 try {
7776 session = openSession();
7777
7778 StringBundler query = new StringBundler(3);
7779
7780 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
7781
7782 query.append(_FINDER_COLUMN_T_S_THREADID_2);
7783
7784 query.append(_FINDER_COLUMN_T_S_STATUS_2);
7785
7786 String sql = query.toString();
7787
7788 Query q = session.createQuery(sql);
7789
7790 QueryPos qPos = QueryPos.getInstance(q);
7791
7792 qPos.add(threadId);
7793
7794 qPos.add(status);
7795
7796 count = (Long)q.uniqueResult();
7797 }
7798 catch (Exception e) {
7799 throw processException(e);
7800 }
7801 finally {
7802 if (count == null) {
7803 count = Long.valueOf(0);
7804 }
7805
7806 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_T_S, finderArgs,
7807 count);
7808
7809 closeSession(session);
7810 }
7811 }
7812
7813 return count.intValue();
7814 }
7815
7816 public int countByTR_S(long threadId, int status) throws SystemException {
7817 Object[] finderArgs = new Object[] {
7818 new Long(threadId), new Integer(status)
7819 };
7820
7821 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_TR_S,
7822 finderArgs, this);
7823
7824 if (count == null) {
7825 Session session = null;
7826
7827 try {
7828 session = openSession();
7829
7830 StringBundler query = new StringBundler(3);
7831
7832 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
7833
7834 query.append(_FINDER_COLUMN_TR_S_THREADID_2);
7835
7836 query.append(_FINDER_COLUMN_TR_S_STATUS_2);
7837
7838 String sql = query.toString();
7839
7840 Query q = session.createQuery(sql);
7841
7842 QueryPos qPos = QueryPos.getInstance(q);
7843
7844 qPos.add(threadId);
7845
7846 qPos.add(status);
7847
7848 count = (Long)q.uniqueResult();
7849 }
7850 catch (Exception e) {
7851 throw processException(e);
7852 }
7853 finally {
7854 if (count == null) {
7855 count = Long.valueOf(0);
7856 }
7857
7858 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_TR_S,
7859 finderArgs, count);
7860
7861 closeSession(session);
7862 }
7863 }
7864
7865 return count.intValue();
7866 }
7867
7868 public int countByG_U_S(long groupId, long userId, int status)
7869 throws SystemException {
7870 Object[] finderArgs = new Object[] {
7871 new Long(groupId), new Long(userId), new Integer(status)
7872 };
7873
7874 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U_S,
7875 finderArgs, this);
7876
7877 if (count == null) {
7878 Session session = null;
7879
7880 try {
7881 session = openSession();
7882
7883 StringBundler query = new StringBundler(4);
7884
7885 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
7886
7887 query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
7888
7889 query.append(_FINDER_COLUMN_G_U_S_USERID_2);
7890
7891 query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
7892
7893 String sql = query.toString();
7894
7895 Query q = session.createQuery(sql);
7896
7897 QueryPos qPos = QueryPos.getInstance(q);
7898
7899 qPos.add(groupId);
7900
7901 qPos.add(userId);
7902
7903 qPos.add(status);
7904
7905 count = (Long)q.uniqueResult();
7906 }
7907 catch (Exception e) {
7908 throw processException(e);
7909 }
7910 finally {
7911 if (count == null) {
7912 count = Long.valueOf(0);
7913 }
7914
7915 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U_S,
7916 finderArgs, count);
7917
7918 closeSession(session);
7919 }
7920 }
7921
7922 return count.intValue();
7923 }
7924
7925 public int filterCountByG_U_S(long groupId, long userId, int status)
7926 throws SystemException {
7927 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7928 return countByG_U_S(groupId, userId, status);
7929 }
7930
7931 Session session = null;
7932
7933 try {
7934 session = openSession();
7935
7936 StringBundler query = new StringBundler(4);
7937
7938 query.append(_FILTER_SQL_COUNT_MBMESSAGE_WHERE);
7939
7940 query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
7941
7942 query.append(_FINDER_COLUMN_G_U_S_USERID_2);
7943
7944 query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
7945
7946 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7947 MBMessage.class.getName(), _FILTER_COLUMN_MESSAGEID,
7948 _FILTER_COLUMN_USERID, groupId);
7949
7950 SQLQuery q = session.createSQLQuery(sql);
7951
7952 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
7953
7954 QueryPos qPos = QueryPos.getInstance(q);
7955
7956 qPos.add(groupId);
7957
7958 qPos.add(userId);
7959
7960 qPos.add(status);
7961
7962 Long count = (Long)q.uniqueResult();
7963
7964 return count.intValue();
7965 }
7966 catch (Exception e) {
7967 throw processException(e);
7968 }
7969 finally {
7970 closeSession(session);
7971 }
7972 }
7973
7974 public int countByG_C_T(long groupId, long categoryId, long threadId)
7975 throws SystemException {
7976 Object[] finderArgs = new Object[] {
7977 new Long(groupId), new Long(categoryId), new Long(threadId)
7978 };
7979
7980 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_T,
7981 finderArgs, this);
7982
7983 if (count == null) {
7984 Session session = null;
7985
7986 try {
7987 session = openSession();
7988
7989 StringBundler query = new StringBundler(4);
7990
7991 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
7992
7993 query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
7994
7995 query.append(_FINDER_COLUMN_G_C_T_CATEGORYID_2);
7996
7997 query.append(_FINDER_COLUMN_G_C_T_THREADID_2);
7998
7999 String sql = query.toString();
8000
8001 Query q = session.createQuery(sql);
8002
8003 QueryPos qPos = QueryPos.getInstance(q);
8004
8005 qPos.add(groupId);
8006
8007 qPos.add(categoryId);
8008
8009 qPos.add(threadId);
8010
8011 count = (Long)q.uniqueResult();
8012 }
8013 catch (Exception e) {
8014 throw processException(e);
8015 }
8016 finally {
8017 if (count == null) {
8018 count = Long.valueOf(0);
8019 }
8020
8021 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_T,
8022 finderArgs, count);
8023
8024 closeSession(session);
8025 }
8026 }
8027
8028 return count.intValue();
8029 }
8030
8031 public int filterCountByG_C_T(long groupId, long categoryId, long threadId)
8032 throws SystemException {
8033 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8034 return countByG_C_T(groupId, categoryId, threadId);
8035 }
8036
8037 Session session = null;
8038
8039 try {
8040 session = openSession();
8041
8042 StringBundler query = new StringBundler(4);
8043
8044 query.append(_FILTER_SQL_COUNT_MBMESSAGE_WHERE);
8045
8046 query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
8047
8048 query.append(_FINDER_COLUMN_G_C_T_CATEGORYID_2);
8049
8050 query.append(_FINDER_COLUMN_G_C_T_THREADID_2);
8051
8052 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8053 MBMessage.class.getName(), _FILTER_COLUMN_MESSAGEID,
8054 _FILTER_COLUMN_USERID, groupId);
8055
8056 SQLQuery q = session.createSQLQuery(sql);
8057
8058 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
8059
8060 QueryPos qPos = QueryPos.getInstance(q);
8061
8062 qPos.add(groupId);
8063
8064 qPos.add(categoryId);
8065
8066 qPos.add(threadId);
8067
8068 Long count = (Long)q.uniqueResult();
8069
8070 return count.intValue();
8071 }
8072 catch (Exception e) {
8073 throw processException(e);
8074 }
8075 finally {
8076 closeSession(session);
8077 }
8078 }
8079
8080 public int countByG_C_S(long groupId, long categoryId, int status)
8081 throws SystemException {
8082 Object[] finderArgs = new Object[] {
8083 new Long(groupId), new Long(categoryId), new Integer(status)
8084 };
8085
8086 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_S,
8087 finderArgs, this);
8088
8089 if (count == null) {
8090 Session session = null;
8091
8092 try {
8093 session = openSession();
8094
8095 StringBundler query = new StringBundler(4);
8096
8097 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
8098
8099 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
8100
8101 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
8102
8103 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
8104
8105 String sql = query.toString();
8106
8107 Query q = session.createQuery(sql);
8108
8109 QueryPos qPos = QueryPos.getInstance(q);
8110
8111 qPos.add(groupId);
8112
8113 qPos.add(categoryId);
8114
8115 qPos.add(status);
8116
8117 count = (Long)q.uniqueResult();
8118 }
8119 catch (Exception e) {
8120 throw processException(e);
8121 }
8122 finally {
8123 if (count == null) {
8124 count = Long.valueOf(0);
8125 }
8126
8127 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S,
8128 finderArgs, count);
8129
8130 closeSession(session);
8131 }
8132 }
8133
8134 return count.intValue();
8135 }
8136
8137 public int filterCountByG_C_S(long groupId, long categoryId, int status)
8138 throws SystemException {
8139 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8140 return countByG_C_S(groupId, categoryId, status);
8141 }
8142
8143 Session session = null;
8144
8145 try {
8146 session = openSession();
8147
8148 StringBundler query = new StringBundler(4);
8149
8150 query.append(_FILTER_SQL_COUNT_MBMESSAGE_WHERE);
8151
8152 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
8153
8154 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
8155
8156 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
8157
8158 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8159 MBMessage.class.getName(), _FILTER_COLUMN_MESSAGEID,
8160 _FILTER_COLUMN_USERID, groupId);
8161
8162 SQLQuery q = session.createSQLQuery(sql);
8163
8164 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
8165
8166 QueryPos qPos = QueryPos.getInstance(q);
8167
8168 qPos.add(groupId);
8169
8170 qPos.add(categoryId);
8171
8172 qPos.add(status);
8173
8174 Long count = (Long)q.uniqueResult();
8175
8176 return count.intValue();
8177 }
8178 catch (Exception e) {
8179 throw processException(e);
8180 }
8181 finally {
8182 closeSession(session);
8183 }
8184 }
8185
8186 public int countByC_C_S(long classNameId, long classPK, int status)
8187 throws SystemException {
8188 Object[] finderArgs = new Object[] {
8189 new Long(classNameId), new Long(classPK), new Integer(status)
8190 };
8191
8192 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_S,
8193 finderArgs, this);
8194
8195 if (count == null) {
8196 Session session = null;
8197
8198 try {
8199 session = openSession();
8200
8201 StringBundler query = new StringBundler(4);
8202
8203 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
8204
8205 query.append(_FINDER_COLUMN_C_C_S_CLASSNAMEID_2);
8206
8207 query.append(_FINDER_COLUMN_C_C_S_CLASSPK_2);
8208
8209 query.append(_FINDER_COLUMN_C_C_S_STATUS_2);
8210
8211 String sql = query.toString();
8212
8213 Query q = session.createQuery(sql);
8214
8215 QueryPos qPos = QueryPos.getInstance(q);
8216
8217 qPos.add(classNameId);
8218
8219 qPos.add(classPK);
8220
8221 qPos.add(status);
8222
8223 count = (Long)q.uniqueResult();
8224 }
8225 catch (Exception e) {
8226 throw processException(e);
8227 }
8228 finally {
8229 if (count == null) {
8230 count = Long.valueOf(0);
8231 }
8232
8233 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_S,
8234 finderArgs, count);
8235
8236 closeSession(session);
8237 }
8238 }
8239
8240 return count.intValue();
8241 }
8242
8243 public int countByG_C_T_S(long groupId, long categoryId, long threadId,
8244 int status) throws SystemException {
8245 Object[] finderArgs = new Object[] {
8246 new Long(groupId), new Long(categoryId), new Long(threadId),
8247 new Integer(status)
8248 };
8249
8250 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_T_S,
8251 finderArgs, this);
8252
8253 if (count == null) {
8254 Session session = null;
8255
8256 try {
8257 session = openSession();
8258
8259 StringBundler query = new StringBundler(5);
8260
8261 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
8262
8263 query.append(_FINDER_COLUMN_G_C_T_S_GROUPID_2);
8264
8265 query.append(_FINDER_COLUMN_G_C_T_S_CATEGORYID_2);
8266
8267 query.append(_FINDER_COLUMN_G_C_T_S_THREADID_2);
8268
8269 query.append(_FINDER_COLUMN_G_C_T_S_STATUS_2);
8270
8271 String sql = query.toString();
8272
8273 Query q = session.createQuery(sql);
8274
8275 QueryPos qPos = QueryPos.getInstance(q);
8276
8277 qPos.add(groupId);
8278
8279 qPos.add(categoryId);
8280
8281 qPos.add(threadId);
8282
8283 qPos.add(status);
8284
8285 count = (Long)q.uniqueResult();
8286 }
8287 catch (Exception e) {
8288 throw processException(e);
8289 }
8290 finally {
8291 if (count == null) {
8292 count = Long.valueOf(0);
8293 }
8294
8295 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_T_S,
8296 finderArgs, count);
8297
8298 closeSession(session);
8299 }
8300 }
8301
8302 return count.intValue();
8303 }
8304
8305 public int filterCountByG_C_T_S(long groupId, long categoryId,
8306 long threadId, int status) throws SystemException {
8307 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8308 return countByG_C_T_S(groupId, categoryId, threadId, status);
8309 }
8310
8311 Session session = null;
8312
8313 try {
8314 session = openSession();
8315
8316 StringBundler query = new StringBundler(5);
8317
8318 query.append(_FILTER_SQL_COUNT_MBMESSAGE_WHERE);
8319
8320 query.append(_FINDER_COLUMN_G_C_T_S_GROUPID_2);
8321
8322 query.append(_FINDER_COLUMN_G_C_T_S_CATEGORYID_2);
8323
8324 query.append(_FINDER_COLUMN_G_C_T_S_THREADID_2);
8325
8326 query.append(_FINDER_COLUMN_G_C_T_S_STATUS_2);
8327
8328 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8329 MBMessage.class.getName(), _FILTER_COLUMN_MESSAGEID,
8330 _FILTER_COLUMN_USERID, groupId);
8331
8332 SQLQuery q = session.createSQLQuery(sql);
8333
8334 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
8335
8336 QueryPos qPos = QueryPos.getInstance(q);
8337
8338 qPos.add(groupId);
8339
8340 qPos.add(categoryId);
8341
8342 qPos.add(threadId);
8343
8344 qPos.add(status);
8345
8346 Long count = (Long)q.uniqueResult();
8347
8348 return count.intValue();
8349 }
8350 catch (Exception e) {
8351 throw processException(e);
8352 }
8353 finally {
8354 closeSession(session);
8355 }
8356 }
8357
8358 public int countAll() throws SystemException {
8359 Object[] finderArgs = new Object[0];
8360
8361 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
8362 finderArgs, this);
8363
8364 if (count == null) {
8365 Session session = null;
8366
8367 try {
8368 session = openSession();
8369
8370 Query q = session.createQuery(_SQL_COUNT_MBMESSAGE);
8371
8372 count = (Long)q.uniqueResult();
8373 }
8374 catch (Exception e) {
8375 throw processException(e);
8376 }
8377 finally {
8378 if (count == null) {
8379 count = Long.valueOf(0);
8380 }
8381
8382 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
8383 count);
8384
8385 closeSession(session);
8386 }
8387 }
8388
8389 return count.intValue();
8390 }
8391
8392 public void afterPropertiesSet() {
8393 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
8394 com.liferay.portal.util.PropsUtil.get(
8395 "value.object.listener.com.liferay.portlet.messageboards.model.MBMessage")));
8396
8397 if (listenerClassNames.length > 0) {
8398 try {
8399 List<ModelListener<MBMessage>> listenersList = new ArrayList<ModelListener<MBMessage>>();
8400
8401 for (String listenerClassName : listenerClassNames) {
8402 listenersList.add((ModelListener<MBMessage>)InstanceFactory.newInstance(
8403 listenerClassName));
8404 }
8405
8406 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
8407 }
8408 catch (Exception e) {
8409 _log.error(e);
8410 }
8411 }
8412 }
8413
8414 @BeanReference(type = MBBanPersistence.class)
8415 protected MBBanPersistence mbBanPersistence;
8416 @BeanReference(type = MBCategoryPersistence.class)
8417 protected MBCategoryPersistence mbCategoryPersistence;
8418 @BeanReference(type = MBDiscussionPersistence.class)
8419 protected MBDiscussionPersistence mbDiscussionPersistence;
8420 @BeanReference(type = MBMailingListPersistence.class)
8421 protected MBMailingListPersistence mbMailingListPersistence;
8422 @BeanReference(type = MBMessagePersistence.class)
8423 protected MBMessagePersistence mbMessagePersistence;
8424 @BeanReference(type = MBMessageFlagPersistence.class)
8425 protected MBMessageFlagPersistence mbMessageFlagPersistence;
8426 @BeanReference(type = MBStatsUserPersistence.class)
8427 protected MBStatsUserPersistence mbStatsUserPersistence;
8428 @BeanReference(type = MBThreadPersistence.class)
8429 protected MBThreadPersistence mbThreadPersistence;
8430 @BeanReference(type = CompanyPersistence.class)
8431 protected CompanyPersistence companyPersistence;
8432 @BeanReference(type = GroupPersistence.class)
8433 protected GroupPersistence groupPersistence;
8434 @BeanReference(type = LockPersistence.class)
8435 protected LockPersistence lockPersistence;
8436 @BeanReference(type = PortletPreferencesPersistence.class)
8437 protected PortletPreferencesPersistence portletPreferencesPersistence;
8438 @BeanReference(type = ResourcePersistence.class)
8439 protected ResourcePersistence resourcePersistence;
8440 @BeanReference(type = SubscriptionPersistence.class)
8441 protected SubscriptionPersistence subscriptionPersistence;
8442 @BeanReference(type = UserPersistence.class)
8443 protected UserPersistence userPersistence;
8444 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
8445 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
8446 @BeanReference(type = AssetEntryPersistence.class)
8447 protected AssetEntryPersistence assetEntryPersistence;
8448 @BeanReference(type = AssetTagPersistence.class)
8449 protected AssetTagPersistence assetTagPersistence;
8450 @BeanReference(type = BlogsEntryPersistence.class)
8451 protected BlogsEntryPersistence blogsEntryPersistence;
8452 @BeanReference(type = ExpandoValuePersistence.class)
8453 protected ExpandoValuePersistence expandoValuePersistence;
8454 @BeanReference(type = RatingsStatsPersistence.class)
8455 protected RatingsStatsPersistence ratingsStatsPersistence;
8456 @BeanReference(type = SocialActivityPersistence.class)
8457 protected SocialActivityPersistence socialActivityPersistence;
8458 @BeanReference(type = SocialEquityLogPersistence.class)
8459 protected SocialEquityLogPersistence socialEquityLogPersistence;
8460 private static final String _SQL_SELECT_MBMESSAGE = "SELECT mbMessage FROM MBMessage mbMessage";
8461 private static final String _SQL_SELECT_MBMESSAGE_WHERE = "SELECT mbMessage FROM MBMessage mbMessage WHERE ";
8462 private static final String _SQL_COUNT_MBMESSAGE = "SELECT COUNT(mbMessage) FROM MBMessage mbMessage";
8463 private static final String _SQL_COUNT_MBMESSAGE_WHERE = "SELECT COUNT(mbMessage) FROM MBMessage mbMessage WHERE ";
8464 private static final String _FINDER_COLUMN_UUID_UUID_1 = "mbMessage.uuid IS NULL";
8465 private static final String _FINDER_COLUMN_UUID_UUID_2 = "mbMessage.uuid = ?";
8466 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(mbMessage.uuid IS NULL OR mbMessage.uuid = ?)";
8467 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "mbMessage.uuid IS NULL AND ";
8468 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "mbMessage.uuid = ? AND ";
8469 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(mbMessage.uuid IS NULL OR mbMessage.uuid = ?) AND ";
8470 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "mbMessage.groupId = ?";
8471 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "mbMessage.groupId = ?";
8472 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "mbMessage.companyId = ?";
8473 private static final String _FINDER_COLUMN_THREADID_THREADID_2 = "mbMessage.threadId = ?";
8474 private static final String _FINDER_COLUMN_THREADREPLIES_THREADID_2 = "mbMessage.threadId = ? AND mbMessage.parentMessageId != 0";
8475 private static final String _FINDER_COLUMN_USERID_USERID_2 = "mbMessage.userId = ?";
8476 private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "mbMessage.groupId = ? AND ";
8477 private static final String _FINDER_COLUMN_G_U_USERID_2 = "mbMessage.userId = ?";
8478 private static final String _FINDER_COLUMN_G_C_GROUPID_2 = "mbMessage.groupId = ? AND ";
8479 private static final String _FINDER_COLUMN_G_C_CATEGORYID_2 = "mbMessage.categoryId = ?";
8480 private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "mbMessage.groupId = ? AND ";
8481 private static final String _FINDER_COLUMN_G_S_STATUS_2 = "mbMessage.status = ?";
8482 private static final String _FINDER_COLUMN_C_S_COMPANYID_2 = "mbMessage.companyId = ? AND ";
8483 private static final String _FINDER_COLUMN_C_S_STATUS_2 = "mbMessage.status = ?";
8484 private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "mbMessage.classNameId = ? AND ";
8485 private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "mbMessage.classPK = ?";
8486 private static final String _FINDER_COLUMN_T_P_THREADID_2 = "mbMessage.threadId = ? AND ";
8487 private static final String _FINDER_COLUMN_T_P_PARENTMESSAGEID_2 = "mbMessage.parentMessageId = ?";
8488 private static final String _FINDER_COLUMN_T_S_THREADID_2 = "mbMessage.threadId = ? AND ";
8489 private static final String _FINDER_COLUMN_T_S_STATUS_2 = "mbMessage.status = ?";
8490 private static final String _FINDER_COLUMN_TR_S_THREADID_2 = "mbMessage.threadId = ? AND ";
8491 private static final String _FINDER_COLUMN_TR_S_STATUS_2 = "mbMessage.status = ? AND mbMessage.parentMessageId != 0";
8492 private static final String _FINDER_COLUMN_G_U_S_GROUPID_2 = "mbMessage.groupId = ? AND ";
8493 private static final String _FINDER_COLUMN_G_U_S_USERID_2 = "mbMessage.userId = ? AND ";
8494 private static final String _FINDER_COLUMN_G_U_S_STATUS_2 = "mbMessage.status = ?";
8495 private static final String _FINDER_COLUMN_G_C_T_GROUPID_2 = "mbMessage.groupId = ? AND ";
8496 private static final String _FINDER_COLUMN_G_C_T_CATEGORYID_2 = "mbMessage.categoryId = ? AND ";
8497 private static final String _FINDER_COLUMN_G_C_T_THREADID_2 = "mbMessage.threadId = ?";
8498 private static final String _FINDER_COLUMN_G_C_S_GROUPID_2 = "mbMessage.groupId = ? AND ";
8499 private static final String _FINDER_COLUMN_G_C_S_CATEGORYID_2 = "mbMessage.categoryId = ? AND ";
8500 private static final String _FINDER_COLUMN_G_C_S_STATUS_2 = "mbMessage.status = ?";
8501 private static final String _FINDER_COLUMN_C_C_S_CLASSNAMEID_2 = "mbMessage.classNameId = ? AND ";
8502 private static final String _FINDER_COLUMN_C_C_S_CLASSPK_2 = "mbMessage.classPK = ? AND ";
8503 private static final String _FINDER_COLUMN_C_C_S_STATUS_2 = "mbMessage.status = ?";
8504 private static final String _FINDER_COLUMN_G_C_T_S_GROUPID_2 = "mbMessage.groupId = ? AND ";
8505 private static final String _FINDER_COLUMN_G_C_T_S_CATEGORYID_2 = "mbMessage.categoryId = ? AND ";
8506 private static final String _FINDER_COLUMN_G_C_T_S_THREADID_2 = "mbMessage.threadId = ? AND ";
8507 private static final String _FINDER_COLUMN_G_C_T_S_STATUS_2 = "mbMessage.status = ?";
8508 private static final String _FILTER_SQL_SELECT_MBMESSAGE_WHERE = "SELECT DISTINCT {mbMessage.*} FROM MBMessage mbMessage WHERE ";
8509 private static final String _FILTER_SQL_COUNT_MBMESSAGE_WHERE = "SELECT COUNT(DISTINCT mbMessage.messageId) AS COUNT_VALUE FROM MBMessage mbMessage WHERE ";
8510 private static final String _FILTER_COLUMN_MESSAGEID = "mbMessage.messageId";
8511 private static final String _FILTER_COLUMN_USERID = "mbMessage.userId";
8512 private static final String _FILTER_ENTITY_ALIAS = "mbMessage";
8513 private static final String _ORDER_BY_ENTITY_ALIAS = "mbMessage.";
8514 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MBMessage exists with the primary key ";
8515 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MBMessage exists with the key {";
8516 private static Log _log = LogFactoryUtil.getLog(MBMessagePersistenceImpl.class);
8517}