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