1
14
15 package com.liferay.portlet.messageboards.service.persistence;
16
17 import com.liferay.portal.NoSuchModelException;
18 import com.liferay.portal.SystemException;
19 import com.liferay.portal.kernel.annotation.BeanReference;
20 import com.liferay.portal.kernel.cache.CacheRegistry;
21 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
22 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
23 import com.liferay.portal.kernel.dao.orm.FinderPath;
24 import com.liferay.portal.kernel.dao.orm.Query;
25 import com.liferay.portal.kernel.dao.orm.QueryPos;
26 import com.liferay.portal.kernel.dao.orm.QueryUtil;
27 import com.liferay.portal.kernel.dao.orm.Session;
28 import com.liferay.portal.kernel.log.Log;
29 import com.liferay.portal.kernel.log.LogFactoryUtil;
30 import com.liferay.portal.kernel.util.GetterUtil;
31 import com.liferay.portal.kernel.util.OrderByComparator;
32 import com.liferay.portal.kernel.util.StringBundler;
33 import com.liferay.portal.kernel.util.StringPool;
34 import com.liferay.portal.kernel.util.StringUtil;
35 import com.liferay.portal.kernel.util.Validator;
36 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
37 import com.liferay.portal.model.ModelListener;
38 import com.liferay.portal.service.persistence.BatchSessionUtil;
39 import com.liferay.portal.service.persistence.CompanyPersistence;
40 import com.liferay.portal.service.persistence.GroupPersistence;
41 import com.liferay.portal.service.persistence.LockPersistence;
42 import com.liferay.portal.service.persistence.PortletPreferencesPersistence;
43 import com.liferay.portal.service.persistence.ResourcePersistence;
44 import com.liferay.portal.service.persistence.SubscriptionPersistence;
45 import com.liferay.portal.service.persistence.UserPersistence;
46 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
47
48 import com.liferay.portlet.blogs.service.persistence.BlogsEntryPersistence;
49 import com.liferay.portlet.messageboards.NoSuchMessageException;
50 import com.liferay.portlet.messageboards.model.MBMessage;
51 import com.liferay.portlet.messageboards.model.impl.MBMessageImpl;
52 import com.liferay.portlet.messageboards.model.impl.MBMessageModelImpl;
53 import com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence;
54 import com.liferay.portlet.social.service.persistence.SocialActivityPersistence;
55 import com.liferay.portlet.tags.service.persistence.TagsAssetPersistence;
56 import com.liferay.portlet.tags.service.persistence.TagsEntryPersistence;
57
58 import java.io.Serializable;
59
60 import java.util.ArrayList;
61 import java.util.Collections;
62 import java.util.List;
63
64
77 public class MBMessagePersistenceImpl extends BasePersistenceImpl<MBMessage>
78 implements MBMessagePersistence {
79 public static final String FINDER_CLASS_NAME_ENTITY = MBMessageImpl.class.getName();
80 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
81 ".List";
82 public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
83 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
84 "findByUuid", new String[] { String.class.getName() });
85 public static final FinderPath FINDER_PATH_FIND_BY_OBC_UUID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
86 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
87 "findByUuid",
88 new String[] {
89 String.class.getName(),
90
91 "java.lang.Integer", "java.lang.Integer",
92 "com.liferay.portal.kernel.util.OrderByComparator"
93 });
94 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
95 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
96 "countByUuid", new String[] { String.class.getName() });
97 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
98 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
99 "fetchByUUID_G",
100 new String[] { String.class.getName(), Long.class.getName() });
101 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
102 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
103 "countByUUID_G",
104 new String[] { String.class.getName(), Long.class.getName() });
105 public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
106 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
107 "findByCompanyId", new String[] { Long.class.getName() });
108 public static final FinderPath FINDER_PATH_FIND_BY_OBC_COMPANYID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
109 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
110 "findByCompanyId",
111 new String[] {
112 Long.class.getName(),
113
114 "java.lang.Integer", "java.lang.Integer",
115 "com.liferay.portal.kernel.util.OrderByComparator"
116 });
117 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
118 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
119 "countByCompanyId", new String[] { Long.class.getName() });
120 public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
121 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
122 "findByGroupId", new String[] { Long.class.getName() });
123 public static final FinderPath FINDER_PATH_FIND_BY_OBC_GROUPID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
124 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
125 "findByGroupId",
126 new String[] {
127 Long.class.getName(),
128
129 "java.lang.Integer", "java.lang.Integer",
130 "com.liferay.portal.kernel.util.OrderByComparator"
131 });
132 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
133 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
134 "countByGroupId", new String[] { Long.class.getName() });
135 public static final FinderPath FINDER_PATH_FIND_BY_CATEGORYID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
136 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
137 "findByCategoryId", new String[] { Long.class.getName() });
138 public static final FinderPath FINDER_PATH_FIND_BY_OBC_CATEGORYID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
139 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
140 "findByCategoryId",
141 new String[] {
142 Long.class.getName(),
143
144 "java.lang.Integer", "java.lang.Integer",
145 "com.liferay.portal.kernel.util.OrderByComparator"
146 });
147 public static final FinderPath FINDER_PATH_COUNT_BY_CATEGORYID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
148 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
149 "countByCategoryId", new String[] { Long.class.getName() });
150 public static final FinderPath FINDER_PATH_FIND_BY_THREADID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
151 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
152 "findByThreadId", new String[] { Long.class.getName() });
153 public static final FinderPath FINDER_PATH_FIND_BY_OBC_THREADID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
154 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
155 "findByThreadId",
156 new String[] {
157 Long.class.getName(),
158
159 "java.lang.Integer", "java.lang.Integer",
160 "com.liferay.portal.kernel.util.OrderByComparator"
161 });
162 public static final FinderPath FINDER_PATH_COUNT_BY_THREADID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
163 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
164 "countByThreadId", new String[] { Long.class.getName() });
165 public static final FinderPath FINDER_PATH_FIND_BY_THREADREPLIES = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
166 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
167 "findByThreadReplies", new String[] { Long.class.getName() });
168 public static final FinderPath FINDER_PATH_FIND_BY_OBC_THREADREPLIES = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
169 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
170 "findByThreadReplies",
171 new String[] {
172 Long.class.getName(),
173
174 "java.lang.Integer", "java.lang.Integer",
175 "com.liferay.portal.kernel.util.OrderByComparator"
176 });
177 public static final FinderPath FINDER_PATH_COUNT_BY_THREADREPLIES = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
178 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
179 "countByThreadReplies", new String[] { Long.class.getName() });
180 public static final FinderPath FINDER_PATH_FIND_BY_G_U = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
181 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
182 "findByG_U",
183 new String[] { Long.class.getName(), Long.class.getName() });
184 public static final FinderPath FINDER_PATH_FIND_BY_OBC_G_U = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
185 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
186 "findByG_U",
187 new String[] {
188 Long.class.getName(), Long.class.getName(),
189
190 "java.lang.Integer", "java.lang.Integer",
191 "com.liferay.portal.kernel.util.OrderByComparator"
192 });
193 public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
194 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
195 "countByG_U",
196 new String[] { Long.class.getName(), Long.class.getName() });
197 public static final FinderPath FINDER_PATH_FIND_BY_C_C = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
198 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
199 "findByC_C",
200 new String[] { Long.class.getName(), Long.class.getName() });
201 public static final FinderPath FINDER_PATH_FIND_BY_OBC_C_C = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
202 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
203 "findByC_C",
204 new String[] {
205 Long.class.getName(), Long.class.getName(),
206
207 "java.lang.Integer", "java.lang.Integer",
208 "com.liferay.portal.kernel.util.OrderByComparator"
209 });
210 public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
211 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
212 "countByC_C",
213 new String[] { Long.class.getName(), Long.class.getName() });
214 public static final FinderPath FINDER_PATH_FIND_BY_C_T = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
215 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
216 "findByC_T",
217 new String[] { Long.class.getName(), Long.class.getName() });
218 public static final FinderPath FINDER_PATH_FIND_BY_OBC_C_T = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
219 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
220 "findByC_T",
221 new String[] {
222 Long.class.getName(), Long.class.getName(),
223
224 "java.lang.Integer", "java.lang.Integer",
225 "com.liferay.portal.kernel.util.OrderByComparator"
226 });
227 public static final FinderPath FINDER_PATH_COUNT_BY_C_T = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
228 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
229 "countByC_T",
230 new String[] { Long.class.getName(), Long.class.getName() });
231 public static final FinderPath FINDER_PATH_FIND_BY_T_P = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
232 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
233 "findByT_P",
234 new String[] { Long.class.getName(), Long.class.getName() });
235 public static final FinderPath FINDER_PATH_FIND_BY_OBC_T_P = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
236 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
237 "findByT_P",
238 new String[] {
239 Long.class.getName(), Long.class.getName(),
240
241 "java.lang.Integer", "java.lang.Integer",
242 "com.liferay.portal.kernel.util.OrderByComparator"
243 });
244 public static final FinderPath FINDER_PATH_COUNT_BY_T_P = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
245 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
246 "countByT_P",
247 new String[] { Long.class.getName(), Long.class.getName() });
248 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
249 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
250 "findAll", new String[0]);
251 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
252 MBMessageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
253 "countAll", new String[0]);
254
255 public void cacheResult(MBMessage mbMessage) {
256 EntityCacheUtil.putResult(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
257 MBMessageImpl.class, mbMessage.getPrimaryKey(), mbMessage);
258
259 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
260 new Object[] { mbMessage.getUuid(), new Long(mbMessage.getGroupId()) },
261 mbMessage);
262 }
263
264 public void cacheResult(List<MBMessage> mbMessages) {
265 for (MBMessage mbMessage : mbMessages) {
266 if (EntityCacheUtil.getResult(
267 MBMessageModelImpl.ENTITY_CACHE_ENABLED,
268 MBMessageImpl.class, mbMessage.getPrimaryKey(), this) == null) {
269 cacheResult(mbMessage);
270 }
271 }
272 }
273
274 public void clearCache() {
275 CacheRegistry.clear(MBMessageImpl.class.getName());
276 EntityCacheUtil.clearCache(MBMessageImpl.class.getName());
277 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
278 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
279 }
280
281 public MBMessage create(long messageId) {
282 MBMessage mbMessage = new MBMessageImpl();
283
284 mbMessage.setNew(true);
285 mbMessage.setPrimaryKey(messageId);
286
287 String uuid = PortalUUIDUtil.generate();
288
289 mbMessage.setUuid(uuid);
290
291 return mbMessage;
292 }
293
294 public MBMessage remove(Serializable primaryKey)
295 throws NoSuchModelException, SystemException {
296 return remove(((Long)primaryKey).longValue());
297 }
298
299 public MBMessage remove(long messageId)
300 throws NoSuchMessageException, SystemException {
301 Session session = null;
302
303 try {
304 session = openSession();
305
306 MBMessage mbMessage = (MBMessage)session.get(MBMessageImpl.class,
307 new Long(messageId));
308
309 if (mbMessage == null) {
310 if (_log.isWarnEnabled()) {
311 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + messageId);
312 }
313
314 throw new NoSuchMessageException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
315 messageId);
316 }
317
318 return remove(mbMessage);
319 }
320 catch (NoSuchMessageException nsee) {
321 throw nsee;
322 }
323 catch (Exception e) {
324 throw processException(e);
325 }
326 finally {
327 closeSession(session);
328 }
329 }
330
331 public MBMessage remove(MBMessage mbMessage) throws SystemException {
332 for (ModelListener<MBMessage> listener : listeners) {
333 listener.onBeforeRemove(mbMessage);
334 }
335
336 mbMessage = removeImpl(mbMessage);
337
338 for (ModelListener<MBMessage> listener : listeners) {
339 listener.onAfterRemove(mbMessage);
340 }
341
342 return mbMessage;
343 }
344
345 protected MBMessage removeImpl(MBMessage mbMessage)
346 throws SystemException {
347 mbMessage = toUnwrappedModel(mbMessage);
348
349 Session session = null;
350
351 try {
352 session = openSession();
353
354 if (mbMessage.isCachedModel() || BatchSessionUtil.isEnabled()) {
355 Object staleObject = session.get(MBMessageImpl.class,
356 mbMessage.getPrimaryKeyObj());
357
358 if (staleObject != null) {
359 session.evict(staleObject);
360 }
361 }
362
363 session.delete(mbMessage);
364
365 session.flush();
366 }
367 catch (Exception e) {
368 throw processException(e);
369 }
370 finally {
371 closeSession(session);
372 }
373
374 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
375
376 MBMessageModelImpl mbMessageModelImpl = (MBMessageModelImpl)mbMessage;
377
378 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
379 new Object[] {
380 mbMessageModelImpl.getOriginalUuid(),
381 new Long(mbMessageModelImpl.getOriginalGroupId())
382 });
383
384 EntityCacheUtil.removeResult(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
385 MBMessageImpl.class, mbMessage.getPrimaryKey());
386
387 return mbMessage;
388 }
389
390
393 public MBMessage update(MBMessage mbMessage) throws SystemException {
394 if (_log.isWarnEnabled()) {
395 _log.warn(
396 "Using the deprecated update(MBMessage mbMessage) method. Use update(MBMessage mbMessage, boolean merge) instead.");
397 }
398
399 return update(mbMessage, false);
400 }
401
402 public MBMessage updateImpl(
403 com.liferay.portlet.messageboards.model.MBMessage mbMessage,
404 boolean merge) throws SystemException {
405 mbMessage = toUnwrappedModel(mbMessage);
406
407 boolean isNew = mbMessage.isNew();
408
409 MBMessageModelImpl mbMessageModelImpl = (MBMessageModelImpl)mbMessage;
410
411 if (Validator.isNull(mbMessage.getUuid())) {
412 String uuid = PortalUUIDUtil.generate();
413
414 mbMessage.setUuid(uuid);
415 }
416
417 Session session = null;
418
419 try {
420 session = openSession();
421
422 BatchSessionUtil.update(session, mbMessage, merge);
423
424 mbMessage.setNew(false);
425 }
426 catch (Exception e) {
427 throw processException(e);
428 }
429 finally {
430 closeSession(session);
431 }
432
433 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
434
435 EntityCacheUtil.putResult(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
436 MBMessageImpl.class, mbMessage.getPrimaryKey(), mbMessage);
437
438 if (!isNew &&
439 (!Validator.equals(mbMessage.getUuid(),
440 mbMessageModelImpl.getOriginalUuid()) ||
441 (mbMessage.getGroupId() != mbMessageModelImpl.getOriginalGroupId()))) {
442 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
443 new Object[] {
444 mbMessageModelImpl.getOriginalUuid(),
445 new Long(mbMessageModelImpl.getOriginalGroupId())
446 });
447 }
448
449 if (isNew ||
450 (!Validator.equals(mbMessage.getUuid(),
451 mbMessageModelImpl.getOriginalUuid()) ||
452 (mbMessage.getGroupId() != mbMessageModelImpl.getOriginalGroupId()))) {
453 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
454 new Object[] {
455 mbMessage.getUuid(), new Long(mbMessage.getGroupId())
456 }, mbMessage);
457 }
458
459 return mbMessage;
460 }
461
462 protected MBMessage toUnwrappedModel(MBMessage mbMessage) {
463 if (mbMessage instanceof MBMessageImpl) {
464 return mbMessage;
465 }
466
467 MBMessageImpl mbMessageImpl = new MBMessageImpl();
468
469 mbMessageImpl.setNew(mbMessage.isNew());
470 mbMessageImpl.setPrimaryKey(mbMessage.getPrimaryKey());
471
472 mbMessageImpl.setUuid(mbMessage.getUuid());
473 mbMessageImpl.setMessageId(mbMessage.getMessageId());
474 mbMessageImpl.setGroupId(mbMessage.getGroupId());
475 mbMessageImpl.setCompanyId(mbMessage.getCompanyId());
476 mbMessageImpl.setUserId(mbMessage.getUserId());
477 mbMessageImpl.setUserName(mbMessage.getUserName());
478 mbMessageImpl.setCreateDate(mbMessage.getCreateDate());
479 mbMessageImpl.setModifiedDate(mbMessage.getModifiedDate());
480 mbMessageImpl.setClassNameId(mbMessage.getClassNameId());
481 mbMessageImpl.setClassPK(mbMessage.getClassPK());
482 mbMessageImpl.setCategoryId(mbMessage.getCategoryId());
483 mbMessageImpl.setThreadId(mbMessage.getThreadId());
484 mbMessageImpl.setParentMessageId(mbMessage.getParentMessageId());
485 mbMessageImpl.setSubject(mbMessage.getSubject());
486 mbMessageImpl.setBody(mbMessage.getBody());
487 mbMessageImpl.setAttachments(mbMessage.isAttachments());
488 mbMessageImpl.setAnonymous(mbMessage.isAnonymous());
489 mbMessageImpl.setPriority(mbMessage.getPriority());
490
491 return mbMessageImpl;
492 }
493
494 public MBMessage findByPrimaryKey(Serializable primaryKey)
495 throws NoSuchModelException, SystemException {
496 return findByPrimaryKey(((Long)primaryKey).longValue());
497 }
498
499 public MBMessage findByPrimaryKey(long messageId)
500 throws NoSuchMessageException, SystemException {
501 MBMessage mbMessage = fetchByPrimaryKey(messageId);
502
503 if (mbMessage == null) {
504 if (_log.isWarnEnabled()) {
505 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + messageId);
506 }
507
508 throw new NoSuchMessageException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
509 messageId);
510 }
511
512 return mbMessage;
513 }
514
515 public MBMessage fetchByPrimaryKey(Serializable primaryKey)
516 throws SystemException {
517 return fetchByPrimaryKey(((Long)primaryKey).longValue());
518 }
519
520 public MBMessage fetchByPrimaryKey(long messageId)
521 throws SystemException {
522 MBMessage mbMessage = (MBMessage)EntityCacheUtil.getResult(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
523 MBMessageImpl.class, messageId, this);
524
525 if (mbMessage == null) {
526 Session session = null;
527
528 try {
529 session = openSession();
530
531 mbMessage = (MBMessage)session.get(MBMessageImpl.class,
532 new Long(messageId));
533 }
534 catch (Exception e) {
535 throw processException(e);
536 }
537 finally {
538 if (mbMessage != null) {
539 cacheResult(mbMessage);
540 }
541
542 closeSession(session);
543 }
544 }
545
546 return mbMessage;
547 }
548
549 public List<MBMessage> findByUuid(String uuid) throws SystemException {
550 Object[] finderArgs = new Object[] { uuid };
551
552 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
553 finderArgs, this);
554
555 if (list == null) {
556 Session session = null;
557
558 try {
559 session = openSession();
560
561 StringBundler query = new StringBundler(3);
562
563 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
564
565 if (uuid == null) {
566 query.append(_FINDER_COLUMN_UUID_UUID_1);
567 }
568 else {
569 if (uuid.equals(StringPool.BLANK)) {
570 query.append(_FINDER_COLUMN_UUID_UUID_3);
571 }
572 else {
573 query.append(_FINDER_COLUMN_UUID_UUID_2);
574 }
575 }
576
577 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
578
579 String sql = query.toString();
580
581 Query q = session.createQuery(sql);
582
583 QueryPos qPos = QueryPos.getInstance(q);
584
585 if (uuid != null) {
586 qPos.add(uuid);
587 }
588
589 list = q.list();
590 }
591 catch (Exception e) {
592 throw processException(e);
593 }
594 finally {
595 if (list == null) {
596 list = new ArrayList<MBMessage>();
597 }
598
599 cacheResult(list);
600
601 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
602 list);
603
604 closeSession(session);
605 }
606 }
607
608 return list;
609 }
610
611 public List<MBMessage> findByUuid(String uuid, int start, int end)
612 throws SystemException {
613 return findByUuid(uuid, start, end, null);
614 }
615
616 public List<MBMessage> findByUuid(String uuid, int start, int end,
617 OrderByComparator orderByComparator) throws SystemException {
618 Object[] finderArgs = new Object[] {
619 uuid,
620
621 String.valueOf(start), String.valueOf(end),
622 String.valueOf(orderByComparator)
623 };
624
625 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_UUID,
626 finderArgs, this);
627
628 if (list == null) {
629 Session session = null;
630
631 try {
632 session = openSession();
633
634 StringBundler query = null;
635
636 if (orderByComparator != null) {
637 query = new StringBundler(3 +
638 (orderByComparator.getOrderByFields().length * 3));
639 }
640 else {
641 query = new StringBundler(3);
642 }
643
644 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
645
646 if (uuid == null) {
647 query.append(_FINDER_COLUMN_UUID_UUID_1);
648 }
649 else {
650 if (uuid.equals(StringPool.BLANK)) {
651 query.append(_FINDER_COLUMN_UUID_UUID_3);
652 }
653 else {
654 query.append(_FINDER_COLUMN_UUID_UUID_2);
655 }
656 }
657
658 if (orderByComparator != null) {
659 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
660 orderByComparator);
661 }
662
663 else {
664 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
665 }
666
667 String sql = query.toString();
668
669 Query q = session.createQuery(sql);
670
671 QueryPos qPos = QueryPos.getInstance(q);
672
673 if (uuid != null) {
674 qPos.add(uuid);
675 }
676
677 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
678 end);
679 }
680 catch (Exception e) {
681 throw processException(e);
682 }
683 finally {
684 if (list == null) {
685 list = new ArrayList<MBMessage>();
686 }
687
688 cacheResult(list);
689
690 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_UUID,
691 finderArgs, list);
692
693 closeSession(session);
694 }
695 }
696
697 return list;
698 }
699
700 public MBMessage findByUuid_First(String uuid,
701 OrderByComparator orderByComparator)
702 throws NoSuchMessageException, SystemException {
703 List<MBMessage> list = findByUuid(uuid, 0, 1, orderByComparator);
704
705 if (list.isEmpty()) {
706 StringBundler msg = new StringBundler(4);
707
708 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
709
710 msg.append("uuid=");
711 msg.append(uuid);
712
713 msg.append(StringPool.CLOSE_CURLY_BRACE);
714
715 throw new NoSuchMessageException(msg.toString());
716 }
717 else {
718 return list.get(0);
719 }
720 }
721
722 public MBMessage findByUuid_Last(String uuid,
723 OrderByComparator orderByComparator)
724 throws NoSuchMessageException, SystemException {
725 int count = countByUuid(uuid);
726
727 List<MBMessage> list = findByUuid(uuid, count - 1, count,
728 orderByComparator);
729
730 if (list.isEmpty()) {
731 StringBundler msg = new StringBundler(4);
732
733 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
734
735 msg.append("uuid=");
736 msg.append(uuid);
737
738 msg.append(StringPool.CLOSE_CURLY_BRACE);
739
740 throw new NoSuchMessageException(msg.toString());
741 }
742 else {
743 return list.get(0);
744 }
745 }
746
747 public MBMessage[] findByUuid_PrevAndNext(long messageId, String uuid,
748 OrderByComparator orderByComparator)
749 throws NoSuchMessageException, SystemException {
750 MBMessage mbMessage = findByPrimaryKey(messageId);
751
752 int count = countByUuid(uuid);
753
754 Session session = null;
755
756 try {
757 session = openSession();
758
759 StringBundler query = null;
760
761 if (orderByComparator != null) {
762 query = new StringBundler(3 +
763 (orderByComparator.getOrderByFields().length * 3));
764 }
765 else {
766 query = new StringBundler(3);
767 }
768
769 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
770
771 if (uuid == null) {
772 query.append(_FINDER_COLUMN_UUID_UUID_1);
773 }
774 else {
775 if (uuid.equals(StringPool.BLANK)) {
776 query.append(_FINDER_COLUMN_UUID_UUID_3);
777 }
778 else {
779 query.append(_FINDER_COLUMN_UUID_UUID_2);
780 }
781 }
782
783 if (orderByComparator != null) {
784 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
785 orderByComparator);
786 }
787
788 else {
789 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
790 }
791
792 String sql = query.toString();
793
794 Query q = session.createQuery(sql);
795
796 QueryPos qPos = QueryPos.getInstance(q);
797
798 if (uuid != null) {
799 qPos.add(uuid);
800 }
801
802 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
803 orderByComparator, mbMessage);
804
805 MBMessage[] array = new MBMessageImpl[3];
806
807 array[0] = (MBMessage)objArray[0];
808 array[1] = (MBMessage)objArray[1];
809 array[2] = (MBMessage)objArray[2];
810
811 return array;
812 }
813 catch (Exception e) {
814 throw processException(e);
815 }
816 finally {
817 closeSession(session);
818 }
819 }
820
821 public MBMessage findByUUID_G(String uuid, long groupId)
822 throws NoSuchMessageException, SystemException {
823 MBMessage mbMessage = fetchByUUID_G(uuid, groupId);
824
825 if (mbMessage == null) {
826 StringBundler msg = new StringBundler(6);
827
828 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
829
830 msg.append("uuid=");
831 msg.append(uuid);
832
833 msg.append(", groupId=");
834 msg.append(groupId);
835
836 msg.append(StringPool.CLOSE_CURLY_BRACE);
837
838 if (_log.isWarnEnabled()) {
839 _log.warn(msg.toString());
840 }
841
842 throw new NoSuchMessageException(msg.toString());
843 }
844
845 return mbMessage;
846 }
847
848 public MBMessage fetchByUUID_G(String uuid, long groupId)
849 throws SystemException {
850 return fetchByUUID_G(uuid, groupId, true);
851 }
852
853 public MBMessage fetchByUUID_G(String uuid, long groupId,
854 boolean retrieveFromCache) throws SystemException {
855 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
856
857 Object result = null;
858
859 if (retrieveFromCache) {
860 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
861 finderArgs, this);
862 }
863
864 if (result == null) {
865 Session session = null;
866
867 try {
868 session = openSession();
869
870 StringBundler query = new StringBundler(4);
871
872 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
873
874 if (uuid == null) {
875 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
876 }
877 else {
878 if (uuid.equals(StringPool.BLANK)) {
879 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
880 }
881 else {
882 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
883 }
884 }
885
886 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
887
888 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
889
890 String sql = query.toString();
891
892 Query q = session.createQuery(sql);
893
894 QueryPos qPos = QueryPos.getInstance(q);
895
896 if (uuid != null) {
897 qPos.add(uuid);
898 }
899
900 qPos.add(groupId);
901
902 List<MBMessage> list = q.list();
903
904 result = list;
905
906 MBMessage mbMessage = null;
907
908 if (list.isEmpty()) {
909 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
910 finderArgs, list);
911 }
912 else {
913 mbMessage = list.get(0);
914
915 cacheResult(mbMessage);
916
917 if ((mbMessage.getUuid() == null) ||
918 !mbMessage.getUuid().equals(uuid) ||
919 (mbMessage.getGroupId() != groupId)) {
920 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
921 finderArgs, mbMessage);
922 }
923 }
924
925 return mbMessage;
926 }
927 catch (Exception e) {
928 throw processException(e);
929 }
930 finally {
931 if (result == null) {
932 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
933 finderArgs, new ArrayList<MBMessage>());
934 }
935
936 closeSession(session);
937 }
938 }
939 else {
940 if (result instanceof List<?>) {
941 return null;
942 }
943 else {
944 return (MBMessage)result;
945 }
946 }
947 }
948
949 public List<MBMessage> findByCompanyId(long companyId)
950 throws SystemException {
951 Object[] finderArgs = new Object[] { new Long(companyId) };
952
953 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
954 finderArgs, this);
955
956 if (list == null) {
957 Session session = null;
958
959 try {
960 session = openSession();
961
962 StringBundler query = new StringBundler(3);
963
964 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
965
966 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
967
968 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
969
970 String sql = query.toString();
971
972 Query q = session.createQuery(sql);
973
974 QueryPos qPos = QueryPos.getInstance(q);
975
976 qPos.add(companyId);
977
978 list = q.list();
979 }
980 catch (Exception e) {
981 throw processException(e);
982 }
983 finally {
984 if (list == null) {
985 list = new ArrayList<MBMessage>();
986 }
987
988 cacheResult(list);
989
990 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
991 finderArgs, list);
992
993 closeSession(session);
994 }
995 }
996
997 return list;
998 }
999
1000 public List<MBMessage> findByCompanyId(long companyId, int start, int end)
1001 throws SystemException {
1002 return findByCompanyId(companyId, start, end, null);
1003 }
1004
1005 public List<MBMessage> findByCompanyId(long companyId, int start, int end,
1006 OrderByComparator orderByComparator) throws SystemException {
1007 Object[] finderArgs = new Object[] {
1008 new Long(companyId),
1009
1010 String.valueOf(start), String.valueOf(end),
1011 String.valueOf(orderByComparator)
1012 };
1013
1014 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
1015 finderArgs, this);
1016
1017 if (list == null) {
1018 Session session = null;
1019
1020 try {
1021 session = openSession();
1022
1023 StringBundler query = null;
1024
1025 if (orderByComparator != null) {
1026 query = new StringBundler(3 +
1027 (orderByComparator.getOrderByFields().length * 3));
1028 }
1029 else {
1030 query = new StringBundler(3);
1031 }
1032
1033 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
1034
1035 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1036
1037 if (orderByComparator != null) {
1038 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1039 orderByComparator);
1040 }
1041
1042 else {
1043 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
1044 }
1045
1046 String sql = query.toString();
1047
1048 Query q = session.createQuery(sql);
1049
1050 QueryPos qPos = QueryPos.getInstance(q);
1051
1052 qPos.add(companyId);
1053
1054 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
1055 end);
1056 }
1057 catch (Exception e) {
1058 throw processException(e);
1059 }
1060 finally {
1061 if (list == null) {
1062 list = new ArrayList<MBMessage>();
1063 }
1064
1065 cacheResult(list);
1066
1067 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
1068 finderArgs, list);
1069
1070 closeSession(session);
1071 }
1072 }
1073
1074 return list;
1075 }
1076
1077 public MBMessage findByCompanyId_First(long companyId,
1078 OrderByComparator orderByComparator)
1079 throws NoSuchMessageException, SystemException {
1080 List<MBMessage> list = findByCompanyId(companyId, 0, 1,
1081 orderByComparator);
1082
1083 if (list.isEmpty()) {
1084 StringBundler msg = new StringBundler(4);
1085
1086 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1087
1088 msg.append("companyId=");
1089 msg.append(companyId);
1090
1091 msg.append(StringPool.CLOSE_CURLY_BRACE);
1092
1093 throw new NoSuchMessageException(msg.toString());
1094 }
1095 else {
1096 return list.get(0);
1097 }
1098 }
1099
1100 public MBMessage findByCompanyId_Last(long companyId,
1101 OrderByComparator orderByComparator)
1102 throws NoSuchMessageException, SystemException {
1103 int count = countByCompanyId(companyId);
1104
1105 List<MBMessage> list = findByCompanyId(companyId, count - 1, count,
1106 orderByComparator);
1107
1108 if (list.isEmpty()) {
1109 StringBundler msg = new StringBundler(4);
1110
1111 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1112
1113 msg.append("companyId=");
1114 msg.append(companyId);
1115
1116 msg.append(StringPool.CLOSE_CURLY_BRACE);
1117
1118 throw new NoSuchMessageException(msg.toString());
1119 }
1120 else {
1121 return list.get(0);
1122 }
1123 }
1124
1125 public MBMessage[] findByCompanyId_PrevAndNext(long messageId,
1126 long companyId, OrderByComparator orderByComparator)
1127 throws NoSuchMessageException, SystemException {
1128 MBMessage mbMessage = findByPrimaryKey(messageId);
1129
1130 int count = countByCompanyId(companyId);
1131
1132 Session session = null;
1133
1134 try {
1135 session = openSession();
1136
1137 StringBundler query = null;
1138
1139 if (orderByComparator != null) {
1140 query = new StringBundler(3 +
1141 (orderByComparator.getOrderByFields().length * 3));
1142 }
1143 else {
1144 query = new StringBundler(3);
1145 }
1146
1147 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
1148
1149 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1150
1151 if (orderByComparator != null) {
1152 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1153 orderByComparator);
1154 }
1155
1156 else {
1157 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
1158 }
1159
1160 String sql = query.toString();
1161
1162 Query q = session.createQuery(sql);
1163
1164 QueryPos qPos = QueryPos.getInstance(q);
1165
1166 qPos.add(companyId);
1167
1168 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
1169 orderByComparator, mbMessage);
1170
1171 MBMessage[] array = new MBMessageImpl[3];
1172
1173 array[0] = (MBMessage)objArray[0];
1174 array[1] = (MBMessage)objArray[1];
1175 array[2] = (MBMessage)objArray[2];
1176
1177 return array;
1178 }
1179 catch (Exception e) {
1180 throw processException(e);
1181 }
1182 finally {
1183 closeSession(session);
1184 }
1185 }
1186
1187 public List<MBMessage> findByGroupId(long groupId)
1188 throws SystemException {
1189 Object[] finderArgs = new Object[] { new Long(groupId) };
1190
1191 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
1192 finderArgs, this);
1193
1194 if (list == null) {
1195 Session session = null;
1196
1197 try {
1198 session = openSession();
1199
1200 StringBundler query = new StringBundler(3);
1201
1202 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
1203
1204 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1205
1206 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
1207
1208 String sql = query.toString();
1209
1210 Query q = session.createQuery(sql);
1211
1212 QueryPos qPos = QueryPos.getInstance(q);
1213
1214 qPos.add(groupId);
1215
1216 list = q.list();
1217 }
1218 catch (Exception e) {
1219 throw processException(e);
1220 }
1221 finally {
1222 if (list == null) {
1223 list = new ArrayList<MBMessage>();
1224 }
1225
1226 cacheResult(list);
1227
1228 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
1229 finderArgs, list);
1230
1231 closeSession(session);
1232 }
1233 }
1234
1235 return list;
1236 }
1237
1238 public List<MBMessage> findByGroupId(long groupId, int start, int end)
1239 throws SystemException {
1240 return findByGroupId(groupId, start, end, null);
1241 }
1242
1243 public List<MBMessage> findByGroupId(long groupId, int start, int end,
1244 OrderByComparator orderByComparator) throws SystemException {
1245 Object[] finderArgs = new Object[] {
1246 new Long(groupId),
1247
1248 String.valueOf(start), String.valueOf(end),
1249 String.valueOf(orderByComparator)
1250 };
1251
1252 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
1253 finderArgs, this);
1254
1255 if (list == null) {
1256 Session session = null;
1257
1258 try {
1259 session = openSession();
1260
1261 StringBundler query = null;
1262
1263 if (orderByComparator != null) {
1264 query = new StringBundler(3 +
1265 (orderByComparator.getOrderByFields().length * 3));
1266 }
1267 else {
1268 query = new StringBundler(3);
1269 }
1270
1271 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
1272
1273 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1274
1275 if (orderByComparator != null) {
1276 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1277 orderByComparator);
1278 }
1279
1280 else {
1281 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
1282 }
1283
1284 String sql = query.toString();
1285
1286 Query q = session.createQuery(sql);
1287
1288 QueryPos qPos = QueryPos.getInstance(q);
1289
1290 qPos.add(groupId);
1291
1292 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
1293 end);
1294 }
1295 catch (Exception e) {
1296 throw processException(e);
1297 }
1298 finally {
1299 if (list == null) {
1300 list = new ArrayList<MBMessage>();
1301 }
1302
1303 cacheResult(list);
1304
1305 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
1306 finderArgs, list);
1307
1308 closeSession(session);
1309 }
1310 }
1311
1312 return list;
1313 }
1314
1315 public MBMessage findByGroupId_First(long groupId,
1316 OrderByComparator orderByComparator)
1317 throws NoSuchMessageException, SystemException {
1318 List<MBMessage> list = findByGroupId(groupId, 0, 1, orderByComparator);
1319
1320 if (list.isEmpty()) {
1321 StringBundler msg = new StringBundler(4);
1322
1323 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1324
1325 msg.append("groupId=");
1326 msg.append(groupId);
1327
1328 msg.append(StringPool.CLOSE_CURLY_BRACE);
1329
1330 throw new NoSuchMessageException(msg.toString());
1331 }
1332 else {
1333 return list.get(0);
1334 }
1335 }
1336
1337 public MBMessage findByGroupId_Last(long groupId,
1338 OrderByComparator orderByComparator)
1339 throws NoSuchMessageException, SystemException {
1340 int count = countByGroupId(groupId);
1341
1342 List<MBMessage> list = findByGroupId(groupId, count - 1, count,
1343 orderByComparator);
1344
1345 if (list.isEmpty()) {
1346 StringBundler msg = new StringBundler(4);
1347
1348 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1349
1350 msg.append("groupId=");
1351 msg.append(groupId);
1352
1353 msg.append(StringPool.CLOSE_CURLY_BRACE);
1354
1355 throw new NoSuchMessageException(msg.toString());
1356 }
1357 else {
1358 return list.get(0);
1359 }
1360 }
1361
1362 public MBMessage[] findByGroupId_PrevAndNext(long messageId, long groupId,
1363 OrderByComparator orderByComparator)
1364 throws NoSuchMessageException, SystemException {
1365 MBMessage mbMessage = findByPrimaryKey(messageId);
1366
1367 int count = countByGroupId(groupId);
1368
1369 Session session = null;
1370
1371 try {
1372 session = openSession();
1373
1374 StringBundler query = null;
1375
1376 if (orderByComparator != null) {
1377 query = new StringBundler(3 +
1378 (orderByComparator.getOrderByFields().length * 3));
1379 }
1380 else {
1381 query = new StringBundler(3);
1382 }
1383
1384 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
1385
1386 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1387
1388 if (orderByComparator != null) {
1389 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1390 orderByComparator);
1391 }
1392
1393 else {
1394 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
1395 }
1396
1397 String sql = query.toString();
1398
1399 Query q = session.createQuery(sql);
1400
1401 QueryPos qPos = QueryPos.getInstance(q);
1402
1403 qPos.add(groupId);
1404
1405 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
1406 orderByComparator, mbMessage);
1407
1408 MBMessage[] array = new MBMessageImpl[3];
1409
1410 array[0] = (MBMessage)objArray[0];
1411 array[1] = (MBMessage)objArray[1];
1412 array[2] = (MBMessage)objArray[2];
1413
1414 return array;
1415 }
1416 catch (Exception e) {
1417 throw processException(e);
1418 }
1419 finally {
1420 closeSession(session);
1421 }
1422 }
1423
1424 public List<MBMessage> findByCategoryId(long categoryId)
1425 throws SystemException {
1426 Object[] finderArgs = new Object[] { new Long(categoryId) };
1427
1428 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_CATEGORYID,
1429 finderArgs, this);
1430
1431 if (list == null) {
1432 Session session = null;
1433
1434 try {
1435 session = openSession();
1436
1437 StringBundler query = new StringBundler(3);
1438
1439 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
1440
1441 query.append(_FINDER_COLUMN_CATEGORYID_CATEGORYID_2);
1442
1443 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
1444
1445 String sql = query.toString();
1446
1447 Query q = session.createQuery(sql);
1448
1449 QueryPos qPos = QueryPos.getInstance(q);
1450
1451 qPos.add(categoryId);
1452
1453 list = q.list();
1454 }
1455 catch (Exception e) {
1456 throw processException(e);
1457 }
1458 finally {
1459 if (list == null) {
1460 list = new ArrayList<MBMessage>();
1461 }
1462
1463 cacheResult(list);
1464
1465 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_CATEGORYID,
1466 finderArgs, list);
1467
1468 closeSession(session);
1469 }
1470 }
1471
1472 return list;
1473 }
1474
1475 public List<MBMessage> findByCategoryId(long categoryId, int start, int end)
1476 throws SystemException {
1477 return findByCategoryId(categoryId, start, end, null);
1478 }
1479
1480 public List<MBMessage> findByCategoryId(long categoryId, int start,
1481 int end, OrderByComparator orderByComparator) throws SystemException {
1482 Object[] finderArgs = new Object[] {
1483 new Long(categoryId),
1484
1485 String.valueOf(start), String.valueOf(end),
1486 String.valueOf(orderByComparator)
1487 };
1488
1489 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_CATEGORYID,
1490 finderArgs, this);
1491
1492 if (list == null) {
1493 Session session = null;
1494
1495 try {
1496 session = openSession();
1497
1498 StringBundler query = null;
1499
1500 if (orderByComparator != null) {
1501 query = new StringBundler(3 +
1502 (orderByComparator.getOrderByFields().length * 3));
1503 }
1504 else {
1505 query = new StringBundler(3);
1506 }
1507
1508 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
1509
1510 query.append(_FINDER_COLUMN_CATEGORYID_CATEGORYID_2);
1511
1512 if (orderByComparator != null) {
1513 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1514 orderByComparator);
1515 }
1516
1517 else {
1518 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
1519 }
1520
1521 String sql = query.toString();
1522
1523 Query q = session.createQuery(sql);
1524
1525 QueryPos qPos = QueryPos.getInstance(q);
1526
1527 qPos.add(categoryId);
1528
1529 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
1530 end);
1531 }
1532 catch (Exception e) {
1533 throw processException(e);
1534 }
1535 finally {
1536 if (list == null) {
1537 list = new ArrayList<MBMessage>();
1538 }
1539
1540 cacheResult(list);
1541
1542 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_CATEGORYID,
1543 finderArgs, list);
1544
1545 closeSession(session);
1546 }
1547 }
1548
1549 return list;
1550 }
1551
1552 public MBMessage findByCategoryId_First(long categoryId,
1553 OrderByComparator orderByComparator)
1554 throws NoSuchMessageException, SystemException {
1555 List<MBMessage> list = findByCategoryId(categoryId, 0, 1,
1556 orderByComparator);
1557
1558 if (list.isEmpty()) {
1559 StringBundler msg = new StringBundler(4);
1560
1561 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1562
1563 msg.append("categoryId=");
1564 msg.append(categoryId);
1565
1566 msg.append(StringPool.CLOSE_CURLY_BRACE);
1567
1568 throw new NoSuchMessageException(msg.toString());
1569 }
1570 else {
1571 return list.get(0);
1572 }
1573 }
1574
1575 public MBMessage findByCategoryId_Last(long categoryId,
1576 OrderByComparator orderByComparator)
1577 throws NoSuchMessageException, SystemException {
1578 int count = countByCategoryId(categoryId);
1579
1580 List<MBMessage> list = findByCategoryId(categoryId, count - 1, count,
1581 orderByComparator);
1582
1583 if (list.isEmpty()) {
1584 StringBundler msg = new StringBundler(4);
1585
1586 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1587
1588 msg.append("categoryId=");
1589 msg.append(categoryId);
1590
1591 msg.append(StringPool.CLOSE_CURLY_BRACE);
1592
1593 throw new NoSuchMessageException(msg.toString());
1594 }
1595 else {
1596 return list.get(0);
1597 }
1598 }
1599
1600 public MBMessage[] findByCategoryId_PrevAndNext(long messageId,
1601 long categoryId, OrderByComparator orderByComparator)
1602 throws NoSuchMessageException, SystemException {
1603 MBMessage mbMessage = findByPrimaryKey(messageId);
1604
1605 int count = countByCategoryId(categoryId);
1606
1607 Session session = null;
1608
1609 try {
1610 session = openSession();
1611
1612 StringBundler query = null;
1613
1614 if (orderByComparator != null) {
1615 query = new StringBundler(3 +
1616 (orderByComparator.getOrderByFields().length * 3));
1617 }
1618 else {
1619 query = new StringBundler(3);
1620 }
1621
1622 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
1623
1624 query.append(_FINDER_COLUMN_CATEGORYID_CATEGORYID_2);
1625
1626 if (orderByComparator != null) {
1627 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1628 orderByComparator);
1629 }
1630
1631 else {
1632 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
1633 }
1634
1635 String sql = query.toString();
1636
1637 Query q = session.createQuery(sql);
1638
1639 QueryPos qPos = QueryPos.getInstance(q);
1640
1641 qPos.add(categoryId);
1642
1643 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
1644 orderByComparator, mbMessage);
1645
1646 MBMessage[] array = new MBMessageImpl[3];
1647
1648 array[0] = (MBMessage)objArray[0];
1649 array[1] = (MBMessage)objArray[1];
1650 array[2] = (MBMessage)objArray[2];
1651
1652 return array;
1653 }
1654 catch (Exception e) {
1655 throw processException(e);
1656 }
1657 finally {
1658 closeSession(session);
1659 }
1660 }
1661
1662 public List<MBMessage> findByThreadId(long threadId)
1663 throws SystemException {
1664 Object[] finderArgs = new Object[] { new Long(threadId) };
1665
1666 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_THREADID,
1667 finderArgs, this);
1668
1669 if (list == null) {
1670 Session session = null;
1671
1672 try {
1673 session = openSession();
1674
1675 StringBundler query = new StringBundler(3);
1676
1677 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
1678
1679 query.append(_FINDER_COLUMN_THREADID_THREADID_2);
1680
1681 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
1682
1683 String sql = query.toString();
1684
1685 Query q = session.createQuery(sql);
1686
1687 QueryPos qPos = QueryPos.getInstance(q);
1688
1689 qPos.add(threadId);
1690
1691 list = q.list();
1692 }
1693 catch (Exception e) {
1694 throw processException(e);
1695 }
1696 finally {
1697 if (list == null) {
1698 list = new ArrayList<MBMessage>();
1699 }
1700
1701 cacheResult(list);
1702
1703 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_THREADID,
1704 finderArgs, list);
1705
1706 closeSession(session);
1707 }
1708 }
1709
1710 return list;
1711 }
1712
1713 public List<MBMessage> findByThreadId(long threadId, int start, int end)
1714 throws SystemException {
1715 return findByThreadId(threadId, start, end, null);
1716 }
1717
1718 public List<MBMessage> findByThreadId(long threadId, int start, int end,
1719 OrderByComparator orderByComparator) throws SystemException {
1720 Object[] finderArgs = new Object[] {
1721 new Long(threadId),
1722
1723 String.valueOf(start), String.valueOf(end),
1724 String.valueOf(orderByComparator)
1725 };
1726
1727 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_THREADID,
1728 finderArgs, this);
1729
1730 if (list == null) {
1731 Session session = null;
1732
1733 try {
1734 session = openSession();
1735
1736 StringBundler query = null;
1737
1738 if (orderByComparator != null) {
1739 query = new StringBundler(3 +
1740 (orderByComparator.getOrderByFields().length * 3));
1741 }
1742 else {
1743 query = new StringBundler(3);
1744 }
1745
1746 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
1747
1748 query.append(_FINDER_COLUMN_THREADID_THREADID_2);
1749
1750 if (orderByComparator != null) {
1751 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1752 orderByComparator);
1753 }
1754
1755 else {
1756 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
1757 }
1758
1759 String sql = query.toString();
1760
1761 Query q = session.createQuery(sql);
1762
1763 QueryPos qPos = QueryPos.getInstance(q);
1764
1765 qPos.add(threadId);
1766
1767 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
1768 end);
1769 }
1770 catch (Exception e) {
1771 throw processException(e);
1772 }
1773 finally {
1774 if (list == null) {
1775 list = new ArrayList<MBMessage>();
1776 }
1777
1778 cacheResult(list);
1779
1780 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_THREADID,
1781 finderArgs, list);
1782
1783 closeSession(session);
1784 }
1785 }
1786
1787 return list;
1788 }
1789
1790 public MBMessage findByThreadId_First(long threadId,
1791 OrderByComparator orderByComparator)
1792 throws NoSuchMessageException, SystemException {
1793 List<MBMessage> list = findByThreadId(threadId, 0, 1, orderByComparator);
1794
1795 if (list.isEmpty()) {
1796 StringBundler msg = new StringBundler(4);
1797
1798 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1799
1800 msg.append("threadId=");
1801 msg.append(threadId);
1802
1803 msg.append(StringPool.CLOSE_CURLY_BRACE);
1804
1805 throw new NoSuchMessageException(msg.toString());
1806 }
1807 else {
1808 return list.get(0);
1809 }
1810 }
1811
1812 public MBMessage findByThreadId_Last(long threadId,
1813 OrderByComparator orderByComparator)
1814 throws NoSuchMessageException, SystemException {
1815 int count = countByThreadId(threadId);
1816
1817 List<MBMessage> list = findByThreadId(threadId, count - 1, count,
1818 orderByComparator);
1819
1820 if (list.isEmpty()) {
1821 StringBundler msg = new StringBundler(4);
1822
1823 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1824
1825 msg.append("threadId=");
1826 msg.append(threadId);
1827
1828 msg.append(StringPool.CLOSE_CURLY_BRACE);
1829
1830 throw new NoSuchMessageException(msg.toString());
1831 }
1832 else {
1833 return list.get(0);
1834 }
1835 }
1836
1837 public MBMessage[] findByThreadId_PrevAndNext(long messageId,
1838 long threadId, OrderByComparator orderByComparator)
1839 throws NoSuchMessageException, SystemException {
1840 MBMessage mbMessage = findByPrimaryKey(messageId);
1841
1842 int count = countByThreadId(threadId);
1843
1844 Session session = null;
1845
1846 try {
1847 session = openSession();
1848
1849 StringBundler query = null;
1850
1851 if (orderByComparator != null) {
1852 query = new StringBundler(3 +
1853 (orderByComparator.getOrderByFields().length * 3));
1854 }
1855 else {
1856 query = new StringBundler(3);
1857 }
1858
1859 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
1860
1861 query.append(_FINDER_COLUMN_THREADID_THREADID_2);
1862
1863 if (orderByComparator != null) {
1864 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1865 orderByComparator);
1866 }
1867
1868 else {
1869 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
1870 }
1871
1872 String sql = query.toString();
1873
1874 Query q = session.createQuery(sql);
1875
1876 QueryPos qPos = QueryPos.getInstance(q);
1877
1878 qPos.add(threadId);
1879
1880 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
1881 orderByComparator, mbMessage);
1882
1883 MBMessage[] array = new MBMessageImpl[3];
1884
1885 array[0] = (MBMessage)objArray[0];
1886 array[1] = (MBMessage)objArray[1];
1887 array[2] = (MBMessage)objArray[2];
1888
1889 return array;
1890 }
1891 catch (Exception e) {
1892 throw processException(e);
1893 }
1894 finally {
1895 closeSession(session);
1896 }
1897 }
1898
1899 public List<MBMessage> findByThreadReplies(long threadId)
1900 throws SystemException {
1901 Object[] finderArgs = new Object[] { new Long(threadId) };
1902
1903 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_THREADREPLIES,
1904 finderArgs, this);
1905
1906 if (list == null) {
1907 Session session = null;
1908
1909 try {
1910 session = openSession();
1911
1912 StringBundler query = new StringBundler(3);
1913
1914 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
1915
1916 query.append(_FINDER_COLUMN_THREADREPLIES_THREADID_2);
1917
1918 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
1919
1920 String sql = query.toString();
1921
1922 Query q = session.createQuery(sql);
1923
1924 QueryPos qPos = QueryPos.getInstance(q);
1925
1926 qPos.add(threadId);
1927
1928 list = q.list();
1929 }
1930 catch (Exception e) {
1931 throw processException(e);
1932 }
1933 finally {
1934 if (list == null) {
1935 list = new ArrayList<MBMessage>();
1936 }
1937
1938 cacheResult(list);
1939
1940 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_THREADREPLIES,
1941 finderArgs, list);
1942
1943 closeSession(session);
1944 }
1945 }
1946
1947 return list;
1948 }
1949
1950 public List<MBMessage> findByThreadReplies(long threadId, int start, int end)
1951 throws SystemException {
1952 return findByThreadReplies(threadId, start, end, null);
1953 }
1954
1955 public List<MBMessage> findByThreadReplies(long threadId, int start,
1956 int end, OrderByComparator orderByComparator) throws SystemException {
1957 Object[] finderArgs = new Object[] {
1958 new Long(threadId),
1959
1960 String.valueOf(start), String.valueOf(end),
1961 String.valueOf(orderByComparator)
1962 };
1963
1964 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_THREADREPLIES,
1965 finderArgs, this);
1966
1967 if (list == null) {
1968 Session session = null;
1969
1970 try {
1971 session = openSession();
1972
1973 StringBundler query = null;
1974
1975 if (orderByComparator != null) {
1976 query = new StringBundler(3 +
1977 (orderByComparator.getOrderByFields().length * 3));
1978 }
1979 else {
1980 query = new StringBundler(3);
1981 }
1982
1983 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
1984
1985 query.append(_FINDER_COLUMN_THREADREPLIES_THREADID_2);
1986
1987 if (orderByComparator != null) {
1988 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1989 orderByComparator);
1990 }
1991
1992 else {
1993 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
1994 }
1995
1996 String sql = query.toString();
1997
1998 Query q = session.createQuery(sql);
1999
2000 QueryPos qPos = QueryPos.getInstance(q);
2001
2002 qPos.add(threadId);
2003
2004 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
2005 end);
2006 }
2007 catch (Exception e) {
2008 throw processException(e);
2009 }
2010 finally {
2011 if (list == null) {
2012 list = new ArrayList<MBMessage>();
2013 }
2014
2015 cacheResult(list);
2016
2017 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_THREADREPLIES,
2018 finderArgs, list);
2019
2020 closeSession(session);
2021 }
2022 }
2023
2024 return list;
2025 }
2026
2027 public MBMessage findByThreadReplies_First(long threadId,
2028 OrderByComparator orderByComparator)
2029 throws NoSuchMessageException, SystemException {
2030 List<MBMessage> list = findByThreadReplies(threadId, 0, 1,
2031 orderByComparator);
2032
2033 if (list.isEmpty()) {
2034 StringBundler msg = new StringBundler(4);
2035
2036 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2037
2038 msg.append("threadId=");
2039 msg.append(threadId);
2040
2041 msg.append(StringPool.CLOSE_CURLY_BRACE);
2042
2043 throw new NoSuchMessageException(msg.toString());
2044 }
2045 else {
2046 return list.get(0);
2047 }
2048 }
2049
2050 public MBMessage findByThreadReplies_Last(long threadId,
2051 OrderByComparator orderByComparator)
2052 throws NoSuchMessageException, SystemException {
2053 int count = countByThreadReplies(threadId);
2054
2055 List<MBMessage> list = findByThreadReplies(threadId, count - 1, count,
2056 orderByComparator);
2057
2058 if (list.isEmpty()) {
2059 StringBundler msg = new StringBundler(4);
2060
2061 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2062
2063 msg.append("threadId=");
2064 msg.append(threadId);
2065
2066 msg.append(StringPool.CLOSE_CURLY_BRACE);
2067
2068 throw new NoSuchMessageException(msg.toString());
2069 }
2070 else {
2071 return list.get(0);
2072 }
2073 }
2074
2075 public MBMessage[] findByThreadReplies_PrevAndNext(long messageId,
2076 long threadId, OrderByComparator orderByComparator)
2077 throws NoSuchMessageException, SystemException {
2078 MBMessage mbMessage = findByPrimaryKey(messageId);
2079
2080 int count = countByThreadReplies(threadId);
2081
2082 Session session = null;
2083
2084 try {
2085 session = openSession();
2086
2087 StringBundler query = null;
2088
2089 if (orderByComparator != null) {
2090 query = new StringBundler(3 +
2091 (orderByComparator.getOrderByFields().length * 3));
2092 }
2093 else {
2094 query = new StringBundler(3);
2095 }
2096
2097 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
2098
2099 query.append(_FINDER_COLUMN_THREADREPLIES_THREADID_2);
2100
2101 if (orderByComparator != null) {
2102 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2103 orderByComparator);
2104 }
2105
2106 else {
2107 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
2108 }
2109
2110 String sql = query.toString();
2111
2112 Query q = session.createQuery(sql);
2113
2114 QueryPos qPos = QueryPos.getInstance(q);
2115
2116 qPos.add(threadId);
2117
2118 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
2119 orderByComparator, mbMessage);
2120
2121 MBMessage[] array = new MBMessageImpl[3];
2122
2123 array[0] = (MBMessage)objArray[0];
2124 array[1] = (MBMessage)objArray[1];
2125 array[2] = (MBMessage)objArray[2];
2126
2127 return array;
2128 }
2129 catch (Exception e) {
2130 throw processException(e);
2131 }
2132 finally {
2133 closeSession(session);
2134 }
2135 }
2136
2137 public List<MBMessage> findByG_U(long groupId, long userId)
2138 throws SystemException {
2139 Object[] finderArgs = new Object[] { new Long(groupId), new Long(userId) };
2140
2141 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_U,
2142 finderArgs, this);
2143
2144 if (list == null) {
2145 Session session = null;
2146
2147 try {
2148 session = openSession();
2149
2150 StringBundler query = new StringBundler(4);
2151
2152 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
2153
2154 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2155
2156 query.append(_FINDER_COLUMN_G_U_USERID_2);
2157
2158 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
2159
2160 String sql = query.toString();
2161
2162 Query q = session.createQuery(sql);
2163
2164 QueryPos qPos = QueryPos.getInstance(q);
2165
2166 qPos.add(groupId);
2167
2168 qPos.add(userId);
2169
2170 list = q.list();
2171 }
2172 catch (Exception e) {
2173 throw processException(e);
2174 }
2175 finally {
2176 if (list == null) {
2177 list = new ArrayList<MBMessage>();
2178 }
2179
2180 cacheResult(list);
2181
2182 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_U, finderArgs,
2183 list);
2184
2185 closeSession(session);
2186 }
2187 }
2188
2189 return list;
2190 }
2191
2192 public List<MBMessage> findByG_U(long groupId, long userId, int start,
2193 int end) throws SystemException {
2194 return findByG_U(groupId, userId, start, end, null);
2195 }
2196
2197 public List<MBMessage> findByG_U(long groupId, long userId, int start,
2198 int end, OrderByComparator orderByComparator) throws SystemException {
2199 Object[] finderArgs = new Object[] {
2200 new Long(groupId), new Long(userId),
2201
2202 String.valueOf(start), String.valueOf(end),
2203 String.valueOf(orderByComparator)
2204 };
2205
2206 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_G_U,
2207 finderArgs, this);
2208
2209 if (list == null) {
2210 Session session = null;
2211
2212 try {
2213 session = openSession();
2214
2215 StringBundler query = null;
2216
2217 if (orderByComparator != null) {
2218 query = new StringBundler(4 +
2219 (orderByComparator.getOrderByFields().length * 3));
2220 }
2221 else {
2222 query = new StringBundler(4);
2223 }
2224
2225 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
2226
2227 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2228
2229 query.append(_FINDER_COLUMN_G_U_USERID_2);
2230
2231 if (orderByComparator != null) {
2232 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2233 orderByComparator);
2234 }
2235
2236 else {
2237 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
2238 }
2239
2240 String sql = query.toString();
2241
2242 Query q = session.createQuery(sql);
2243
2244 QueryPos qPos = QueryPos.getInstance(q);
2245
2246 qPos.add(groupId);
2247
2248 qPos.add(userId);
2249
2250 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
2251 end);
2252 }
2253 catch (Exception e) {
2254 throw processException(e);
2255 }
2256 finally {
2257 if (list == null) {
2258 list = new ArrayList<MBMessage>();
2259 }
2260
2261 cacheResult(list);
2262
2263 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_G_U,
2264 finderArgs, list);
2265
2266 closeSession(session);
2267 }
2268 }
2269
2270 return list;
2271 }
2272
2273 public MBMessage findByG_U_First(long groupId, long userId,
2274 OrderByComparator orderByComparator)
2275 throws NoSuchMessageException, SystemException {
2276 List<MBMessage> list = findByG_U(groupId, userId, 0, 1,
2277 orderByComparator);
2278
2279 if (list.isEmpty()) {
2280 StringBundler msg = new StringBundler(6);
2281
2282 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2283
2284 msg.append("groupId=");
2285 msg.append(groupId);
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 findByG_U_Last(long groupId, long userId,
2300 OrderByComparator orderByComparator)
2301 throws NoSuchMessageException, SystemException {
2302 int count = countByG_U(groupId, userId);
2303
2304 List<MBMessage> list = findByG_U(groupId, userId, count - 1, count,
2305 orderByComparator);
2306
2307 if (list.isEmpty()) {
2308 StringBundler msg = new StringBundler(6);
2309
2310 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2311
2312 msg.append("groupId=");
2313 msg.append(groupId);
2314
2315 msg.append(", userId=");
2316 msg.append(userId);
2317
2318 msg.append(StringPool.CLOSE_CURLY_BRACE);
2319
2320 throw new NoSuchMessageException(msg.toString());
2321 }
2322 else {
2323 return list.get(0);
2324 }
2325 }
2326
2327 public MBMessage[] findByG_U_PrevAndNext(long messageId, long groupId,
2328 long userId, OrderByComparator orderByComparator)
2329 throws NoSuchMessageException, SystemException {
2330 MBMessage mbMessage = findByPrimaryKey(messageId);
2331
2332 int count = countByG_U(groupId, userId);
2333
2334 Session session = null;
2335
2336 try {
2337 session = openSession();
2338
2339 StringBundler query = null;
2340
2341 if (orderByComparator != null) {
2342 query = new StringBundler(4 +
2343 (orderByComparator.getOrderByFields().length * 3));
2344 }
2345 else {
2346 query = new StringBundler(4);
2347 }
2348
2349 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
2350
2351 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2352
2353 query.append(_FINDER_COLUMN_G_U_USERID_2);
2354
2355 if (orderByComparator != null) {
2356 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2357 orderByComparator);
2358 }
2359
2360 else {
2361 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
2362 }
2363
2364 String sql = query.toString();
2365
2366 Query q = session.createQuery(sql);
2367
2368 QueryPos qPos = QueryPos.getInstance(q);
2369
2370 qPos.add(groupId);
2371
2372 qPos.add(userId);
2373
2374 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
2375 orderByComparator, mbMessage);
2376
2377 MBMessage[] array = new MBMessageImpl[3];
2378
2379 array[0] = (MBMessage)objArray[0];
2380 array[1] = (MBMessage)objArray[1];
2381 array[2] = (MBMessage)objArray[2];
2382
2383 return array;
2384 }
2385 catch (Exception e) {
2386 throw processException(e);
2387 }
2388 finally {
2389 closeSession(session);
2390 }
2391 }
2392
2393 public List<MBMessage> findByC_C(long classNameId, long classPK)
2394 throws SystemException {
2395 Object[] finderArgs = new Object[] {
2396 new Long(classNameId), new Long(classPK)
2397 };
2398
2399 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_C,
2400 finderArgs, this);
2401
2402 if (list == null) {
2403 Session session = null;
2404
2405 try {
2406 session = openSession();
2407
2408 StringBundler query = new StringBundler(4);
2409
2410 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
2411
2412 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2413
2414 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
2415
2416 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
2417
2418 String sql = query.toString();
2419
2420 Query q = session.createQuery(sql);
2421
2422 QueryPos qPos = QueryPos.getInstance(q);
2423
2424 qPos.add(classNameId);
2425
2426 qPos.add(classPK);
2427
2428 list = q.list();
2429 }
2430 catch (Exception e) {
2431 throw processException(e);
2432 }
2433 finally {
2434 if (list == null) {
2435 list = new ArrayList<MBMessage>();
2436 }
2437
2438 cacheResult(list);
2439
2440 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_C, finderArgs,
2441 list);
2442
2443 closeSession(session);
2444 }
2445 }
2446
2447 return list;
2448 }
2449
2450 public List<MBMessage> findByC_C(long classNameId, long classPK, int start,
2451 int end) throws SystemException {
2452 return findByC_C(classNameId, classPK, start, end, null);
2453 }
2454
2455 public List<MBMessage> findByC_C(long classNameId, long classPK, int start,
2456 int end, OrderByComparator orderByComparator) throws SystemException {
2457 Object[] finderArgs = new Object[] {
2458 new Long(classNameId), new Long(classPK),
2459
2460 String.valueOf(start), String.valueOf(end),
2461 String.valueOf(orderByComparator)
2462 };
2463
2464 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_C_C,
2465 finderArgs, this);
2466
2467 if (list == null) {
2468 Session session = null;
2469
2470 try {
2471 session = openSession();
2472
2473 StringBundler query = null;
2474
2475 if (orderByComparator != null) {
2476 query = new StringBundler(4 +
2477 (orderByComparator.getOrderByFields().length * 3));
2478 }
2479 else {
2480 query = new StringBundler(4);
2481 }
2482
2483 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
2484
2485 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2486
2487 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
2488
2489 if (orderByComparator != null) {
2490 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2491 orderByComparator);
2492 }
2493
2494 else {
2495 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
2496 }
2497
2498 String sql = query.toString();
2499
2500 Query q = session.createQuery(sql);
2501
2502 QueryPos qPos = QueryPos.getInstance(q);
2503
2504 qPos.add(classNameId);
2505
2506 qPos.add(classPK);
2507
2508 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
2509 end);
2510 }
2511 catch (Exception e) {
2512 throw processException(e);
2513 }
2514 finally {
2515 if (list == null) {
2516 list = new ArrayList<MBMessage>();
2517 }
2518
2519 cacheResult(list);
2520
2521 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_C_C,
2522 finderArgs, list);
2523
2524 closeSession(session);
2525 }
2526 }
2527
2528 return list;
2529 }
2530
2531 public MBMessage findByC_C_First(long classNameId, long classPK,
2532 OrderByComparator orderByComparator)
2533 throws NoSuchMessageException, SystemException {
2534 List<MBMessage> list = findByC_C(classNameId, classPK, 0, 1,
2535 orderByComparator);
2536
2537 if (list.isEmpty()) {
2538 StringBundler msg = new StringBundler(6);
2539
2540 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2541
2542 msg.append("classNameId=");
2543 msg.append(classNameId);
2544
2545 msg.append(", classPK=");
2546 msg.append(classPK);
2547
2548 msg.append(StringPool.CLOSE_CURLY_BRACE);
2549
2550 throw new NoSuchMessageException(msg.toString());
2551 }
2552 else {
2553 return list.get(0);
2554 }
2555 }
2556
2557 public MBMessage findByC_C_Last(long classNameId, long classPK,
2558 OrderByComparator orderByComparator)
2559 throws NoSuchMessageException, SystemException {
2560 int count = countByC_C(classNameId, classPK);
2561
2562 List<MBMessage> list = findByC_C(classNameId, classPK, count - 1,
2563 count, orderByComparator);
2564
2565 if (list.isEmpty()) {
2566 StringBundler msg = new StringBundler(6);
2567
2568 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2569
2570 msg.append("classNameId=");
2571 msg.append(classNameId);
2572
2573 msg.append(", classPK=");
2574 msg.append(classPK);
2575
2576 msg.append(StringPool.CLOSE_CURLY_BRACE);
2577
2578 throw new NoSuchMessageException(msg.toString());
2579 }
2580 else {
2581 return list.get(0);
2582 }
2583 }
2584
2585 public MBMessage[] findByC_C_PrevAndNext(long messageId, long classNameId,
2586 long classPK, OrderByComparator orderByComparator)
2587 throws NoSuchMessageException, SystemException {
2588 MBMessage mbMessage = findByPrimaryKey(messageId);
2589
2590 int count = countByC_C(classNameId, classPK);
2591
2592 Session session = null;
2593
2594 try {
2595 session = openSession();
2596
2597 StringBundler query = null;
2598
2599 if (orderByComparator != null) {
2600 query = new StringBundler(4 +
2601 (orderByComparator.getOrderByFields().length * 3));
2602 }
2603 else {
2604 query = new StringBundler(4);
2605 }
2606
2607 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
2608
2609 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2610
2611 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
2612
2613 if (orderByComparator != null) {
2614 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2615 orderByComparator);
2616 }
2617
2618 else {
2619 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
2620 }
2621
2622 String sql = query.toString();
2623
2624 Query q = session.createQuery(sql);
2625
2626 QueryPos qPos = QueryPos.getInstance(q);
2627
2628 qPos.add(classNameId);
2629
2630 qPos.add(classPK);
2631
2632 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
2633 orderByComparator, mbMessage);
2634
2635 MBMessage[] array = new MBMessageImpl[3];
2636
2637 array[0] = (MBMessage)objArray[0];
2638 array[1] = (MBMessage)objArray[1];
2639 array[2] = (MBMessage)objArray[2];
2640
2641 return array;
2642 }
2643 catch (Exception e) {
2644 throw processException(e);
2645 }
2646 finally {
2647 closeSession(session);
2648 }
2649 }
2650
2651 public List<MBMessage> findByC_T(long categoryId, long threadId)
2652 throws SystemException {
2653 Object[] finderArgs = new Object[] {
2654 new Long(categoryId), new Long(threadId)
2655 };
2656
2657 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_T,
2658 finderArgs, this);
2659
2660 if (list == null) {
2661 Session session = null;
2662
2663 try {
2664 session = openSession();
2665
2666 StringBundler query = new StringBundler(4);
2667
2668 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
2669
2670 query.append(_FINDER_COLUMN_C_T_CATEGORYID_2);
2671
2672 query.append(_FINDER_COLUMN_C_T_THREADID_2);
2673
2674 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
2675
2676 String sql = query.toString();
2677
2678 Query q = session.createQuery(sql);
2679
2680 QueryPos qPos = QueryPos.getInstance(q);
2681
2682 qPos.add(categoryId);
2683
2684 qPos.add(threadId);
2685
2686 list = q.list();
2687 }
2688 catch (Exception e) {
2689 throw processException(e);
2690 }
2691 finally {
2692 if (list == null) {
2693 list = new ArrayList<MBMessage>();
2694 }
2695
2696 cacheResult(list);
2697
2698 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_T, finderArgs,
2699 list);
2700
2701 closeSession(session);
2702 }
2703 }
2704
2705 return list;
2706 }
2707
2708 public List<MBMessage> findByC_T(long categoryId, long threadId, int start,
2709 int end) throws SystemException {
2710 return findByC_T(categoryId, threadId, start, end, null);
2711 }
2712
2713 public List<MBMessage> findByC_T(long categoryId, long threadId, int start,
2714 int end, OrderByComparator orderByComparator) throws SystemException {
2715 Object[] finderArgs = new Object[] {
2716 new Long(categoryId), new Long(threadId),
2717
2718 String.valueOf(start), String.valueOf(end),
2719 String.valueOf(orderByComparator)
2720 };
2721
2722 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_C_T,
2723 finderArgs, this);
2724
2725 if (list == null) {
2726 Session session = null;
2727
2728 try {
2729 session = openSession();
2730
2731 StringBundler query = null;
2732
2733 if (orderByComparator != null) {
2734 query = new StringBundler(4 +
2735 (orderByComparator.getOrderByFields().length * 3));
2736 }
2737 else {
2738 query = new StringBundler(4);
2739 }
2740
2741 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
2742
2743 query.append(_FINDER_COLUMN_C_T_CATEGORYID_2);
2744
2745 query.append(_FINDER_COLUMN_C_T_THREADID_2);
2746
2747 if (orderByComparator != null) {
2748 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2749 orderByComparator);
2750 }
2751
2752 else {
2753 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
2754 }
2755
2756 String sql = query.toString();
2757
2758 Query q = session.createQuery(sql);
2759
2760 QueryPos qPos = QueryPos.getInstance(q);
2761
2762 qPos.add(categoryId);
2763
2764 qPos.add(threadId);
2765
2766 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
2767 end);
2768 }
2769 catch (Exception e) {
2770 throw processException(e);
2771 }
2772 finally {
2773 if (list == null) {
2774 list = new ArrayList<MBMessage>();
2775 }
2776
2777 cacheResult(list);
2778
2779 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_C_T,
2780 finderArgs, list);
2781
2782 closeSession(session);
2783 }
2784 }
2785
2786 return list;
2787 }
2788
2789 public MBMessage findByC_T_First(long categoryId, long threadId,
2790 OrderByComparator orderByComparator)
2791 throws NoSuchMessageException, SystemException {
2792 List<MBMessage> list = findByC_T(categoryId, threadId, 0, 1,
2793 orderByComparator);
2794
2795 if (list.isEmpty()) {
2796 StringBundler msg = new StringBundler(6);
2797
2798 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2799
2800 msg.append("categoryId=");
2801 msg.append(categoryId);
2802
2803 msg.append(", threadId=");
2804 msg.append(threadId);
2805
2806 msg.append(StringPool.CLOSE_CURLY_BRACE);
2807
2808 throw new NoSuchMessageException(msg.toString());
2809 }
2810 else {
2811 return list.get(0);
2812 }
2813 }
2814
2815 public MBMessage findByC_T_Last(long categoryId, long threadId,
2816 OrderByComparator orderByComparator)
2817 throws NoSuchMessageException, SystemException {
2818 int count = countByC_T(categoryId, threadId);
2819
2820 List<MBMessage> list = findByC_T(categoryId, threadId, count - 1,
2821 count, orderByComparator);
2822
2823 if (list.isEmpty()) {
2824 StringBundler msg = new StringBundler(6);
2825
2826 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2827
2828 msg.append("categoryId=");
2829 msg.append(categoryId);
2830
2831 msg.append(", threadId=");
2832 msg.append(threadId);
2833
2834 msg.append(StringPool.CLOSE_CURLY_BRACE);
2835
2836 throw new NoSuchMessageException(msg.toString());
2837 }
2838 else {
2839 return list.get(0);
2840 }
2841 }
2842
2843 public MBMessage[] findByC_T_PrevAndNext(long messageId, long categoryId,
2844 long threadId, OrderByComparator orderByComparator)
2845 throws NoSuchMessageException, SystemException {
2846 MBMessage mbMessage = findByPrimaryKey(messageId);
2847
2848 int count = countByC_T(categoryId, threadId);
2849
2850 Session session = null;
2851
2852 try {
2853 session = openSession();
2854
2855 StringBundler query = null;
2856
2857 if (orderByComparator != null) {
2858 query = new StringBundler(4 +
2859 (orderByComparator.getOrderByFields().length * 3));
2860 }
2861 else {
2862 query = new StringBundler(4);
2863 }
2864
2865 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
2866
2867 query.append(_FINDER_COLUMN_C_T_CATEGORYID_2);
2868
2869 query.append(_FINDER_COLUMN_C_T_THREADID_2);
2870
2871 if (orderByComparator != null) {
2872 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2873 orderByComparator);
2874 }
2875
2876 else {
2877 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
2878 }
2879
2880 String sql = query.toString();
2881
2882 Query q = session.createQuery(sql);
2883
2884 QueryPos qPos = QueryPos.getInstance(q);
2885
2886 qPos.add(categoryId);
2887
2888 qPos.add(threadId);
2889
2890 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
2891 orderByComparator, mbMessage);
2892
2893 MBMessage[] array = new MBMessageImpl[3];
2894
2895 array[0] = (MBMessage)objArray[0];
2896 array[1] = (MBMessage)objArray[1];
2897 array[2] = (MBMessage)objArray[2];
2898
2899 return array;
2900 }
2901 catch (Exception e) {
2902 throw processException(e);
2903 }
2904 finally {
2905 closeSession(session);
2906 }
2907 }
2908
2909 public List<MBMessage> findByT_P(long threadId, long parentMessageId)
2910 throws SystemException {
2911 Object[] finderArgs = new Object[] {
2912 new Long(threadId), new Long(parentMessageId)
2913 };
2914
2915 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_T_P,
2916 finderArgs, this);
2917
2918 if (list == null) {
2919 Session session = null;
2920
2921 try {
2922 session = openSession();
2923
2924 StringBundler query = new StringBundler(4);
2925
2926 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
2927
2928 query.append(_FINDER_COLUMN_T_P_THREADID_2);
2929
2930 query.append(_FINDER_COLUMN_T_P_PARENTMESSAGEID_2);
2931
2932 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
2933
2934 String sql = query.toString();
2935
2936 Query q = session.createQuery(sql);
2937
2938 QueryPos qPos = QueryPos.getInstance(q);
2939
2940 qPos.add(threadId);
2941
2942 qPos.add(parentMessageId);
2943
2944 list = q.list();
2945 }
2946 catch (Exception e) {
2947 throw processException(e);
2948 }
2949 finally {
2950 if (list == null) {
2951 list = new ArrayList<MBMessage>();
2952 }
2953
2954 cacheResult(list);
2955
2956 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_T_P, finderArgs,
2957 list);
2958
2959 closeSession(session);
2960 }
2961 }
2962
2963 return list;
2964 }
2965
2966 public List<MBMessage> findByT_P(long threadId, long parentMessageId,
2967 int start, int end) throws SystemException {
2968 return findByT_P(threadId, parentMessageId, start, end, null);
2969 }
2970
2971 public List<MBMessage> findByT_P(long threadId, long parentMessageId,
2972 int start, int end, OrderByComparator orderByComparator)
2973 throws SystemException {
2974 Object[] finderArgs = new Object[] {
2975 new Long(threadId), new Long(parentMessageId),
2976
2977 String.valueOf(start), String.valueOf(end),
2978 String.valueOf(orderByComparator)
2979 };
2980
2981 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_T_P,
2982 finderArgs, this);
2983
2984 if (list == null) {
2985 Session session = null;
2986
2987 try {
2988 session = openSession();
2989
2990 StringBundler query = null;
2991
2992 if (orderByComparator != null) {
2993 query = new StringBundler(4 +
2994 (orderByComparator.getOrderByFields().length * 3));
2995 }
2996 else {
2997 query = new StringBundler(4);
2998 }
2999
3000 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
3001
3002 query.append(_FINDER_COLUMN_T_P_THREADID_2);
3003
3004 query.append(_FINDER_COLUMN_T_P_PARENTMESSAGEID_2);
3005
3006 if (orderByComparator != null) {
3007 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3008 orderByComparator);
3009 }
3010
3011 else {
3012 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
3013 }
3014
3015 String sql = query.toString();
3016
3017 Query q = session.createQuery(sql);
3018
3019 QueryPos qPos = QueryPos.getInstance(q);
3020
3021 qPos.add(threadId);
3022
3023 qPos.add(parentMessageId);
3024
3025 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
3026 end);
3027 }
3028 catch (Exception e) {
3029 throw processException(e);
3030 }
3031 finally {
3032 if (list == null) {
3033 list = new ArrayList<MBMessage>();
3034 }
3035
3036 cacheResult(list);
3037
3038 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_T_P,
3039 finderArgs, list);
3040
3041 closeSession(session);
3042 }
3043 }
3044
3045 return list;
3046 }
3047
3048 public MBMessage findByT_P_First(long threadId, long parentMessageId,
3049 OrderByComparator orderByComparator)
3050 throws NoSuchMessageException, SystemException {
3051 List<MBMessage> list = findByT_P(threadId, parentMessageId, 0, 1,
3052 orderByComparator);
3053
3054 if (list.isEmpty()) {
3055 StringBundler msg = new StringBundler(6);
3056
3057 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3058
3059 msg.append("threadId=");
3060 msg.append(threadId);
3061
3062 msg.append(", parentMessageId=");
3063 msg.append(parentMessageId);
3064
3065 msg.append(StringPool.CLOSE_CURLY_BRACE);
3066
3067 throw new NoSuchMessageException(msg.toString());
3068 }
3069 else {
3070 return list.get(0);
3071 }
3072 }
3073
3074 public MBMessage findByT_P_Last(long threadId, long parentMessageId,
3075 OrderByComparator orderByComparator)
3076 throws NoSuchMessageException, SystemException {
3077 int count = countByT_P(threadId, parentMessageId);
3078
3079 List<MBMessage> list = findByT_P(threadId, parentMessageId, count - 1,
3080 count, orderByComparator);
3081
3082 if (list.isEmpty()) {
3083 StringBundler msg = new StringBundler(6);
3084
3085 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3086
3087 msg.append("threadId=");
3088 msg.append(threadId);
3089
3090 msg.append(", parentMessageId=");
3091 msg.append(parentMessageId);
3092
3093 msg.append(StringPool.CLOSE_CURLY_BRACE);
3094
3095 throw new NoSuchMessageException(msg.toString());
3096 }
3097 else {
3098 return list.get(0);
3099 }
3100 }
3101
3102 public MBMessage[] findByT_P_PrevAndNext(long messageId, long threadId,
3103 long parentMessageId, OrderByComparator orderByComparator)
3104 throws NoSuchMessageException, SystemException {
3105 MBMessage mbMessage = findByPrimaryKey(messageId);
3106
3107 int count = countByT_P(threadId, parentMessageId);
3108
3109 Session session = null;
3110
3111 try {
3112 session = openSession();
3113
3114 StringBundler query = null;
3115
3116 if (orderByComparator != null) {
3117 query = new StringBundler(4 +
3118 (orderByComparator.getOrderByFields().length * 3));
3119 }
3120 else {
3121 query = new StringBundler(4);
3122 }
3123
3124 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
3125
3126 query.append(_FINDER_COLUMN_T_P_THREADID_2);
3127
3128 query.append(_FINDER_COLUMN_T_P_PARENTMESSAGEID_2);
3129
3130 if (orderByComparator != null) {
3131 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3132 orderByComparator);
3133 }
3134
3135 else {
3136 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
3137 }
3138
3139 String sql = query.toString();
3140
3141 Query q = session.createQuery(sql);
3142
3143 QueryPos qPos = QueryPos.getInstance(q);
3144
3145 qPos.add(threadId);
3146
3147 qPos.add(parentMessageId);
3148
3149 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
3150 orderByComparator, mbMessage);
3151
3152 MBMessage[] array = new MBMessageImpl[3];
3153
3154 array[0] = (MBMessage)objArray[0];
3155 array[1] = (MBMessage)objArray[1];
3156 array[2] = (MBMessage)objArray[2];
3157
3158 return array;
3159 }
3160 catch (Exception e) {
3161 throw processException(e);
3162 }
3163 finally {
3164 closeSession(session);
3165 }
3166 }
3167
3168 public List<MBMessage> findAll() throws SystemException {
3169 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3170 }
3171
3172 public List<MBMessage> findAll(int start, int end)
3173 throws SystemException {
3174 return findAll(start, end, null);
3175 }
3176
3177 public List<MBMessage> findAll(int start, int end,
3178 OrderByComparator orderByComparator) throws SystemException {
3179 Object[] finderArgs = new Object[] {
3180 String.valueOf(start), String.valueOf(end),
3181 String.valueOf(orderByComparator)
3182 };
3183
3184 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
3185 finderArgs, this);
3186
3187 if (list == null) {
3188 Session session = null;
3189
3190 try {
3191 session = openSession();
3192
3193 StringBundler query = null;
3194 String sql = null;
3195
3196 if (orderByComparator != null) {
3197 query = new StringBundler(2 +
3198 (orderByComparator.getOrderByFields().length * 3));
3199
3200 query.append(_SQL_SELECT_MBMESSAGE);
3201
3202 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3203 orderByComparator);
3204
3205 sql = query.toString();
3206 }
3207
3208 else {
3209 sql = _SQL_SELECT_MBMESSAGE.concat(MBMessageModelImpl.ORDER_BY_JPQL);
3210 }
3211
3212 Query q = session.createQuery(sql);
3213
3214 if (orderByComparator == null) {
3215 list = (List<MBMessage>)QueryUtil.list(q, getDialect(),
3216 start, end, false);
3217
3218 Collections.sort(list);
3219 }
3220 else {
3221 list = (List<MBMessage>)QueryUtil.list(q, getDialect(),
3222 start, end);
3223 }
3224 }
3225 catch (Exception e) {
3226 throw processException(e);
3227 }
3228 finally {
3229 if (list == null) {
3230 list = new ArrayList<MBMessage>();
3231 }
3232
3233 cacheResult(list);
3234
3235 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
3236
3237 closeSession(session);
3238 }
3239 }
3240
3241 return list;
3242 }
3243
3244 public void removeByUuid(String uuid) throws SystemException {
3245 for (MBMessage mbMessage : findByUuid(uuid)) {
3246 remove(mbMessage);
3247 }
3248 }
3249
3250 public void removeByUUID_G(String uuid, long groupId)
3251 throws NoSuchMessageException, SystemException {
3252 MBMessage mbMessage = findByUUID_G(uuid, groupId);
3253
3254 remove(mbMessage);
3255 }
3256
3257 public void removeByCompanyId(long companyId) throws SystemException {
3258 for (MBMessage mbMessage : findByCompanyId(companyId)) {
3259 remove(mbMessage);
3260 }
3261 }
3262
3263 public void removeByGroupId(long groupId) throws SystemException {
3264 for (MBMessage mbMessage : findByGroupId(groupId)) {
3265 remove(mbMessage);
3266 }
3267 }
3268
3269 public void removeByCategoryId(long categoryId) throws SystemException {
3270 for (MBMessage mbMessage : findByCategoryId(categoryId)) {
3271 remove(mbMessage);
3272 }
3273 }
3274
3275 public void removeByThreadId(long threadId) throws SystemException {
3276 for (MBMessage mbMessage : findByThreadId(threadId)) {
3277 remove(mbMessage);
3278 }
3279 }
3280
3281 public void removeByThreadReplies(long threadId) throws SystemException {
3282 for (MBMessage mbMessage : findByThreadReplies(threadId)) {
3283 remove(mbMessage);
3284 }
3285 }
3286
3287 public void removeByG_U(long groupId, long userId)
3288 throws SystemException {
3289 for (MBMessage mbMessage : findByG_U(groupId, userId)) {
3290 remove(mbMessage);
3291 }
3292 }
3293
3294 public void removeByC_C(long classNameId, long classPK)
3295 throws SystemException {
3296 for (MBMessage mbMessage : findByC_C(classNameId, classPK)) {
3297 remove(mbMessage);
3298 }
3299 }
3300
3301 public void removeByC_T(long categoryId, long threadId)
3302 throws SystemException {
3303 for (MBMessage mbMessage : findByC_T(categoryId, threadId)) {
3304 remove(mbMessage);
3305 }
3306 }
3307
3308 public void removeByT_P(long threadId, long parentMessageId)
3309 throws SystemException {
3310 for (MBMessage mbMessage : findByT_P(threadId, parentMessageId)) {
3311 remove(mbMessage);
3312 }
3313 }
3314
3315 public void removeAll() throws SystemException {
3316 for (MBMessage mbMessage : findAll()) {
3317 remove(mbMessage);
3318 }
3319 }
3320
3321 public int countByUuid(String uuid) throws SystemException {
3322 Object[] finderArgs = new Object[] { uuid };
3323
3324 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
3325 finderArgs, this);
3326
3327 if (count == null) {
3328 Session session = null;
3329
3330 try {
3331 session = openSession();
3332
3333 StringBundler query = new StringBundler(2);
3334
3335 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
3336
3337 if (uuid == null) {
3338 query.append(_FINDER_COLUMN_UUID_UUID_1);
3339 }
3340 else {
3341 if (uuid.equals(StringPool.BLANK)) {
3342 query.append(_FINDER_COLUMN_UUID_UUID_3);
3343 }
3344 else {
3345 query.append(_FINDER_COLUMN_UUID_UUID_2);
3346 }
3347 }
3348
3349 String sql = query.toString();
3350
3351 Query q = session.createQuery(sql);
3352
3353 QueryPos qPos = QueryPos.getInstance(q);
3354
3355 if (uuid != null) {
3356 qPos.add(uuid);
3357 }
3358
3359 count = (Long)q.uniqueResult();
3360 }
3361 catch (Exception e) {
3362 throw processException(e);
3363 }
3364 finally {
3365 if (count == null) {
3366 count = Long.valueOf(0);
3367 }
3368
3369 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
3370 finderArgs, count);
3371
3372 closeSession(session);
3373 }
3374 }
3375
3376 return count.intValue();
3377 }
3378
3379 public int countByUUID_G(String uuid, long groupId)
3380 throws SystemException {
3381 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
3382
3383 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
3384 finderArgs, this);
3385
3386 if (count == null) {
3387 Session session = null;
3388
3389 try {
3390 session = openSession();
3391
3392 StringBundler query = new StringBundler(3);
3393
3394 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
3395
3396 if (uuid == null) {
3397 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
3398 }
3399 else {
3400 if (uuid.equals(StringPool.BLANK)) {
3401 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
3402 }
3403 else {
3404 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
3405 }
3406 }
3407
3408 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
3409
3410 String sql = query.toString();
3411
3412 Query q = session.createQuery(sql);
3413
3414 QueryPos qPos = QueryPos.getInstance(q);
3415
3416 if (uuid != null) {
3417 qPos.add(uuid);
3418 }
3419
3420 qPos.add(groupId);
3421
3422 count = (Long)q.uniqueResult();
3423 }
3424 catch (Exception e) {
3425 throw processException(e);
3426 }
3427 finally {
3428 if (count == null) {
3429 count = Long.valueOf(0);
3430 }
3431
3432 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
3433 finderArgs, count);
3434
3435 closeSession(session);
3436 }
3437 }
3438
3439 return count.intValue();
3440 }
3441
3442 public int countByCompanyId(long companyId) throws SystemException {
3443 Object[] finderArgs = new Object[] { new Long(companyId) };
3444
3445 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
3446 finderArgs, this);
3447
3448 if (count == null) {
3449 Session session = null;
3450
3451 try {
3452 session = openSession();
3453
3454 StringBundler query = new StringBundler(2);
3455
3456 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
3457
3458 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3459
3460 String sql = query.toString();
3461
3462 Query q = session.createQuery(sql);
3463
3464 QueryPos qPos = QueryPos.getInstance(q);
3465
3466 qPos.add(companyId);
3467
3468 count = (Long)q.uniqueResult();
3469 }
3470 catch (Exception e) {
3471 throw processException(e);
3472 }
3473 finally {
3474 if (count == null) {
3475 count = Long.valueOf(0);
3476 }
3477
3478 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
3479 finderArgs, count);
3480
3481 closeSession(session);
3482 }
3483 }
3484
3485 return count.intValue();
3486 }
3487
3488 public int countByGroupId(long groupId) throws SystemException {
3489 Object[] finderArgs = new Object[] { new Long(groupId) };
3490
3491 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
3492 finderArgs, this);
3493
3494 if (count == null) {
3495 Session session = null;
3496
3497 try {
3498 session = openSession();
3499
3500 StringBundler query = new StringBundler(2);
3501
3502 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
3503
3504 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
3505
3506 String sql = query.toString();
3507
3508 Query q = session.createQuery(sql);
3509
3510 QueryPos qPos = QueryPos.getInstance(q);
3511
3512 qPos.add(groupId);
3513
3514 count = (Long)q.uniqueResult();
3515 }
3516 catch (Exception e) {
3517 throw processException(e);
3518 }
3519 finally {
3520 if (count == null) {
3521 count = Long.valueOf(0);
3522 }
3523
3524 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
3525 finderArgs, count);
3526
3527 closeSession(session);
3528 }
3529 }
3530
3531 return count.intValue();
3532 }
3533
3534 public int countByCategoryId(long categoryId) throws SystemException {
3535 Object[] finderArgs = new Object[] { new Long(categoryId) };
3536
3537 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_CATEGORYID,
3538 finderArgs, this);
3539
3540 if (count == null) {
3541 Session session = null;
3542
3543 try {
3544 session = openSession();
3545
3546 StringBundler query = new StringBundler(2);
3547
3548 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
3549
3550 query.append(_FINDER_COLUMN_CATEGORYID_CATEGORYID_2);
3551
3552 String sql = query.toString();
3553
3554 Query q = session.createQuery(sql);
3555
3556 QueryPos qPos = QueryPos.getInstance(q);
3557
3558 qPos.add(categoryId);
3559
3560 count = (Long)q.uniqueResult();
3561 }
3562 catch (Exception e) {
3563 throw processException(e);
3564 }
3565 finally {
3566 if (count == null) {
3567 count = Long.valueOf(0);
3568 }
3569
3570 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CATEGORYID,
3571 finderArgs, count);
3572
3573 closeSession(session);
3574 }
3575 }
3576
3577 return count.intValue();
3578 }
3579
3580 public int countByThreadId(long threadId) throws SystemException {
3581 Object[] finderArgs = new Object[] { new Long(threadId) };
3582
3583 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_THREADID,
3584 finderArgs, this);
3585
3586 if (count == null) {
3587 Session session = null;
3588
3589 try {
3590 session = openSession();
3591
3592 StringBundler query = new StringBundler(2);
3593
3594 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
3595
3596 query.append(_FINDER_COLUMN_THREADID_THREADID_2);
3597
3598 String sql = query.toString();
3599
3600 Query q = session.createQuery(sql);
3601
3602 QueryPos qPos = QueryPos.getInstance(q);
3603
3604 qPos.add(threadId);
3605
3606 count = (Long)q.uniqueResult();
3607 }
3608 catch (Exception e) {
3609 throw processException(e);
3610 }
3611 finally {
3612 if (count == null) {
3613 count = Long.valueOf(0);
3614 }
3615
3616 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_THREADID,
3617 finderArgs, count);
3618
3619 closeSession(session);
3620 }
3621 }
3622
3623 return count.intValue();
3624 }
3625
3626 public int countByThreadReplies(long threadId) throws SystemException {
3627 Object[] finderArgs = new Object[] { new Long(threadId) };
3628
3629 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_THREADREPLIES,
3630 finderArgs, this);
3631
3632 if (count == null) {
3633 Session session = null;
3634
3635 try {
3636 session = openSession();
3637
3638 StringBundler query = new StringBundler(2);
3639
3640 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
3641
3642 query.append(_FINDER_COLUMN_THREADREPLIES_THREADID_2);
3643
3644 String sql = query.toString();
3645
3646 Query q = session.createQuery(sql);
3647
3648 QueryPos qPos = QueryPos.getInstance(q);
3649
3650 qPos.add(threadId);
3651
3652 count = (Long)q.uniqueResult();
3653 }
3654 catch (Exception e) {
3655 throw processException(e);
3656 }
3657 finally {
3658 if (count == null) {
3659 count = Long.valueOf(0);
3660 }
3661
3662 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_THREADREPLIES,
3663 finderArgs, count);
3664
3665 closeSession(session);
3666 }
3667 }
3668
3669 return count.intValue();
3670 }
3671
3672 public int countByG_U(long groupId, long userId) throws SystemException {
3673 Object[] finderArgs = new Object[] { new Long(groupId), new Long(userId) };
3674
3675 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U,
3676 finderArgs, this);
3677
3678 if (count == null) {
3679 Session session = null;
3680
3681 try {
3682 session = openSession();
3683
3684 StringBundler query = new StringBundler(3);
3685
3686 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
3687
3688 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
3689
3690 query.append(_FINDER_COLUMN_G_U_USERID_2);
3691
3692 String sql = query.toString();
3693
3694 Query q = session.createQuery(sql);
3695
3696 QueryPos qPos = QueryPos.getInstance(q);
3697
3698 qPos.add(groupId);
3699
3700 qPos.add(userId);
3701
3702 count = (Long)q.uniqueResult();
3703 }
3704 catch (Exception e) {
3705 throw processException(e);
3706 }
3707 finally {
3708 if (count == null) {
3709 count = Long.valueOf(0);
3710 }
3711
3712 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U, finderArgs,
3713 count);
3714
3715 closeSession(session);
3716 }
3717 }
3718
3719 return count.intValue();
3720 }
3721
3722 public int countByC_C(long classNameId, long classPK)
3723 throws SystemException {
3724 Object[] finderArgs = new Object[] {
3725 new Long(classNameId), new Long(classPK)
3726 };
3727
3728 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
3729 finderArgs, this);
3730
3731 if (count == null) {
3732 Session session = null;
3733
3734 try {
3735 session = openSession();
3736
3737 StringBundler query = new StringBundler(3);
3738
3739 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
3740
3741 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3742
3743 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
3744
3745 String sql = query.toString();
3746
3747 Query q = session.createQuery(sql);
3748
3749 QueryPos qPos = QueryPos.getInstance(q);
3750
3751 qPos.add(classNameId);
3752
3753 qPos.add(classPK);
3754
3755 count = (Long)q.uniqueResult();
3756 }
3757 catch (Exception e) {
3758 throw processException(e);
3759 }
3760 finally {
3761 if (count == null) {
3762 count = Long.valueOf(0);
3763 }
3764
3765 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
3766 count);
3767
3768 closeSession(session);
3769 }
3770 }
3771
3772 return count.intValue();
3773 }
3774
3775 public int countByC_T(long categoryId, long threadId)
3776 throws SystemException {
3777 Object[] finderArgs = new Object[] {
3778 new Long(categoryId), new Long(threadId)
3779 };
3780
3781 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_T,
3782 finderArgs, this);
3783
3784 if (count == null) {
3785 Session session = null;
3786
3787 try {
3788 session = openSession();
3789
3790 StringBundler query = new StringBundler(3);
3791
3792 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
3793
3794 query.append(_FINDER_COLUMN_C_T_CATEGORYID_2);
3795
3796 query.append(_FINDER_COLUMN_C_T_THREADID_2);
3797
3798 String sql = query.toString();
3799
3800 Query q = session.createQuery(sql);
3801
3802 QueryPos qPos = QueryPos.getInstance(q);
3803
3804 qPos.add(categoryId);
3805
3806 qPos.add(threadId);
3807
3808 count = (Long)q.uniqueResult();
3809 }
3810 catch (Exception e) {
3811 throw processException(e);
3812 }
3813 finally {
3814 if (count == null) {
3815 count = Long.valueOf(0);
3816 }
3817
3818 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_T, finderArgs,
3819 count);
3820
3821 closeSession(session);
3822 }
3823 }
3824
3825 return count.intValue();
3826 }
3827
3828 public int countByT_P(long threadId, long parentMessageId)
3829 throws SystemException {
3830 Object[] finderArgs = new Object[] {
3831 new Long(threadId), new Long(parentMessageId)
3832 };
3833
3834 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_T_P,
3835 finderArgs, this);
3836
3837 if (count == null) {
3838 Session session = null;
3839
3840 try {
3841 session = openSession();
3842
3843 StringBundler query = new StringBundler(3);
3844
3845 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
3846
3847 query.append(_FINDER_COLUMN_T_P_THREADID_2);
3848
3849 query.append(_FINDER_COLUMN_T_P_PARENTMESSAGEID_2);
3850
3851 String sql = query.toString();
3852
3853 Query q = session.createQuery(sql);
3854
3855 QueryPos qPos = QueryPos.getInstance(q);
3856
3857 qPos.add(threadId);
3858
3859 qPos.add(parentMessageId);
3860
3861 count = (Long)q.uniqueResult();
3862 }
3863 catch (Exception e) {
3864 throw processException(e);
3865 }
3866 finally {
3867 if (count == null) {
3868 count = Long.valueOf(0);
3869 }
3870
3871 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_T_P, finderArgs,
3872 count);
3873
3874 closeSession(session);
3875 }
3876 }
3877
3878 return count.intValue();
3879 }
3880
3881 public int countAll() throws SystemException {
3882 Object[] finderArgs = new Object[0];
3883
3884 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3885 finderArgs, this);
3886
3887 if (count == null) {
3888 Session session = null;
3889
3890 try {
3891 session = openSession();
3892
3893 Query q = session.createQuery(_SQL_COUNT_MBMESSAGE);
3894
3895 count = (Long)q.uniqueResult();
3896 }
3897 catch (Exception e) {
3898 throw processException(e);
3899 }
3900 finally {
3901 if (count == null) {
3902 count = Long.valueOf(0);
3903 }
3904
3905 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
3906 count);
3907
3908 closeSession(session);
3909 }
3910 }
3911
3912 return count.intValue();
3913 }
3914
3915 public void afterPropertiesSet() {
3916 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3917 com.liferay.portal.util.PropsUtil.get(
3918 "value.object.listener.com.liferay.portlet.messageboards.model.MBMessage")));
3919
3920 if (listenerClassNames.length > 0) {
3921 try {
3922 List<ModelListener<MBMessage>> listenersList = new ArrayList<ModelListener<MBMessage>>();
3923
3924 for (String listenerClassName : listenerClassNames) {
3925 listenersList.add((ModelListener<MBMessage>)Class.forName(
3926 listenerClassName).newInstance());
3927 }
3928
3929 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3930 }
3931 catch (Exception e) {
3932 _log.error(e);
3933 }
3934 }
3935 }
3936
3937 @BeanReference(type = MBBanPersistence.class)
3938 protected MBBanPersistence mbBanPersistence;
3939 @BeanReference(type = MBCategoryPersistence.class)
3940 protected MBCategoryPersistence mbCategoryPersistence;
3941 @BeanReference(type = MBDiscussionPersistence.class)
3942 protected MBDiscussionPersistence mbDiscussionPersistence;
3943 @BeanReference(type = MBMailingListPersistence.class)
3944 protected MBMailingListPersistence mbMailingListPersistence;
3945 @BeanReference(type = MBMessagePersistence.class)
3946 protected MBMessagePersistence mbMessagePersistence;
3947 @BeanReference(type = MBMessageFlagPersistence.class)
3948 protected MBMessageFlagPersistence mbMessageFlagPersistence;
3949 @BeanReference(type = MBStatsUserPersistence.class)
3950 protected MBStatsUserPersistence mbStatsUserPersistence;
3951 @BeanReference(type = MBThreadPersistence.class)
3952 protected MBThreadPersistence mbThreadPersistence;
3953 @BeanReference(type = CompanyPersistence.class)
3954 protected CompanyPersistence companyPersistence;
3955 @BeanReference(type = GroupPersistence.class)
3956 protected GroupPersistence groupPersistence;
3957 @BeanReference(type = LockPersistence.class)
3958 protected LockPersistence lockPersistence;
3959 @BeanReference(type = PortletPreferencesPersistence.class)
3960 protected PortletPreferencesPersistence portletPreferencesPersistence;
3961 @BeanReference(type = ResourcePersistence.class)
3962 protected ResourcePersistence resourcePersistence;
3963 @BeanReference(type = SubscriptionPersistence.class)
3964 protected SubscriptionPersistence subscriptionPersistence;
3965 @BeanReference(type = UserPersistence.class)
3966 protected UserPersistence userPersistence;
3967 @BeanReference(type = BlogsEntryPersistence.class)
3968 protected BlogsEntryPersistence blogsEntryPersistence;
3969 @BeanReference(type = RatingsStatsPersistence.class)
3970 protected RatingsStatsPersistence ratingsStatsPersistence;
3971 @BeanReference(type = SocialActivityPersistence.class)
3972 protected SocialActivityPersistence socialActivityPersistence;
3973 @BeanReference(type = TagsAssetPersistence.class)
3974 protected TagsAssetPersistence tagsAssetPersistence;
3975 @BeanReference(type = TagsEntryPersistence.class)
3976 protected TagsEntryPersistence tagsEntryPersistence;
3977 private static final String _SQL_SELECT_MBMESSAGE = "SELECT mbMessage FROM MBMessage mbMessage";
3978 private static final String _SQL_SELECT_MBMESSAGE_WHERE = "SELECT mbMessage FROM MBMessage mbMessage WHERE ";
3979 private static final String _SQL_COUNT_MBMESSAGE = "SELECT COUNT(mbMessage) FROM MBMessage mbMessage";
3980 private static final String _SQL_COUNT_MBMESSAGE_WHERE = "SELECT COUNT(mbMessage) FROM MBMessage mbMessage WHERE ";
3981 private static final String _FINDER_COLUMN_UUID_UUID_1 = "mbMessage.uuid IS NULL";
3982 private static final String _FINDER_COLUMN_UUID_UUID_2 = "mbMessage.uuid = ?";
3983 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(mbMessage.uuid IS NULL OR mbMessage.uuid = ?)";
3984 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "mbMessage.uuid IS NULL AND ";
3985 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "mbMessage.uuid = ? AND ";
3986 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(mbMessage.uuid IS NULL OR mbMessage.uuid = ?) AND ";
3987 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "mbMessage.groupId = ?";
3988 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "mbMessage.companyId = ?";
3989 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "mbMessage.groupId = ?";
3990 private static final String _FINDER_COLUMN_CATEGORYID_CATEGORYID_2 = "mbMessage.categoryId = ?";
3991 private static final String _FINDER_COLUMN_THREADID_THREADID_2 = "mbMessage.threadId = ?";
3992 private static final String _FINDER_COLUMN_THREADREPLIES_THREADID_2 = "mbMessage.threadId = ? AND mbMessage.parentMessageId != 0";
3993 private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "mbMessage.groupId = ? AND ";
3994 private static final String _FINDER_COLUMN_G_U_USERID_2 = "mbMessage.userId = ?";
3995 private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "mbMessage.classNameId = ? AND ";
3996 private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "mbMessage.classPK = ?";
3997 private static final String _FINDER_COLUMN_C_T_CATEGORYID_2 = "mbMessage.categoryId = ? AND ";
3998 private static final String _FINDER_COLUMN_C_T_THREADID_2 = "mbMessage.threadId = ?";
3999 private static final String _FINDER_COLUMN_T_P_THREADID_2 = "mbMessage.threadId = ? AND ";
4000 private static final String _FINDER_COLUMN_T_P_PARENTMESSAGEID_2 = "mbMessage.parentMessageId = ?";
4001 private static final String _ORDER_BY_ENTITY_ALIAS = "mbMessage.";
4002 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MBMessage exists with the primary key ";
4003 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MBMessage exists with the key {";
4004 private static Log _log = LogFactoryUtil.getLog(MBMessagePersistenceImpl.class);
4005}