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