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