001
014
015 package com.liferay.portlet.messageboards.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.bean.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.sanitizer.Sanitizer;
032 import com.liferay.portal.kernel.sanitizer.SanitizerException;
033 import com.liferay.portal.kernel.sanitizer.SanitizerUtil;
034 import com.liferay.portal.kernel.util.ContentTypes;
035 import com.liferay.portal.kernel.util.GetterUtil;
036 import com.liferay.portal.kernel.util.InstanceFactory;
037 import com.liferay.portal.kernel.util.OrderByComparator;
038 import com.liferay.portal.kernel.util.StringBundler;
039 import com.liferay.portal.kernel.util.StringPool;
040 import com.liferay.portal.kernel.util.StringUtil;
041 import com.liferay.portal.kernel.util.Validator;
042 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
043 import com.liferay.portal.model.CacheModel;
044 import com.liferay.portal.model.ModelListener;
045 import com.liferay.portal.security.auth.PrincipalThreadLocal;
046 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
047 import com.liferay.portal.service.persistence.BatchSessionUtil;
048 import com.liferay.portal.service.persistence.CompanyPersistence;
049 import com.liferay.portal.service.persistence.GroupPersistence;
050 import com.liferay.portal.service.persistence.LockPersistence;
051 import com.liferay.portal.service.persistence.PortletPreferencesPersistence;
052 import com.liferay.portal.service.persistence.ResourcePersistence;
053 import com.liferay.portal.service.persistence.SubscriptionPersistence;
054 import com.liferay.portal.service.persistence.UserPersistence;
055 import com.liferay.portal.service.persistence.WorkflowInstanceLinkPersistence;
056 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
057
058 import com.liferay.portlet.asset.service.persistence.AssetEntryPersistence;
059 import com.liferay.portlet.asset.service.persistence.AssetLinkPersistence;
060 import com.liferay.portlet.asset.service.persistence.AssetTagPersistence;
061 import com.liferay.portlet.blogs.service.persistence.BlogsEntryPersistence;
062 import com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence;
063 import com.liferay.portlet.messageboards.NoSuchMessageException;
064 import com.liferay.portlet.messageboards.model.MBMessage;
065 import com.liferay.portlet.messageboards.model.impl.MBMessageImpl;
066 import com.liferay.portlet.messageboards.model.impl.MBMessageModelImpl;
067 import com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence;
068 import com.liferay.portlet.social.service.persistence.SocialActivityPersistence;
069 import com.liferay.portlet.wiki.service.persistence.WikiPagePersistence;
070
071 import java.io.Serializable;
072
073 import java.util.ArrayList;
074 import java.util.Collections;
075 import java.util.List;
076
077
089 public class MBMessagePersistenceImpl extends BasePersistenceImpl<MBMessage>
090 implements MBMessagePersistence {
091
096 public static final String FINDER_CLASS_NAME_ENTITY = MBMessageImpl.class.getName();
097 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
098 ".List1";
099 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
100 ".List2";
101 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
102 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
103 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
104 new String[] {
105 String.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_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
111 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
112 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
113 new String[] { String.class.getName() },
114 MBMessageModelImpl.UUID_COLUMN_BITMASK);
115 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
116 MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class,
117 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
118 new String[] { String.class.getName() });
119 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
120 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
121 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
122 new String[] { String.class.getName(), Long.class.getName() },
123 MBMessageModelImpl.UUID_COLUMN_BITMASK |
124 MBMessageModelImpl.GROUPID_COLUMN_BITMASK);
125 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
126 MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class,
127 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
128 new String[] { String.class.getName(), Long.class.getName() });
129 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
130 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
131 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
132 new String[] {
133 Long.class.getName(),
134
135 "java.lang.Integer", "java.lang.Integer",
136 "com.liferay.portal.kernel.util.OrderByComparator"
137 });
138 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
139 new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
140 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
141 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
142 new String[] { Long.class.getName() },
143 MBMessageModelImpl.GROUPID_COLUMN_BITMASK);
144 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
145 MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class,
146 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
147 new String[] { Long.class.getName() });
148 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
149 new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
150 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
151 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
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_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
159 new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
160 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
161 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
162 new String[] { Long.class.getName() },
163 MBMessageModelImpl.COMPANYID_COLUMN_BITMASK);
164 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
165 MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class,
166 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
167 new String[] { Long.class.getName() });
168 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_THREADID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
169 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
170 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByThreadId",
171 new String[] {
172 Long.class.getName(),
173
174 "java.lang.Integer", "java.lang.Integer",
175 "com.liferay.portal.kernel.util.OrderByComparator"
176 });
177 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_THREADID =
178 new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
179 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
180 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByThreadId",
181 new String[] { Long.class.getName() },
182 MBMessageModelImpl.THREADID_COLUMN_BITMASK);
183 public static final FinderPath FINDER_PATH_COUNT_BY_THREADID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
184 MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class,
185 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByThreadId",
186 new String[] { Long.class.getName() });
187 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_THREADREPLIES =
188 new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
189 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
190 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByThreadReplies",
191 new String[] {
192 Long.class.getName(),
193
194 "java.lang.Integer", "java.lang.Integer",
195 "com.liferay.portal.kernel.util.OrderByComparator"
196 });
197 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_THREADREPLIES =
198 new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
199 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
200 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByThreadReplies",
201 new String[] { Long.class.getName() },
202 MBMessageModelImpl.THREADID_COLUMN_BITMASK);
203 public static final FinderPath FINDER_PATH_COUNT_BY_THREADREPLIES = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
204 MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class,
205 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByThreadReplies",
206 new String[] { Long.class.getName() });
207 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
208 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
209 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId",
210 new String[] {
211 Long.class.getName(),
212
213 "java.lang.Integer", "java.lang.Integer",
214 "com.liferay.portal.kernel.util.OrderByComparator"
215 });
216 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
217 new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
218 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
219 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
220 new String[] { Long.class.getName() },
221 MBMessageModelImpl.USERID_COLUMN_BITMASK);
222 public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
223 MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class,
224 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
225 new String[] { Long.class.getName() });
226 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
227 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
228 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U",
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_WITHOUT_PAGINATION_FIND_BY_G_U = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
236 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
237 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U",
238 new String[] { Long.class.getName(), Long.class.getName() },
239 MBMessageModelImpl.GROUPID_COLUMN_BITMASK |
240 MBMessageModelImpl.USERID_COLUMN_BITMASK);
241 public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
242 MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class,
243 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U",
244 new String[] { Long.class.getName(), Long.class.getName() });
245 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
246 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
247 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_C",
248 new String[] {
249 Long.class.getName(), Long.class.getName(),
250
251 "java.lang.Integer", "java.lang.Integer",
252 "com.liferay.portal.kernel.util.OrderByComparator"
253 });
254 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
255 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
256 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C",
257 new String[] { Long.class.getName(), Long.class.getName() },
258 MBMessageModelImpl.GROUPID_COLUMN_BITMASK |
259 MBMessageModelImpl.CATEGORYID_COLUMN_BITMASK);
260 public static final FinderPath FINDER_PATH_COUNT_BY_G_C = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
261 MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class,
262 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C",
263 new String[] { Long.class.getName(), Long.class.getName() });
264 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
265 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
266 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_S",
267 new String[] {
268 Long.class.getName(), Integer.class.getName(),
269
270 "java.lang.Integer", "java.lang.Integer",
271 "com.liferay.portal.kernel.util.OrderByComparator"
272 });
273 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
274 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
275 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
276 new String[] { Long.class.getName(), Integer.class.getName() },
277 MBMessageModelImpl.GROUPID_COLUMN_BITMASK |
278 MBMessageModelImpl.STATUS_COLUMN_BITMASK);
279 public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
280 MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class,
281 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
282 new String[] { Long.class.getName(), Integer.class.getName() });
283 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
284 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
285 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_S",
286 new String[] {
287 Long.class.getName(), Integer.class.getName(),
288
289 "java.lang.Integer", "java.lang.Integer",
290 "com.liferay.portal.kernel.util.OrderByComparator"
291 });
292 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
293 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
294 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_S",
295 new String[] { Long.class.getName(), Integer.class.getName() },
296 MBMessageModelImpl.COMPANYID_COLUMN_BITMASK |
297 MBMessageModelImpl.STATUS_COLUMN_BITMASK);
298 public static final FinderPath FINDER_PATH_COUNT_BY_C_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
299 MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class,
300 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_S",
301 new String[] { Long.class.getName(), Integer.class.getName() });
302 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
303 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
304 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_C",
305 new String[] {
306 Long.class.getName(), Long.class.getName(),
307
308 "java.lang.Integer", "java.lang.Integer",
309 "com.liferay.portal.kernel.util.OrderByComparator"
310 });
311 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
312 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
313 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_C",
314 new String[] { Long.class.getName(), Long.class.getName() },
315 MBMessageModelImpl.USERID_COLUMN_BITMASK |
316 MBMessageModelImpl.CLASSNAMEID_COLUMN_BITMASK);
317 public static final FinderPath FINDER_PATH_COUNT_BY_U_C = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
318 MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class,
319 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_C",
320 new String[] { Long.class.getName(), Long.class.getName() });
321 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
322 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
323 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C",
324 new String[] {
325 Long.class.getName(), Long.class.getName(),
326
327 "java.lang.Integer", "java.lang.Integer",
328 "com.liferay.portal.kernel.util.OrderByComparator"
329 });
330 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
331 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
332 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C",
333 new String[] { Long.class.getName(), Long.class.getName() },
334 MBMessageModelImpl.CLASSNAMEID_COLUMN_BITMASK |
335 MBMessageModelImpl.CLASSPK_COLUMN_BITMASK);
336 public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
337 MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class,
338 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C",
339 new String[] { Long.class.getName(), Long.class.getName() });
340 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_T_P = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
341 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
342 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByT_P",
343 new String[] {
344 Long.class.getName(), Long.class.getName(),
345
346 "java.lang.Integer", "java.lang.Integer",
347 "com.liferay.portal.kernel.util.OrderByComparator"
348 });
349 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_P = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
350 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
351 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByT_P",
352 new String[] { Long.class.getName(), Long.class.getName() },
353 MBMessageModelImpl.THREADID_COLUMN_BITMASK |
354 MBMessageModelImpl.PARENTMESSAGEID_COLUMN_BITMASK);
355 public static final FinderPath FINDER_PATH_COUNT_BY_T_P = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
356 MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class,
357 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByT_P",
358 new String[] { Long.class.getName(), Long.class.getName() });
359 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_T_A = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
360 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
361 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByT_A",
362 new String[] {
363 Long.class.getName(), Boolean.class.getName(),
364
365 "java.lang.Integer", "java.lang.Integer",
366 "com.liferay.portal.kernel.util.OrderByComparator"
367 });
368 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
369 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
370 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByT_A",
371 new String[] { Long.class.getName(), Boolean.class.getName() },
372 MBMessageModelImpl.THREADID_COLUMN_BITMASK |
373 MBMessageModelImpl.ANSWER_COLUMN_BITMASK);
374 public static final FinderPath FINDER_PATH_COUNT_BY_T_A = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
375 MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class,
376 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByT_A",
377 new String[] { Long.class.getName(), Boolean.class.getName() });
378 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_T_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
379 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
380 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByT_S",
381 new String[] {
382 Long.class.getName(), Integer.class.getName(),
383
384 "java.lang.Integer", "java.lang.Integer",
385 "com.liferay.portal.kernel.util.OrderByComparator"
386 });
387 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
388 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
389 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByT_S",
390 new String[] { Long.class.getName(), Integer.class.getName() },
391 MBMessageModelImpl.THREADID_COLUMN_BITMASK |
392 MBMessageModelImpl.STATUS_COLUMN_BITMASK);
393 public static final FinderPath FINDER_PATH_COUNT_BY_T_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
394 MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class,
395 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByT_S",
396 new String[] { Long.class.getName(), Integer.class.getName() });
397 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_TR_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
398 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
399 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByTR_S",
400 new String[] {
401 Long.class.getName(), Integer.class.getName(),
402
403 "java.lang.Integer", "java.lang.Integer",
404 "com.liferay.portal.kernel.util.OrderByComparator"
405 });
406 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TR_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
407 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
408 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByTR_S",
409 new String[] { Long.class.getName(), Integer.class.getName() },
410 MBMessageModelImpl.THREADID_COLUMN_BITMASK |
411 MBMessageModelImpl.STATUS_COLUMN_BITMASK);
412 public static final FinderPath FINDER_PATH_COUNT_BY_TR_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
413 MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class,
414 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByTR_S",
415 new String[] { Long.class.getName(), Integer.class.getName() });
416 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
417 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
418 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_S",
419 new String[] {
420 Long.class.getName(), Long.class.getName(),
421 Integer.class.getName(),
422
423 "java.lang.Integer", "java.lang.Integer",
424 "com.liferay.portal.kernel.util.OrderByComparator"
425 });
426 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
427 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
428 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_S",
429 new String[] {
430 Long.class.getName(), Long.class.getName(),
431 Integer.class.getName()
432 },
433 MBMessageModelImpl.GROUPID_COLUMN_BITMASK |
434 MBMessageModelImpl.USERID_COLUMN_BITMASK |
435 MBMessageModelImpl.STATUS_COLUMN_BITMASK);
436 public static final FinderPath FINDER_PATH_COUNT_BY_G_U_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
437 MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class,
438 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_S",
439 new String[] {
440 Long.class.getName(), Long.class.getName(),
441 Integer.class.getName()
442 });
443 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
444 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
445 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_C_T",
446 new String[] {
447 Long.class.getName(), Long.class.getName(), Long.class.getName(),
448
449 "java.lang.Integer", "java.lang.Integer",
450 "com.liferay.portal.kernel.util.OrderByComparator"
451 });
452 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
453 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
454 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_T",
455 new String[] {
456 Long.class.getName(), Long.class.getName(), Long.class.getName()
457 },
458 MBMessageModelImpl.GROUPID_COLUMN_BITMASK |
459 MBMessageModelImpl.CATEGORYID_COLUMN_BITMASK |
460 MBMessageModelImpl.THREADID_COLUMN_BITMASK);
461 public static final FinderPath FINDER_PATH_COUNT_BY_G_C_T = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
462 MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class,
463 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_T",
464 new String[] {
465 Long.class.getName(), Long.class.getName(), Long.class.getName()
466 });
467 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
468 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
469 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_C_S",
470 new String[] {
471 Long.class.getName(), Long.class.getName(),
472 Integer.class.getName(),
473
474 "java.lang.Integer", "java.lang.Integer",
475 "com.liferay.portal.kernel.util.OrderByComparator"
476 });
477 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
478 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
479 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_S",
480 new String[] {
481 Long.class.getName(), Long.class.getName(),
482 Integer.class.getName()
483 },
484 MBMessageModelImpl.GROUPID_COLUMN_BITMASK |
485 MBMessageModelImpl.CATEGORYID_COLUMN_BITMASK |
486 MBMessageModelImpl.STATUS_COLUMN_BITMASK);
487 public static final FinderPath FINDER_PATH_COUNT_BY_G_C_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
488 MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class,
489 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_S",
490 new String[] {
491 Long.class.getName(), Long.class.getName(),
492 Integer.class.getName()
493 });
494 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C_C = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
495 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
496 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_C_C",
497 new String[] {
498 Long.class.getName(), Long.class.getName(), Long.class.getName(),
499
500 "java.lang.Integer", "java.lang.Integer",
501 "com.liferay.portal.kernel.util.OrderByComparator"
502 });
503 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_C = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
504 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
505 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_C_C",
506 new String[] {
507 Long.class.getName(), Long.class.getName(), Long.class.getName()
508 },
509 MBMessageModelImpl.USERID_COLUMN_BITMASK |
510 MBMessageModelImpl.CLASSNAMEID_COLUMN_BITMASK |
511 MBMessageModelImpl.CLASSPK_COLUMN_BITMASK);
512 public static final FinderPath FINDER_PATH_COUNT_BY_U_C_C = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
513 MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class,
514 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_C_C",
515 new String[] {
516 Long.class.getName(), Long.class.getName(), Long.class.getName()
517 });
518 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
519 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
520 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_C_S",
521 new String[] {
522 Long.class.getName(), Long.class.getName(),
523 Integer.class.getName(),
524
525 "java.lang.Integer", "java.lang.Integer",
526 "com.liferay.portal.kernel.util.OrderByComparator"
527 });
528 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
529 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
530 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_C_S",
531 new String[] {
532 Long.class.getName(), Long.class.getName(),
533 Integer.class.getName()
534 },
535 MBMessageModelImpl.USERID_COLUMN_BITMASK |
536 MBMessageModelImpl.CLASSNAMEID_COLUMN_BITMASK |
537 MBMessageModelImpl.STATUS_COLUMN_BITMASK);
538 public static final FinderPath FINDER_PATH_COUNT_BY_U_C_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
539 MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class,
540 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_C_S",
541 new String[] {
542 Long.class.getName(), Long.class.getName(),
543 Integer.class.getName()
544 });
545 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
546 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
547 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C_S",
548 new String[] {
549 Long.class.getName(), Long.class.getName(),
550 Integer.class.getName(),
551
552 "java.lang.Integer", "java.lang.Integer",
553 "com.liferay.portal.kernel.util.OrderByComparator"
554 });
555 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
556 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
557 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C_S",
558 new String[] {
559 Long.class.getName(), Long.class.getName(),
560 Integer.class.getName()
561 },
562 MBMessageModelImpl.CLASSNAMEID_COLUMN_BITMASK |
563 MBMessageModelImpl.CLASSPK_COLUMN_BITMASK |
564 MBMessageModelImpl.STATUS_COLUMN_BITMASK);
565 public static final FinderPath FINDER_PATH_COUNT_BY_C_C_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
566 MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class,
567 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_S",
568 new String[] {
569 Long.class.getName(), Long.class.getName(),
570 Integer.class.getName()
571 });
572 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T_A = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
573 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
574 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_C_T_A",
575 new String[] {
576 Long.class.getName(), Long.class.getName(), Long.class.getName(),
577 Boolean.class.getName(),
578
579 "java.lang.Integer", "java.lang.Integer",
580 "com.liferay.portal.kernel.util.OrderByComparator"
581 });
582 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T_A =
583 new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
584 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
585 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_T_A",
586 new String[] {
587 Long.class.getName(), Long.class.getName(), Long.class.getName(),
588 Boolean.class.getName()
589 },
590 MBMessageModelImpl.GROUPID_COLUMN_BITMASK |
591 MBMessageModelImpl.CATEGORYID_COLUMN_BITMASK |
592 MBMessageModelImpl.THREADID_COLUMN_BITMASK |
593 MBMessageModelImpl.ANSWER_COLUMN_BITMASK);
594 public static final FinderPath FINDER_PATH_COUNT_BY_G_C_T_A = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
595 MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class,
596 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_T_A",
597 new String[] {
598 Long.class.getName(), Long.class.getName(), Long.class.getName(),
599 Boolean.class.getName()
600 });
601 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
602 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
603 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_C_T_S",
604 new String[] {
605 Long.class.getName(), Long.class.getName(), Long.class.getName(),
606 Integer.class.getName(),
607
608 "java.lang.Integer", "java.lang.Integer",
609 "com.liferay.portal.kernel.util.OrderByComparator"
610 });
611 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T_S =
612 new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
613 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
614 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_T_S",
615 new String[] {
616 Long.class.getName(), Long.class.getName(), Long.class.getName(),
617 Integer.class.getName()
618 },
619 MBMessageModelImpl.GROUPID_COLUMN_BITMASK |
620 MBMessageModelImpl.CATEGORYID_COLUMN_BITMASK |
621 MBMessageModelImpl.THREADID_COLUMN_BITMASK |
622 MBMessageModelImpl.STATUS_COLUMN_BITMASK);
623 public static final FinderPath FINDER_PATH_COUNT_BY_G_C_T_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
624 MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class,
625 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_T_S",
626 new String[] {
627 Long.class.getName(), Long.class.getName(), Long.class.getName(),
628 Integer.class.getName()
629 });
630 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C_C_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
631 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
632 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_C_C_S",
633 new String[] {
634 Long.class.getName(), Long.class.getName(), Long.class.getName(),
635 Integer.class.getName(),
636
637 "java.lang.Integer", "java.lang.Integer",
638 "com.liferay.portal.kernel.util.OrderByComparator"
639 });
640 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_C_S =
641 new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
642 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
643 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_C_C_S",
644 new String[] {
645 Long.class.getName(), Long.class.getName(), Long.class.getName(),
646 Integer.class.getName()
647 },
648 MBMessageModelImpl.USERID_COLUMN_BITMASK |
649 MBMessageModelImpl.CLASSNAMEID_COLUMN_BITMASK |
650 MBMessageModelImpl.CLASSPK_COLUMN_BITMASK |
651 MBMessageModelImpl.STATUS_COLUMN_BITMASK);
652 public static final FinderPath FINDER_PATH_COUNT_BY_U_C_C_S = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
653 MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class,
654 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_C_C_S",
655 new String[] {
656 Long.class.getName(), Long.class.getName(), Long.class.getName(),
657 Integer.class.getName()
658 });
659 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
660 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
661 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
662 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
663 MBMessageModelImpl.FINDER_CACHE_ENABLED, MBMessageImpl.class,
664 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
665 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
666 MBMessageModelImpl.FINDER_CACHE_ENABLED, Long.class,
667 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
668
669
674 public void cacheResult(MBMessage mbMessage) {
675 EntityCacheUtil.putResult(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
676 MBMessageImpl.class, mbMessage.getPrimaryKey(), mbMessage);
677
678 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
679 new Object[] {
680 mbMessage.getUuid(), Long.valueOf(mbMessage.getGroupId())
681 }, mbMessage);
682
683 mbMessage.resetOriginalValues();
684 }
685
686
691 public void cacheResult(List<MBMessage> mbMessages) {
692 for (MBMessage mbMessage : mbMessages) {
693 if (EntityCacheUtil.getResult(
694 MBMessageModelImpl.ENTITY_CACHE_ENABLED,
695 MBMessageImpl.class, mbMessage.getPrimaryKey()) == null) {
696 cacheResult(mbMessage);
697 }
698 else {
699 mbMessage.resetOriginalValues();
700 }
701 }
702 }
703
704
711 @Override
712 public void clearCache() {
713 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
714 CacheRegistryUtil.clear(MBMessageImpl.class.getName());
715 }
716
717 EntityCacheUtil.clearCache(MBMessageImpl.class.getName());
718
719 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
720 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
721 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
722 }
723
724
731 @Override
732 public void clearCache(MBMessage mbMessage) {
733 EntityCacheUtil.removeResult(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
734 MBMessageImpl.class, mbMessage.getPrimaryKey());
735
736 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
737 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
738
739 clearUniqueFindersCache(mbMessage);
740 }
741
742 @Override
743 public void clearCache(List<MBMessage> mbMessages) {
744 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
745 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
746
747 for (MBMessage mbMessage : mbMessages) {
748 EntityCacheUtil.removeResult(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
749 MBMessageImpl.class, mbMessage.getPrimaryKey());
750
751 clearUniqueFindersCache(mbMessage);
752 }
753 }
754
755 protected void clearUniqueFindersCache(MBMessage mbMessage) {
756 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
757 new Object[] {
758 mbMessage.getUuid(), Long.valueOf(mbMessage.getGroupId())
759 });
760 }
761
762
768 public MBMessage create(long messageId) {
769 MBMessage mbMessage = new MBMessageImpl();
770
771 mbMessage.setNew(true);
772 mbMessage.setPrimaryKey(messageId);
773
774 String uuid = PortalUUIDUtil.generate();
775
776 mbMessage.setUuid(uuid);
777
778 return mbMessage;
779 }
780
781
789 public MBMessage remove(long messageId)
790 throws NoSuchMessageException, SystemException {
791 return remove(Long.valueOf(messageId));
792 }
793
794
802 @Override
803 public MBMessage remove(Serializable primaryKey)
804 throws NoSuchMessageException, SystemException {
805 Session session = null;
806
807 try {
808 session = openSession();
809
810 MBMessage mbMessage = (MBMessage)session.get(MBMessageImpl.class,
811 primaryKey);
812
813 if (mbMessage == null) {
814 if (_log.isWarnEnabled()) {
815 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
816 }
817
818 throw new NoSuchMessageException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
819 primaryKey);
820 }
821
822 return remove(mbMessage);
823 }
824 catch (NoSuchMessageException nsee) {
825 throw nsee;
826 }
827 catch (Exception e) {
828 throw processException(e);
829 }
830 finally {
831 closeSession(session);
832 }
833 }
834
835 @Override
836 protected MBMessage removeImpl(MBMessage mbMessage)
837 throws SystemException {
838 mbMessage = toUnwrappedModel(mbMessage);
839
840 Session session = null;
841
842 try {
843 session = openSession();
844
845 BatchSessionUtil.delete(session, mbMessage);
846 }
847 catch (Exception e) {
848 throw processException(e);
849 }
850 finally {
851 closeSession(session);
852 }
853
854 clearCache(mbMessage);
855
856 return mbMessage;
857 }
858
859 @Override
860 public MBMessage updateImpl(
861 com.liferay.portlet.messageboards.model.MBMessage mbMessage,
862 boolean merge) throws SystemException {
863 mbMessage = toUnwrappedModel(mbMessage);
864
865 boolean isNew = mbMessage.isNew();
866
867 MBMessageModelImpl mbMessageModelImpl = (MBMessageModelImpl)mbMessage;
868
869 if (Validator.isNull(mbMessage.getUuid())) {
870 String uuid = PortalUUIDUtil.generate();
871
872 mbMessage.setUuid(uuid);
873 }
874
875 long userId = GetterUtil.getLong(PrincipalThreadLocal.getName());
876
877 if (userId > 0) {
878 long companyId = mbMessage.getCompanyId();
879
880 long groupId = mbMessage.getGroupId();
881
882 long messageId = 0;
883
884 if (!isNew) {
885 messageId = mbMessage.getPrimaryKey();
886 }
887
888 try {
889 mbMessage.setSubject(SanitizerUtil.sanitize(companyId, groupId,
890 userId,
891 com.liferay.portlet.messageboards.model.MBMessage.class.getName(),
892 messageId, ContentTypes.TEXT_PLAIN, Sanitizer.MODE_ALL,
893 mbMessage.getSubject(), null));
894 }
895 catch (SanitizerException se) {
896 throw new SystemException(se);
897 }
898 }
899
900 Session session = null;
901
902 try {
903 session = openSession();
904
905 BatchSessionUtil.update(session, mbMessage, merge);
906
907 mbMessage.setNew(false);
908 }
909 catch (Exception e) {
910 throw processException(e);
911 }
912 finally {
913 closeSession(session);
914 }
915
916 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
917
918 if (isNew || !MBMessageModelImpl.COLUMN_BITMASK_ENABLED) {
919 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
920 }
921
922 else {
923 if ((mbMessageModelImpl.getColumnBitmask() &
924 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
925 Object[] args = new Object[] {
926 mbMessageModelImpl.getOriginalUuid()
927 };
928
929 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
930 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
931 args);
932
933 args = new Object[] { mbMessageModelImpl.getUuid() };
934
935 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
936 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
937 args);
938 }
939
940 if ((mbMessageModelImpl.getColumnBitmask() &
941 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
942 Object[] args = new Object[] {
943 Long.valueOf(mbMessageModelImpl.getOriginalGroupId())
944 };
945
946 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
947 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
948 args);
949
950 args = new Object[] {
951 Long.valueOf(mbMessageModelImpl.getGroupId())
952 };
953
954 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
955 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
956 args);
957 }
958
959 if ((mbMessageModelImpl.getColumnBitmask() &
960 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
961 Object[] args = new Object[] {
962 Long.valueOf(mbMessageModelImpl.getOriginalCompanyId())
963 };
964
965 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
966 args);
967 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
968 args);
969
970 args = new Object[] {
971 Long.valueOf(mbMessageModelImpl.getCompanyId())
972 };
973
974 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
975 args);
976 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
977 args);
978 }
979
980 if ((mbMessageModelImpl.getColumnBitmask() &
981 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_THREADID.getColumnBitmask()) != 0) {
982 Object[] args = new Object[] {
983 Long.valueOf(mbMessageModelImpl.getOriginalThreadId())
984 };
985
986 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_THREADID, args);
987 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_THREADID,
988 args);
989
990 args = new Object[] {
991 Long.valueOf(mbMessageModelImpl.getThreadId())
992 };
993
994 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_THREADID, args);
995 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_THREADID,
996 args);
997 }
998
999 if ((mbMessageModelImpl.getColumnBitmask() &
1000 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_THREADREPLIES.getColumnBitmask()) != 0) {
1001 Object[] args = new Object[] {
1002 Long.valueOf(mbMessageModelImpl.getOriginalThreadId())
1003 };
1004
1005 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_THREADREPLIES,
1006 args);
1007 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_THREADREPLIES,
1008 args);
1009
1010 args = new Object[] {
1011 Long.valueOf(mbMessageModelImpl.getThreadId())
1012 };
1013
1014 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_THREADREPLIES,
1015 args);
1016 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_THREADREPLIES,
1017 args);
1018 }
1019
1020 if ((mbMessageModelImpl.getColumnBitmask() &
1021 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
1022 Object[] args = new Object[] {
1023 Long.valueOf(mbMessageModelImpl.getOriginalUserId())
1024 };
1025
1026 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
1027 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
1028 args);
1029
1030 args = new Object[] { Long.valueOf(mbMessageModelImpl.getUserId()) };
1031
1032 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
1033 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
1034 args);
1035 }
1036
1037 if ((mbMessageModelImpl.getColumnBitmask() &
1038 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U.getColumnBitmask()) != 0) {
1039 Object[] args = new Object[] {
1040 Long.valueOf(mbMessageModelImpl.getOriginalGroupId()),
1041 Long.valueOf(mbMessageModelImpl.getOriginalUserId())
1042 };
1043
1044 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
1045 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
1046 args);
1047
1048 args = new Object[] {
1049 Long.valueOf(mbMessageModelImpl.getGroupId()),
1050 Long.valueOf(mbMessageModelImpl.getUserId())
1051 };
1052
1053 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
1054 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
1055 args);
1056 }
1057
1058 if ((mbMessageModelImpl.getColumnBitmask() &
1059 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C.getColumnBitmask()) != 0) {
1060 Object[] args = new Object[] {
1061 Long.valueOf(mbMessageModelImpl.getOriginalGroupId()),
1062 Long.valueOf(mbMessageModelImpl.getOriginalCategoryId())
1063 };
1064
1065 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C, args);
1066 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C,
1067 args);
1068
1069 args = new Object[] {
1070 Long.valueOf(mbMessageModelImpl.getGroupId()),
1071 Long.valueOf(mbMessageModelImpl.getCategoryId())
1072 };
1073
1074 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C, args);
1075 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C,
1076 args);
1077 }
1078
1079 if ((mbMessageModelImpl.getColumnBitmask() &
1080 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
1081 Object[] args = new Object[] {
1082 Long.valueOf(mbMessageModelImpl.getOriginalGroupId()),
1083 Integer.valueOf(mbMessageModelImpl.getOriginalStatus())
1084 };
1085
1086 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
1087 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
1088 args);
1089
1090 args = new Object[] {
1091 Long.valueOf(mbMessageModelImpl.getGroupId()),
1092 Integer.valueOf(mbMessageModelImpl.getStatus())
1093 };
1094
1095 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
1096 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
1097 args);
1098 }
1099
1100 if ((mbMessageModelImpl.getColumnBitmask() &
1101 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S.getColumnBitmask()) != 0) {
1102 Object[] args = new Object[] {
1103 Long.valueOf(mbMessageModelImpl.getOriginalCompanyId()),
1104 Integer.valueOf(mbMessageModelImpl.getOriginalStatus())
1105 };
1106
1107 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
1108 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
1109 args);
1110
1111 args = new Object[] {
1112 Long.valueOf(mbMessageModelImpl.getCompanyId()),
1113 Integer.valueOf(mbMessageModelImpl.getStatus())
1114 };
1115
1116 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
1117 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
1118 args);
1119 }
1120
1121 if ((mbMessageModelImpl.getColumnBitmask() &
1122 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C.getColumnBitmask()) != 0) {
1123 Object[] args = new Object[] {
1124 Long.valueOf(mbMessageModelImpl.getOriginalUserId()),
1125 Long.valueOf(mbMessageModelImpl.getOriginalClassNameId())
1126 };
1127
1128 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_C, args);
1129 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C,
1130 args);
1131
1132 args = new Object[] {
1133 Long.valueOf(mbMessageModelImpl.getUserId()),
1134 Long.valueOf(mbMessageModelImpl.getClassNameId())
1135 };
1136
1137 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_C, args);
1138 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C,
1139 args);
1140 }
1141
1142 if ((mbMessageModelImpl.getColumnBitmask() &
1143 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C.getColumnBitmask()) != 0) {
1144 Object[] args = new Object[] {
1145 Long.valueOf(mbMessageModelImpl.getOriginalClassNameId()),
1146 Long.valueOf(mbMessageModelImpl.getOriginalClassPK())
1147 };
1148
1149 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
1150 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
1151 args);
1152
1153 args = new Object[] {
1154 Long.valueOf(mbMessageModelImpl.getClassNameId()),
1155 Long.valueOf(mbMessageModelImpl.getClassPK())
1156 };
1157
1158 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
1159 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
1160 args);
1161 }
1162
1163 if ((mbMessageModelImpl.getColumnBitmask() &
1164 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_P.getColumnBitmask()) != 0) {
1165 Object[] args = new Object[] {
1166 Long.valueOf(mbMessageModelImpl.getOriginalThreadId()),
1167 Long.valueOf(mbMessageModelImpl.getOriginalParentMessageId())
1168 };
1169
1170 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_P, args);
1171 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_P,
1172 args);
1173
1174 args = new Object[] {
1175 Long.valueOf(mbMessageModelImpl.getThreadId()),
1176 Long.valueOf(mbMessageModelImpl.getParentMessageId())
1177 };
1178
1179 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_P, args);
1180 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_P,
1181 args);
1182 }
1183
1184 if ((mbMessageModelImpl.getColumnBitmask() &
1185 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A.getColumnBitmask()) != 0) {
1186 Object[] args = new Object[] {
1187 Long.valueOf(mbMessageModelImpl.getOriginalThreadId()),
1188 Boolean.valueOf(mbMessageModelImpl.getOriginalAnswer())
1189 };
1190
1191 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_A, args);
1192 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A,
1193 args);
1194
1195 args = new Object[] {
1196 Long.valueOf(mbMessageModelImpl.getThreadId()),
1197 Boolean.valueOf(mbMessageModelImpl.getAnswer())
1198 };
1199
1200 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_A, args);
1201 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A,
1202 args);
1203 }
1204
1205 if ((mbMessageModelImpl.getColumnBitmask() &
1206 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_S.getColumnBitmask()) != 0) {
1207 Object[] args = new Object[] {
1208 Long.valueOf(mbMessageModelImpl.getOriginalThreadId()),
1209 Integer.valueOf(mbMessageModelImpl.getOriginalStatus())
1210 };
1211
1212 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_S, args);
1213 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_S,
1214 args);
1215
1216 args = new Object[] {
1217 Long.valueOf(mbMessageModelImpl.getThreadId()),
1218 Integer.valueOf(mbMessageModelImpl.getStatus())
1219 };
1220
1221 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_S, args);
1222 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_S,
1223 args);
1224 }
1225
1226 if ((mbMessageModelImpl.getColumnBitmask() &
1227 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TR_S.getColumnBitmask()) != 0) {
1228 Object[] args = new Object[] {
1229 Long.valueOf(mbMessageModelImpl.getOriginalThreadId()),
1230 Integer.valueOf(mbMessageModelImpl.getOriginalStatus())
1231 };
1232
1233 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TR_S, args);
1234 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TR_S,
1235 args);
1236
1237 args = new Object[] {
1238 Long.valueOf(mbMessageModelImpl.getThreadId()),
1239 Integer.valueOf(mbMessageModelImpl.getStatus())
1240 };
1241
1242 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TR_S, args);
1243 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TR_S,
1244 args);
1245 }
1246
1247 if ((mbMessageModelImpl.getColumnBitmask() &
1248 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S.getColumnBitmask()) != 0) {
1249 Object[] args = new Object[] {
1250 Long.valueOf(mbMessageModelImpl.getOriginalGroupId()),
1251 Long.valueOf(mbMessageModelImpl.getOriginalUserId()),
1252 Integer.valueOf(mbMessageModelImpl.getOriginalStatus())
1253 };
1254
1255 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
1256 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
1257 args);
1258
1259 args = new Object[] {
1260 Long.valueOf(mbMessageModelImpl.getGroupId()),
1261 Long.valueOf(mbMessageModelImpl.getUserId()),
1262 Integer.valueOf(mbMessageModelImpl.getStatus())
1263 };
1264
1265 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
1266 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
1267 args);
1268 }
1269
1270 if ((mbMessageModelImpl.getColumnBitmask() &
1271 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T.getColumnBitmask()) != 0) {
1272 Object[] args = new Object[] {
1273 Long.valueOf(mbMessageModelImpl.getOriginalGroupId()),
1274 Long.valueOf(mbMessageModelImpl.getOriginalCategoryId()),
1275 Long.valueOf(mbMessageModelImpl.getOriginalThreadId())
1276 };
1277
1278 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T, args);
1279 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T,
1280 args);
1281
1282 args = new Object[] {
1283 Long.valueOf(mbMessageModelImpl.getGroupId()),
1284 Long.valueOf(mbMessageModelImpl.getCategoryId()),
1285 Long.valueOf(mbMessageModelImpl.getThreadId())
1286 };
1287
1288 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T, args);
1289 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T,
1290 args);
1291 }
1292
1293 if ((mbMessageModelImpl.getColumnBitmask() &
1294 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_S.getColumnBitmask()) != 0) {
1295 Object[] args = new Object[] {
1296 Long.valueOf(mbMessageModelImpl.getOriginalGroupId()),
1297 Long.valueOf(mbMessageModelImpl.getOriginalCategoryId()),
1298 Integer.valueOf(mbMessageModelImpl.getOriginalStatus())
1299 };
1300
1301 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
1302 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_S,
1303 args);
1304
1305 args = new Object[] {
1306 Long.valueOf(mbMessageModelImpl.getGroupId()),
1307 Long.valueOf(mbMessageModelImpl.getCategoryId()),
1308 Integer.valueOf(mbMessageModelImpl.getStatus())
1309 };
1310
1311 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
1312 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_S,
1313 args);
1314 }
1315
1316 if ((mbMessageModelImpl.getColumnBitmask() &
1317 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_C.getColumnBitmask()) != 0) {
1318 Object[] args = new Object[] {
1319 Long.valueOf(mbMessageModelImpl.getOriginalUserId()),
1320 Long.valueOf(mbMessageModelImpl.getOriginalClassNameId()),
1321 Long.valueOf(mbMessageModelImpl.getOriginalClassPK())
1322 };
1323
1324 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_C_C, args);
1325 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_C,
1326 args);
1327
1328 args = new Object[] {
1329 Long.valueOf(mbMessageModelImpl.getUserId()),
1330 Long.valueOf(mbMessageModelImpl.getClassNameId()),
1331 Long.valueOf(mbMessageModelImpl.getClassPK())
1332 };
1333
1334 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_C_C, args);
1335 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_C,
1336 args);
1337 }
1338
1339 if ((mbMessageModelImpl.getColumnBitmask() &
1340 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_S.getColumnBitmask()) != 0) {
1341 Object[] args = new Object[] {
1342 Long.valueOf(mbMessageModelImpl.getOriginalUserId()),
1343 Long.valueOf(mbMessageModelImpl.getOriginalClassNameId()),
1344 Integer.valueOf(mbMessageModelImpl.getOriginalStatus())
1345 };
1346
1347 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_C_S, args);
1348 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_S,
1349 args);
1350
1351 args = new Object[] {
1352 Long.valueOf(mbMessageModelImpl.getUserId()),
1353 Long.valueOf(mbMessageModelImpl.getClassNameId()),
1354 Integer.valueOf(mbMessageModelImpl.getStatus())
1355 };
1356
1357 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_C_S, args);
1358 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_S,
1359 args);
1360 }
1361
1362 if ((mbMessageModelImpl.getColumnBitmask() &
1363 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_S.getColumnBitmask()) != 0) {
1364 Object[] args = new Object[] {
1365 Long.valueOf(mbMessageModelImpl.getOriginalClassNameId()),
1366 Long.valueOf(mbMessageModelImpl.getOriginalClassPK()),
1367 Integer.valueOf(mbMessageModelImpl.getOriginalStatus())
1368 };
1369
1370 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_S, args);
1371 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_S,
1372 args);
1373
1374 args = new Object[] {
1375 Long.valueOf(mbMessageModelImpl.getClassNameId()),
1376 Long.valueOf(mbMessageModelImpl.getClassPK()),
1377 Integer.valueOf(mbMessageModelImpl.getStatus())
1378 };
1379
1380 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_S, args);
1381 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_S,
1382 args);
1383 }
1384
1385 if ((mbMessageModelImpl.getColumnBitmask() &
1386 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T_A.getColumnBitmask()) != 0) {
1387 Object[] args = new Object[] {
1388 Long.valueOf(mbMessageModelImpl.getOriginalGroupId()),
1389 Long.valueOf(mbMessageModelImpl.getOriginalCategoryId()),
1390 Long.valueOf(mbMessageModelImpl.getOriginalThreadId()),
1391 Boolean.valueOf(mbMessageModelImpl.getOriginalAnswer())
1392 };
1393
1394 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T_A, args);
1395 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T_A,
1396 args);
1397
1398 args = new Object[] {
1399 Long.valueOf(mbMessageModelImpl.getGroupId()),
1400 Long.valueOf(mbMessageModelImpl.getCategoryId()),
1401 Long.valueOf(mbMessageModelImpl.getThreadId()),
1402 Boolean.valueOf(mbMessageModelImpl.getAnswer())
1403 };
1404
1405 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T_A, args);
1406 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T_A,
1407 args);
1408 }
1409
1410 if ((mbMessageModelImpl.getColumnBitmask() &
1411 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T_S.getColumnBitmask()) != 0) {
1412 Object[] args = new Object[] {
1413 Long.valueOf(mbMessageModelImpl.getOriginalGroupId()),
1414 Long.valueOf(mbMessageModelImpl.getOriginalCategoryId()),
1415 Long.valueOf(mbMessageModelImpl.getOriginalThreadId()),
1416 Integer.valueOf(mbMessageModelImpl.getOriginalStatus())
1417 };
1418
1419 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T_S, args);
1420 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T_S,
1421 args);
1422
1423 args = new Object[] {
1424 Long.valueOf(mbMessageModelImpl.getGroupId()),
1425 Long.valueOf(mbMessageModelImpl.getCategoryId()),
1426 Long.valueOf(mbMessageModelImpl.getThreadId()),
1427 Integer.valueOf(mbMessageModelImpl.getStatus())
1428 };
1429
1430 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T_S, args);
1431 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T_S,
1432 args);
1433 }
1434
1435 if ((mbMessageModelImpl.getColumnBitmask() &
1436 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_C_S.getColumnBitmask()) != 0) {
1437 Object[] args = new Object[] {
1438 Long.valueOf(mbMessageModelImpl.getOriginalUserId()),
1439 Long.valueOf(mbMessageModelImpl.getOriginalClassNameId()),
1440 Long.valueOf(mbMessageModelImpl.getOriginalClassPK()),
1441 Integer.valueOf(mbMessageModelImpl.getOriginalStatus())
1442 };
1443
1444 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_C_C_S, args);
1445 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_C_S,
1446 args);
1447
1448 args = new Object[] {
1449 Long.valueOf(mbMessageModelImpl.getUserId()),
1450 Long.valueOf(mbMessageModelImpl.getClassNameId()),
1451 Long.valueOf(mbMessageModelImpl.getClassPK()),
1452 Integer.valueOf(mbMessageModelImpl.getStatus())
1453 };
1454
1455 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_C_C_S, args);
1456 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_C_S,
1457 args);
1458 }
1459 }
1460
1461 EntityCacheUtil.putResult(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
1462 MBMessageImpl.class, mbMessage.getPrimaryKey(), mbMessage);
1463
1464 if (isNew) {
1465 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1466 new Object[] {
1467 mbMessage.getUuid(), Long.valueOf(mbMessage.getGroupId())
1468 }, mbMessage);
1469 }
1470 else {
1471 if ((mbMessageModelImpl.getColumnBitmask() &
1472 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
1473 Object[] args = new Object[] {
1474 mbMessageModelImpl.getOriginalUuid(),
1475 Long.valueOf(mbMessageModelImpl.getOriginalGroupId())
1476 };
1477
1478 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
1479 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
1480
1481 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1482 new Object[] {
1483 mbMessage.getUuid(),
1484 Long.valueOf(mbMessage.getGroupId())
1485 }, mbMessage);
1486 }
1487 }
1488
1489 return mbMessage;
1490 }
1491
1492 protected MBMessage toUnwrappedModel(MBMessage mbMessage) {
1493 if (mbMessage instanceof MBMessageImpl) {
1494 return mbMessage;
1495 }
1496
1497 MBMessageImpl mbMessageImpl = new MBMessageImpl();
1498
1499 mbMessageImpl.setNew(mbMessage.isNew());
1500 mbMessageImpl.setPrimaryKey(mbMessage.getPrimaryKey());
1501
1502 mbMessageImpl.setUuid(mbMessage.getUuid());
1503 mbMessageImpl.setMessageId(mbMessage.getMessageId());
1504 mbMessageImpl.setGroupId(mbMessage.getGroupId());
1505 mbMessageImpl.setCompanyId(mbMessage.getCompanyId());
1506 mbMessageImpl.setUserId(mbMessage.getUserId());
1507 mbMessageImpl.setUserName(mbMessage.getUserName());
1508 mbMessageImpl.setCreateDate(mbMessage.getCreateDate());
1509 mbMessageImpl.setModifiedDate(mbMessage.getModifiedDate());
1510 mbMessageImpl.setClassNameId(mbMessage.getClassNameId());
1511 mbMessageImpl.setClassPK(mbMessage.getClassPK());
1512 mbMessageImpl.setCategoryId(mbMessage.getCategoryId());
1513 mbMessageImpl.setThreadId(mbMessage.getThreadId());
1514 mbMessageImpl.setRootMessageId(mbMessage.getRootMessageId());
1515 mbMessageImpl.setParentMessageId(mbMessage.getParentMessageId());
1516 mbMessageImpl.setSubject(mbMessage.getSubject());
1517 mbMessageImpl.setBody(mbMessage.getBody());
1518 mbMessageImpl.setFormat(mbMessage.getFormat());
1519 mbMessageImpl.setAttachments(mbMessage.isAttachments());
1520 mbMessageImpl.setAnonymous(mbMessage.isAnonymous());
1521 mbMessageImpl.setPriority(mbMessage.getPriority());
1522 mbMessageImpl.setAllowPingbacks(mbMessage.isAllowPingbacks());
1523 mbMessageImpl.setAnswer(mbMessage.isAnswer());
1524 mbMessageImpl.setStatus(mbMessage.getStatus());
1525 mbMessageImpl.setStatusByUserId(mbMessage.getStatusByUserId());
1526 mbMessageImpl.setStatusByUserName(mbMessage.getStatusByUserName());
1527 mbMessageImpl.setStatusDate(mbMessage.getStatusDate());
1528
1529 return mbMessageImpl;
1530 }
1531
1532
1540 @Override
1541 public MBMessage findByPrimaryKey(Serializable primaryKey)
1542 throws NoSuchModelException, SystemException {
1543 return findByPrimaryKey(((Long)primaryKey).longValue());
1544 }
1545
1546
1554 public MBMessage findByPrimaryKey(long messageId)
1555 throws NoSuchMessageException, SystemException {
1556 MBMessage mbMessage = fetchByPrimaryKey(messageId);
1557
1558 if (mbMessage == null) {
1559 if (_log.isWarnEnabled()) {
1560 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + messageId);
1561 }
1562
1563 throw new NoSuchMessageException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1564 messageId);
1565 }
1566
1567 return mbMessage;
1568 }
1569
1570
1577 @Override
1578 public MBMessage fetchByPrimaryKey(Serializable primaryKey)
1579 throws SystemException {
1580 return fetchByPrimaryKey(((Long)primaryKey).longValue());
1581 }
1582
1583
1590 public MBMessage fetchByPrimaryKey(long messageId)
1591 throws SystemException {
1592 MBMessage mbMessage = (MBMessage)EntityCacheUtil.getResult(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
1593 MBMessageImpl.class, messageId);
1594
1595 if (mbMessage == _nullMBMessage) {
1596 return null;
1597 }
1598
1599 if (mbMessage == null) {
1600 Session session = null;
1601
1602 boolean hasException = false;
1603
1604 try {
1605 session = openSession();
1606
1607 mbMessage = (MBMessage)session.get(MBMessageImpl.class,
1608 Long.valueOf(messageId));
1609 }
1610 catch (Exception e) {
1611 hasException = true;
1612
1613 throw processException(e);
1614 }
1615 finally {
1616 if (mbMessage != null) {
1617 cacheResult(mbMessage);
1618 }
1619 else if (!hasException) {
1620 EntityCacheUtil.putResult(MBMessageModelImpl.ENTITY_CACHE_ENABLED,
1621 MBMessageImpl.class, messageId, _nullMBMessage);
1622 }
1623
1624 closeSession(session);
1625 }
1626 }
1627
1628 return mbMessage;
1629 }
1630
1631
1638 public List<MBMessage> findByUuid(String uuid) throws SystemException {
1639 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1640 }
1641
1642
1655 public List<MBMessage> findByUuid(String uuid, int start, int end)
1656 throws SystemException {
1657 return findByUuid(uuid, start, end, null);
1658 }
1659
1660
1674 public List<MBMessage> findByUuid(String uuid, int start, int end,
1675 OrderByComparator orderByComparator) throws SystemException {
1676 FinderPath finderPath = null;
1677 Object[] finderArgs = null;
1678
1679 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1680 (orderByComparator == null)) {
1681 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
1682 finderArgs = new Object[] { uuid };
1683 }
1684 else {
1685 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
1686 finderArgs = new Object[] { uuid, start, end, orderByComparator };
1687 }
1688
1689 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(finderPath,
1690 finderArgs, this);
1691
1692 if (list == null) {
1693 StringBundler query = null;
1694
1695 if (orderByComparator != null) {
1696 query = new StringBundler(3 +
1697 (orderByComparator.getOrderByFields().length * 3));
1698 }
1699 else {
1700 query = new StringBundler(3);
1701 }
1702
1703 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
1704
1705 if (uuid == null) {
1706 query.append(_FINDER_COLUMN_UUID_UUID_1);
1707 }
1708 else {
1709 if (uuid.equals(StringPool.BLANK)) {
1710 query.append(_FINDER_COLUMN_UUID_UUID_3);
1711 }
1712 else {
1713 query.append(_FINDER_COLUMN_UUID_UUID_2);
1714 }
1715 }
1716
1717 if (orderByComparator != null) {
1718 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1719 orderByComparator);
1720 }
1721
1722 else {
1723 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
1724 }
1725
1726 String sql = query.toString();
1727
1728 Session session = null;
1729
1730 try {
1731 session = openSession();
1732
1733 Query q = session.createQuery(sql);
1734
1735 QueryPos qPos = QueryPos.getInstance(q);
1736
1737 if (uuid != null) {
1738 qPos.add(uuid);
1739 }
1740
1741 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
1742 end);
1743 }
1744 catch (Exception e) {
1745 throw processException(e);
1746 }
1747 finally {
1748 if (list == null) {
1749 FinderCacheUtil.removeResult(finderPath, finderArgs);
1750 }
1751 else {
1752 cacheResult(list);
1753
1754 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1755 }
1756
1757 closeSession(session);
1758 }
1759 }
1760
1761 return list;
1762 }
1763
1764
1777 public MBMessage findByUuid_First(String uuid,
1778 OrderByComparator orderByComparator)
1779 throws NoSuchMessageException, SystemException {
1780 List<MBMessage> list = findByUuid(uuid, 0, 1, orderByComparator);
1781
1782 if (list.isEmpty()) {
1783 StringBundler msg = new StringBundler(4);
1784
1785 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1786
1787 msg.append("uuid=");
1788 msg.append(uuid);
1789
1790 msg.append(StringPool.CLOSE_CURLY_BRACE);
1791
1792 throw new NoSuchMessageException(msg.toString());
1793 }
1794 else {
1795 return list.get(0);
1796 }
1797 }
1798
1799
1812 public MBMessage findByUuid_Last(String uuid,
1813 OrderByComparator orderByComparator)
1814 throws NoSuchMessageException, SystemException {
1815 int count = countByUuid(uuid);
1816
1817 List<MBMessage> list = findByUuid(uuid, count - 1, count,
1818 orderByComparator);
1819
1820 if (list.isEmpty()) {
1821 StringBundler msg = new StringBundler(4);
1822
1823 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1824
1825 msg.append("uuid=");
1826 msg.append(uuid);
1827
1828 msg.append(StringPool.CLOSE_CURLY_BRACE);
1829
1830 throw new NoSuchMessageException(msg.toString());
1831 }
1832 else {
1833 return list.get(0);
1834 }
1835 }
1836
1837
1851 public MBMessage[] findByUuid_PrevAndNext(long messageId, String uuid,
1852 OrderByComparator orderByComparator)
1853 throws NoSuchMessageException, SystemException {
1854 MBMessage mbMessage = findByPrimaryKey(messageId);
1855
1856 Session session = null;
1857
1858 try {
1859 session = openSession();
1860
1861 MBMessage[] array = new MBMessageImpl[3];
1862
1863 array[0] = getByUuid_PrevAndNext(session, mbMessage, uuid,
1864 orderByComparator, true);
1865
1866 array[1] = mbMessage;
1867
1868 array[2] = getByUuid_PrevAndNext(session, mbMessage, uuid,
1869 orderByComparator, false);
1870
1871 return array;
1872 }
1873 catch (Exception e) {
1874 throw processException(e);
1875 }
1876 finally {
1877 closeSession(session);
1878 }
1879 }
1880
1881 protected MBMessage getByUuid_PrevAndNext(Session session,
1882 MBMessage mbMessage, String uuid, OrderByComparator orderByComparator,
1883 boolean previous) {
1884 StringBundler query = null;
1885
1886 if (orderByComparator != null) {
1887 query = new StringBundler(6 +
1888 (orderByComparator.getOrderByFields().length * 6));
1889 }
1890 else {
1891 query = new StringBundler(3);
1892 }
1893
1894 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
1895
1896 if (uuid == null) {
1897 query.append(_FINDER_COLUMN_UUID_UUID_1);
1898 }
1899 else {
1900 if (uuid.equals(StringPool.BLANK)) {
1901 query.append(_FINDER_COLUMN_UUID_UUID_3);
1902 }
1903 else {
1904 query.append(_FINDER_COLUMN_UUID_UUID_2);
1905 }
1906 }
1907
1908 if (orderByComparator != null) {
1909 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1910
1911 if (orderByConditionFields.length > 0) {
1912 query.append(WHERE_AND);
1913 }
1914
1915 for (int i = 0; i < orderByConditionFields.length; i++) {
1916 query.append(_ORDER_BY_ENTITY_ALIAS);
1917 query.append(orderByConditionFields[i]);
1918
1919 if ((i + 1) < orderByConditionFields.length) {
1920 if (orderByComparator.isAscending() ^ previous) {
1921 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1922 }
1923 else {
1924 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1925 }
1926 }
1927 else {
1928 if (orderByComparator.isAscending() ^ previous) {
1929 query.append(WHERE_GREATER_THAN);
1930 }
1931 else {
1932 query.append(WHERE_LESSER_THAN);
1933 }
1934 }
1935 }
1936
1937 query.append(ORDER_BY_CLAUSE);
1938
1939 String[] orderByFields = orderByComparator.getOrderByFields();
1940
1941 for (int i = 0; i < orderByFields.length; i++) {
1942 query.append(_ORDER_BY_ENTITY_ALIAS);
1943 query.append(orderByFields[i]);
1944
1945 if ((i + 1) < orderByFields.length) {
1946 if (orderByComparator.isAscending() ^ previous) {
1947 query.append(ORDER_BY_ASC_HAS_NEXT);
1948 }
1949 else {
1950 query.append(ORDER_BY_DESC_HAS_NEXT);
1951 }
1952 }
1953 else {
1954 if (orderByComparator.isAscending() ^ previous) {
1955 query.append(ORDER_BY_ASC);
1956 }
1957 else {
1958 query.append(ORDER_BY_DESC);
1959 }
1960 }
1961 }
1962 }
1963
1964 else {
1965 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
1966 }
1967
1968 String sql = query.toString();
1969
1970 Query q = session.createQuery(sql);
1971
1972 q.setFirstResult(0);
1973 q.setMaxResults(2);
1974
1975 QueryPos qPos = QueryPos.getInstance(q);
1976
1977 if (uuid != null) {
1978 qPos.add(uuid);
1979 }
1980
1981 if (orderByComparator != null) {
1982 Object[] values = orderByComparator.getOrderByConditionValues(mbMessage);
1983
1984 for (Object value : values) {
1985 qPos.add(value);
1986 }
1987 }
1988
1989 List<MBMessage> list = q.list();
1990
1991 if (list.size() == 2) {
1992 return list.get(1);
1993 }
1994 else {
1995 return null;
1996 }
1997 }
1998
1999
2008 public MBMessage findByUUID_G(String uuid, long groupId)
2009 throws NoSuchMessageException, SystemException {
2010 MBMessage mbMessage = fetchByUUID_G(uuid, groupId);
2011
2012 if (mbMessage == null) {
2013 StringBundler msg = new StringBundler(6);
2014
2015 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2016
2017 msg.append("uuid=");
2018 msg.append(uuid);
2019
2020 msg.append(", groupId=");
2021 msg.append(groupId);
2022
2023 msg.append(StringPool.CLOSE_CURLY_BRACE);
2024
2025 if (_log.isWarnEnabled()) {
2026 _log.warn(msg.toString());
2027 }
2028
2029 throw new NoSuchMessageException(msg.toString());
2030 }
2031
2032 return mbMessage;
2033 }
2034
2035
2043 public MBMessage fetchByUUID_G(String uuid, long groupId)
2044 throws SystemException {
2045 return fetchByUUID_G(uuid, groupId, true);
2046 }
2047
2048
2057 public MBMessage fetchByUUID_G(String uuid, long groupId,
2058 boolean retrieveFromCache) throws SystemException {
2059 Object[] finderArgs = new Object[] { uuid, groupId };
2060
2061 Object result = null;
2062
2063 if (retrieveFromCache) {
2064 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
2065 finderArgs, this);
2066 }
2067
2068 if (result == null) {
2069 StringBundler query = new StringBundler(4);
2070
2071 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
2072
2073 if (uuid == null) {
2074 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
2075 }
2076 else {
2077 if (uuid.equals(StringPool.BLANK)) {
2078 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
2079 }
2080 else {
2081 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
2082 }
2083 }
2084
2085 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
2086
2087 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
2088
2089 String sql = query.toString();
2090
2091 Session session = null;
2092
2093 try {
2094 session = openSession();
2095
2096 Query q = session.createQuery(sql);
2097
2098 QueryPos qPos = QueryPos.getInstance(q);
2099
2100 if (uuid != null) {
2101 qPos.add(uuid);
2102 }
2103
2104 qPos.add(groupId);
2105
2106 List<MBMessage> list = q.list();
2107
2108 result = list;
2109
2110 MBMessage mbMessage = null;
2111
2112 if (list.isEmpty()) {
2113 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
2114 finderArgs, list);
2115 }
2116 else {
2117 mbMessage = list.get(0);
2118
2119 cacheResult(mbMessage);
2120
2121 if ((mbMessage.getUuid() == null) ||
2122 !mbMessage.getUuid().equals(uuid) ||
2123 (mbMessage.getGroupId() != groupId)) {
2124 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
2125 finderArgs, mbMessage);
2126 }
2127 }
2128
2129 return mbMessage;
2130 }
2131 catch (Exception e) {
2132 throw processException(e);
2133 }
2134 finally {
2135 if (result == null) {
2136 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
2137 finderArgs);
2138 }
2139
2140 closeSession(session);
2141 }
2142 }
2143 else {
2144 if (result instanceof List<?>) {
2145 return null;
2146 }
2147 else {
2148 return (MBMessage)result;
2149 }
2150 }
2151 }
2152
2153
2160 public List<MBMessage> findByGroupId(long groupId)
2161 throws SystemException {
2162 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2163 }
2164
2165
2178 public List<MBMessage> findByGroupId(long groupId, int start, int end)
2179 throws SystemException {
2180 return findByGroupId(groupId, start, end, null);
2181 }
2182
2183
2197 public List<MBMessage> findByGroupId(long groupId, int start, int end,
2198 OrderByComparator orderByComparator) throws SystemException {
2199 FinderPath finderPath = null;
2200 Object[] finderArgs = null;
2201
2202 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2203 (orderByComparator == null)) {
2204 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
2205 finderArgs = new Object[] { groupId };
2206 }
2207 else {
2208 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
2209 finderArgs = new Object[] { groupId, start, end, orderByComparator };
2210 }
2211
2212 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(finderPath,
2213 finderArgs, this);
2214
2215 if (list == null) {
2216 StringBundler query = null;
2217
2218 if (orderByComparator != null) {
2219 query = new StringBundler(3 +
2220 (orderByComparator.getOrderByFields().length * 3));
2221 }
2222 else {
2223 query = new StringBundler(3);
2224 }
2225
2226 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
2227
2228 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2229
2230 if (orderByComparator != null) {
2231 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2232 orderByComparator);
2233 }
2234
2235 else {
2236 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
2237 }
2238
2239 String sql = query.toString();
2240
2241 Session session = null;
2242
2243 try {
2244 session = openSession();
2245
2246 Query q = session.createQuery(sql);
2247
2248 QueryPos qPos = QueryPos.getInstance(q);
2249
2250 qPos.add(groupId);
2251
2252 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
2253 end);
2254 }
2255 catch (Exception e) {
2256 throw processException(e);
2257 }
2258 finally {
2259 if (list == null) {
2260 FinderCacheUtil.removeResult(finderPath, finderArgs);
2261 }
2262 else {
2263 cacheResult(list);
2264
2265 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2266 }
2267
2268 closeSession(session);
2269 }
2270 }
2271
2272 return list;
2273 }
2274
2275
2288 public MBMessage findByGroupId_First(long groupId,
2289 OrderByComparator orderByComparator)
2290 throws NoSuchMessageException, SystemException {
2291 List<MBMessage> list = findByGroupId(groupId, 0, 1, orderByComparator);
2292
2293 if (list.isEmpty()) {
2294 StringBundler msg = new StringBundler(4);
2295
2296 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2297
2298 msg.append("groupId=");
2299 msg.append(groupId);
2300
2301 msg.append(StringPool.CLOSE_CURLY_BRACE);
2302
2303 throw new NoSuchMessageException(msg.toString());
2304 }
2305 else {
2306 return list.get(0);
2307 }
2308 }
2309
2310
2323 public MBMessage findByGroupId_Last(long groupId,
2324 OrderByComparator orderByComparator)
2325 throws NoSuchMessageException, SystemException {
2326 int count = countByGroupId(groupId);
2327
2328 List<MBMessage> list = findByGroupId(groupId, count - 1, count,
2329 orderByComparator);
2330
2331 if (list.isEmpty()) {
2332 StringBundler msg = new StringBundler(4);
2333
2334 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2335
2336 msg.append("groupId=");
2337 msg.append(groupId);
2338
2339 msg.append(StringPool.CLOSE_CURLY_BRACE);
2340
2341 throw new NoSuchMessageException(msg.toString());
2342 }
2343 else {
2344 return list.get(0);
2345 }
2346 }
2347
2348
2362 public MBMessage[] findByGroupId_PrevAndNext(long messageId, long groupId,
2363 OrderByComparator orderByComparator)
2364 throws NoSuchMessageException, SystemException {
2365 MBMessage mbMessage = findByPrimaryKey(messageId);
2366
2367 Session session = null;
2368
2369 try {
2370 session = openSession();
2371
2372 MBMessage[] array = new MBMessageImpl[3];
2373
2374 array[0] = getByGroupId_PrevAndNext(session, mbMessage, groupId,
2375 orderByComparator, true);
2376
2377 array[1] = mbMessage;
2378
2379 array[2] = getByGroupId_PrevAndNext(session, mbMessage, groupId,
2380 orderByComparator, false);
2381
2382 return array;
2383 }
2384 catch (Exception e) {
2385 throw processException(e);
2386 }
2387 finally {
2388 closeSession(session);
2389 }
2390 }
2391
2392 protected MBMessage getByGroupId_PrevAndNext(Session session,
2393 MBMessage mbMessage, long groupId, OrderByComparator orderByComparator,
2394 boolean previous) {
2395 StringBundler query = null;
2396
2397 if (orderByComparator != null) {
2398 query = new StringBundler(6 +
2399 (orderByComparator.getOrderByFields().length * 6));
2400 }
2401 else {
2402 query = new StringBundler(3);
2403 }
2404
2405 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
2406
2407 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2408
2409 if (orderByComparator != null) {
2410 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2411
2412 if (orderByConditionFields.length > 0) {
2413 query.append(WHERE_AND);
2414 }
2415
2416 for (int i = 0; i < orderByConditionFields.length; i++) {
2417 query.append(_ORDER_BY_ENTITY_ALIAS);
2418 query.append(orderByConditionFields[i]);
2419
2420 if ((i + 1) < orderByConditionFields.length) {
2421 if (orderByComparator.isAscending() ^ previous) {
2422 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2423 }
2424 else {
2425 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2426 }
2427 }
2428 else {
2429 if (orderByComparator.isAscending() ^ previous) {
2430 query.append(WHERE_GREATER_THAN);
2431 }
2432 else {
2433 query.append(WHERE_LESSER_THAN);
2434 }
2435 }
2436 }
2437
2438 query.append(ORDER_BY_CLAUSE);
2439
2440 String[] orderByFields = orderByComparator.getOrderByFields();
2441
2442 for (int i = 0; i < orderByFields.length; i++) {
2443 query.append(_ORDER_BY_ENTITY_ALIAS);
2444 query.append(orderByFields[i]);
2445
2446 if ((i + 1) < orderByFields.length) {
2447 if (orderByComparator.isAscending() ^ previous) {
2448 query.append(ORDER_BY_ASC_HAS_NEXT);
2449 }
2450 else {
2451 query.append(ORDER_BY_DESC_HAS_NEXT);
2452 }
2453 }
2454 else {
2455 if (orderByComparator.isAscending() ^ previous) {
2456 query.append(ORDER_BY_ASC);
2457 }
2458 else {
2459 query.append(ORDER_BY_DESC);
2460 }
2461 }
2462 }
2463 }
2464
2465 else {
2466 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
2467 }
2468
2469 String sql = query.toString();
2470
2471 Query q = session.createQuery(sql);
2472
2473 q.setFirstResult(0);
2474 q.setMaxResults(2);
2475
2476 QueryPos qPos = QueryPos.getInstance(q);
2477
2478 qPos.add(groupId);
2479
2480 if (orderByComparator != null) {
2481 Object[] values = orderByComparator.getOrderByConditionValues(mbMessage);
2482
2483 for (Object value : values) {
2484 qPos.add(value);
2485 }
2486 }
2487
2488 List<MBMessage> list = q.list();
2489
2490 if (list.size() == 2) {
2491 return list.get(1);
2492 }
2493 else {
2494 return null;
2495 }
2496 }
2497
2498
2505 public List<MBMessage> filterFindByGroupId(long groupId)
2506 throws SystemException {
2507 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
2508 QueryUtil.ALL_POS, null);
2509 }
2510
2511
2524 public List<MBMessage> filterFindByGroupId(long groupId, int start, int end)
2525 throws SystemException {
2526 return filterFindByGroupId(groupId, start, end, null);
2527 }
2528
2529
2543 public List<MBMessage> filterFindByGroupId(long groupId, int start,
2544 int end, OrderByComparator orderByComparator) throws SystemException {
2545 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2546 return findByGroupId(groupId, start, end, orderByComparator);
2547 }
2548
2549 StringBundler query = null;
2550
2551 if (orderByComparator != null) {
2552 query = new StringBundler(3 +
2553 (orderByComparator.getOrderByFields().length * 3));
2554 }
2555 else {
2556 query = new StringBundler(3);
2557 }
2558
2559 if (getDB().isSupportsInlineDistinct()) {
2560 query.append(_FILTER_SQL_SELECT_MBMESSAGE_WHERE);
2561 }
2562 else {
2563 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1);
2564 }
2565
2566 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2567
2568 if (!getDB().isSupportsInlineDistinct()) {
2569 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_2);
2570 }
2571
2572 if (orderByComparator != null) {
2573 if (getDB().isSupportsInlineDistinct()) {
2574 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2575 orderByComparator);
2576 }
2577 else {
2578 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2579 orderByComparator);
2580 }
2581 }
2582
2583 else {
2584 if (getDB().isSupportsInlineDistinct()) {
2585 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
2586 }
2587 else {
2588 query.append(MBMessageModelImpl.ORDER_BY_SQL);
2589 }
2590 }
2591
2592 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2593 MBMessage.class.getName(),
2594 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2595
2596 Session session = null;
2597
2598 try {
2599 session = openSession();
2600
2601 SQLQuery q = session.createSQLQuery(sql);
2602
2603 if (getDB().isSupportsInlineDistinct()) {
2604 q.addEntity(_FILTER_ENTITY_ALIAS, MBMessageImpl.class);
2605 }
2606 else {
2607 q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class);
2608 }
2609
2610 QueryPos qPos = QueryPos.getInstance(q);
2611
2612 qPos.add(groupId);
2613
2614 return (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end);
2615 }
2616 catch (Exception e) {
2617 throw processException(e);
2618 }
2619 finally {
2620 closeSession(session);
2621 }
2622 }
2623
2624
2634 public MBMessage[] filterFindByGroupId_PrevAndNext(long messageId,
2635 long groupId, OrderByComparator orderByComparator)
2636 throws NoSuchMessageException, SystemException {
2637 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2638 return findByGroupId_PrevAndNext(messageId, groupId,
2639 orderByComparator);
2640 }
2641
2642 MBMessage mbMessage = findByPrimaryKey(messageId);
2643
2644 Session session = null;
2645
2646 try {
2647 session = openSession();
2648
2649 MBMessage[] array = new MBMessageImpl[3];
2650
2651 array[0] = filterGetByGroupId_PrevAndNext(session, mbMessage,
2652 groupId, orderByComparator, true);
2653
2654 array[1] = mbMessage;
2655
2656 array[2] = filterGetByGroupId_PrevAndNext(session, mbMessage,
2657 groupId, orderByComparator, false);
2658
2659 return array;
2660 }
2661 catch (Exception e) {
2662 throw processException(e);
2663 }
2664 finally {
2665 closeSession(session);
2666 }
2667 }
2668
2669 protected MBMessage filterGetByGroupId_PrevAndNext(Session session,
2670 MBMessage mbMessage, long groupId, OrderByComparator orderByComparator,
2671 boolean previous) {
2672 StringBundler query = null;
2673
2674 if (orderByComparator != null) {
2675 query = new StringBundler(6 +
2676 (orderByComparator.getOrderByFields().length * 6));
2677 }
2678 else {
2679 query = new StringBundler(3);
2680 }
2681
2682 if (getDB().isSupportsInlineDistinct()) {
2683 query.append(_FILTER_SQL_SELECT_MBMESSAGE_WHERE);
2684 }
2685 else {
2686 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1);
2687 }
2688
2689 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2690
2691 if (!getDB().isSupportsInlineDistinct()) {
2692 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_2);
2693 }
2694
2695 if (orderByComparator != null) {
2696 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2697
2698 if (orderByConditionFields.length > 0) {
2699 query.append(WHERE_AND);
2700 }
2701
2702 for (int i = 0; i < orderByConditionFields.length; i++) {
2703 if (getDB().isSupportsInlineDistinct()) {
2704 query.append(_ORDER_BY_ENTITY_ALIAS);
2705 }
2706 else {
2707 query.append(_ORDER_BY_ENTITY_TABLE);
2708 }
2709
2710 query.append(orderByConditionFields[i]);
2711
2712 if ((i + 1) < orderByConditionFields.length) {
2713 if (orderByComparator.isAscending() ^ previous) {
2714 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2715 }
2716 else {
2717 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2718 }
2719 }
2720 else {
2721 if (orderByComparator.isAscending() ^ previous) {
2722 query.append(WHERE_GREATER_THAN);
2723 }
2724 else {
2725 query.append(WHERE_LESSER_THAN);
2726 }
2727 }
2728 }
2729
2730 query.append(ORDER_BY_CLAUSE);
2731
2732 String[] orderByFields = orderByComparator.getOrderByFields();
2733
2734 for (int i = 0; i < orderByFields.length; i++) {
2735 if (getDB().isSupportsInlineDistinct()) {
2736 query.append(_ORDER_BY_ENTITY_ALIAS);
2737 }
2738 else {
2739 query.append(_ORDER_BY_ENTITY_TABLE);
2740 }
2741
2742 query.append(orderByFields[i]);
2743
2744 if ((i + 1) < orderByFields.length) {
2745 if (orderByComparator.isAscending() ^ previous) {
2746 query.append(ORDER_BY_ASC_HAS_NEXT);
2747 }
2748 else {
2749 query.append(ORDER_BY_DESC_HAS_NEXT);
2750 }
2751 }
2752 else {
2753 if (orderByComparator.isAscending() ^ previous) {
2754 query.append(ORDER_BY_ASC);
2755 }
2756 else {
2757 query.append(ORDER_BY_DESC);
2758 }
2759 }
2760 }
2761 }
2762
2763 else {
2764 if (getDB().isSupportsInlineDistinct()) {
2765 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
2766 }
2767 else {
2768 query.append(MBMessageModelImpl.ORDER_BY_SQL);
2769 }
2770 }
2771
2772 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2773 MBMessage.class.getName(),
2774 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2775
2776 SQLQuery q = session.createSQLQuery(sql);
2777
2778 q.setFirstResult(0);
2779 q.setMaxResults(2);
2780
2781 if (getDB().isSupportsInlineDistinct()) {
2782 q.addEntity(_FILTER_ENTITY_ALIAS, MBMessageImpl.class);
2783 }
2784 else {
2785 q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class);
2786 }
2787
2788 QueryPos qPos = QueryPos.getInstance(q);
2789
2790 qPos.add(groupId);
2791
2792 if (orderByComparator != null) {
2793 Object[] values = orderByComparator.getOrderByConditionValues(mbMessage);
2794
2795 for (Object value : values) {
2796 qPos.add(value);
2797 }
2798 }
2799
2800 List<MBMessage> list = q.list();
2801
2802 if (list.size() == 2) {
2803 return list.get(1);
2804 }
2805 else {
2806 return null;
2807 }
2808 }
2809
2810
2817 public List<MBMessage> findByCompanyId(long companyId)
2818 throws SystemException {
2819 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2820 null);
2821 }
2822
2823
2836 public List<MBMessage> findByCompanyId(long companyId, int start, int end)
2837 throws SystemException {
2838 return findByCompanyId(companyId, start, end, null);
2839 }
2840
2841
2855 public List<MBMessage> findByCompanyId(long companyId, int start, int end,
2856 OrderByComparator orderByComparator) throws SystemException {
2857 FinderPath finderPath = null;
2858 Object[] finderArgs = null;
2859
2860 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2861 (orderByComparator == null)) {
2862 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2863 finderArgs = new Object[] { companyId };
2864 }
2865 else {
2866 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2867 finderArgs = new Object[] { companyId, start, end, orderByComparator };
2868 }
2869
2870 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(finderPath,
2871 finderArgs, this);
2872
2873 if (list == null) {
2874 StringBundler query = null;
2875
2876 if (orderByComparator != null) {
2877 query = new StringBundler(3 +
2878 (orderByComparator.getOrderByFields().length * 3));
2879 }
2880 else {
2881 query = new StringBundler(3);
2882 }
2883
2884 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
2885
2886 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2887
2888 if (orderByComparator != null) {
2889 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2890 orderByComparator);
2891 }
2892
2893 else {
2894 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
2895 }
2896
2897 String sql = query.toString();
2898
2899 Session session = null;
2900
2901 try {
2902 session = openSession();
2903
2904 Query q = session.createQuery(sql);
2905
2906 QueryPos qPos = QueryPos.getInstance(q);
2907
2908 qPos.add(companyId);
2909
2910 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
2911 end);
2912 }
2913 catch (Exception e) {
2914 throw processException(e);
2915 }
2916 finally {
2917 if (list == null) {
2918 FinderCacheUtil.removeResult(finderPath, finderArgs);
2919 }
2920 else {
2921 cacheResult(list);
2922
2923 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2924 }
2925
2926 closeSession(session);
2927 }
2928 }
2929
2930 return list;
2931 }
2932
2933
2946 public MBMessage findByCompanyId_First(long companyId,
2947 OrderByComparator orderByComparator)
2948 throws NoSuchMessageException, SystemException {
2949 List<MBMessage> list = findByCompanyId(companyId, 0, 1,
2950 orderByComparator);
2951
2952 if (list.isEmpty()) {
2953 StringBundler msg = new StringBundler(4);
2954
2955 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2956
2957 msg.append("companyId=");
2958 msg.append(companyId);
2959
2960 msg.append(StringPool.CLOSE_CURLY_BRACE);
2961
2962 throw new NoSuchMessageException(msg.toString());
2963 }
2964 else {
2965 return list.get(0);
2966 }
2967 }
2968
2969
2982 public MBMessage findByCompanyId_Last(long companyId,
2983 OrderByComparator orderByComparator)
2984 throws NoSuchMessageException, SystemException {
2985 int count = countByCompanyId(companyId);
2986
2987 List<MBMessage> list = findByCompanyId(companyId, count - 1, count,
2988 orderByComparator);
2989
2990 if (list.isEmpty()) {
2991 StringBundler msg = new StringBundler(4);
2992
2993 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2994
2995 msg.append("companyId=");
2996 msg.append(companyId);
2997
2998 msg.append(StringPool.CLOSE_CURLY_BRACE);
2999
3000 throw new NoSuchMessageException(msg.toString());
3001 }
3002 else {
3003 return list.get(0);
3004 }
3005 }
3006
3007
3021 public MBMessage[] findByCompanyId_PrevAndNext(long messageId,
3022 long companyId, OrderByComparator orderByComparator)
3023 throws NoSuchMessageException, SystemException {
3024 MBMessage mbMessage = findByPrimaryKey(messageId);
3025
3026 Session session = null;
3027
3028 try {
3029 session = openSession();
3030
3031 MBMessage[] array = new MBMessageImpl[3];
3032
3033 array[0] = getByCompanyId_PrevAndNext(session, mbMessage,
3034 companyId, orderByComparator, true);
3035
3036 array[1] = mbMessage;
3037
3038 array[2] = getByCompanyId_PrevAndNext(session, mbMessage,
3039 companyId, orderByComparator, false);
3040
3041 return array;
3042 }
3043 catch (Exception e) {
3044 throw processException(e);
3045 }
3046 finally {
3047 closeSession(session);
3048 }
3049 }
3050
3051 protected MBMessage getByCompanyId_PrevAndNext(Session session,
3052 MBMessage mbMessage, long companyId,
3053 OrderByComparator orderByComparator, boolean previous) {
3054 StringBundler query = null;
3055
3056 if (orderByComparator != null) {
3057 query = new StringBundler(6 +
3058 (orderByComparator.getOrderByFields().length * 6));
3059 }
3060 else {
3061 query = new StringBundler(3);
3062 }
3063
3064 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
3065
3066 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3067
3068 if (orderByComparator != null) {
3069 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3070
3071 if (orderByConditionFields.length > 0) {
3072 query.append(WHERE_AND);
3073 }
3074
3075 for (int i = 0; i < orderByConditionFields.length; i++) {
3076 query.append(_ORDER_BY_ENTITY_ALIAS);
3077 query.append(orderByConditionFields[i]);
3078
3079 if ((i + 1) < orderByConditionFields.length) {
3080 if (orderByComparator.isAscending() ^ previous) {
3081 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3082 }
3083 else {
3084 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3085 }
3086 }
3087 else {
3088 if (orderByComparator.isAscending() ^ previous) {
3089 query.append(WHERE_GREATER_THAN);
3090 }
3091 else {
3092 query.append(WHERE_LESSER_THAN);
3093 }
3094 }
3095 }
3096
3097 query.append(ORDER_BY_CLAUSE);
3098
3099 String[] orderByFields = orderByComparator.getOrderByFields();
3100
3101 for (int i = 0; i < orderByFields.length; i++) {
3102 query.append(_ORDER_BY_ENTITY_ALIAS);
3103 query.append(orderByFields[i]);
3104
3105 if ((i + 1) < orderByFields.length) {
3106 if (orderByComparator.isAscending() ^ previous) {
3107 query.append(ORDER_BY_ASC_HAS_NEXT);
3108 }
3109 else {
3110 query.append(ORDER_BY_DESC_HAS_NEXT);
3111 }
3112 }
3113 else {
3114 if (orderByComparator.isAscending() ^ previous) {
3115 query.append(ORDER_BY_ASC);
3116 }
3117 else {
3118 query.append(ORDER_BY_DESC);
3119 }
3120 }
3121 }
3122 }
3123
3124 else {
3125 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
3126 }
3127
3128 String sql = query.toString();
3129
3130 Query q = session.createQuery(sql);
3131
3132 q.setFirstResult(0);
3133 q.setMaxResults(2);
3134
3135 QueryPos qPos = QueryPos.getInstance(q);
3136
3137 qPos.add(companyId);
3138
3139 if (orderByComparator != null) {
3140 Object[] values = orderByComparator.getOrderByConditionValues(mbMessage);
3141
3142 for (Object value : values) {
3143 qPos.add(value);
3144 }
3145 }
3146
3147 List<MBMessage> list = q.list();
3148
3149 if (list.size() == 2) {
3150 return list.get(1);
3151 }
3152 else {
3153 return null;
3154 }
3155 }
3156
3157
3164 public List<MBMessage> findByThreadId(long threadId)
3165 throws SystemException {
3166 return findByThreadId(threadId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3167 null);
3168 }
3169
3170
3183 public List<MBMessage> findByThreadId(long threadId, int start, int end)
3184 throws SystemException {
3185 return findByThreadId(threadId, start, end, null);
3186 }
3187
3188
3202 public List<MBMessage> findByThreadId(long threadId, int start, int end,
3203 OrderByComparator orderByComparator) throws SystemException {
3204 FinderPath finderPath = null;
3205 Object[] finderArgs = null;
3206
3207 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3208 (orderByComparator == null)) {
3209 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_THREADID;
3210 finderArgs = new Object[] { threadId };
3211 }
3212 else {
3213 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_THREADID;
3214 finderArgs = new Object[] { threadId, start, end, orderByComparator };
3215 }
3216
3217 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(finderPath,
3218 finderArgs, this);
3219
3220 if (list == null) {
3221 StringBundler query = null;
3222
3223 if (orderByComparator != null) {
3224 query = new StringBundler(3 +
3225 (orderByComparator.getOrderByFields().length * 3));
3226 }
3227 else {
3228 query = new StringBundler(3);
3229 }
3230
3231 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
3232
3233 query.append(_FINDER_COLUMN_THREADID_THREADID_2);
3234
3235 if (orderByComparator != null) {
3236 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3237 orderByComparator);
3238 }
3239
3240 else {
3241 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
3242 }
3243
3244 String sql = query.toString();
3245
3246 Session session = null;
3247
3248 try {
3249 session = openSession();
3250
3251 Query q = session.createQuery(sql);
3252
3253 QueryPos qPos = QueryPos.getInstance(q);
3254
3255 qPos.add(threadId);
3256
3257 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
3258 end);
3259 }
3260 catch (Exception e) {
3261 throw processException(e);
3262 }
3263 finally {
3264 if (list == null) {
3265 FinderCacheUtil.removeResult(finderPath, finderArgs);
3266 }
3267 else {
3268 cacheResult(list);
3269
3270 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3271 }
3272
3273 closeSession(session);
3274 }
3275 }
3276
3277 return list;
3278 }
3279
3280
3293 public MBMessage findByThreadId_First(long threadId,
3294 OrderByComparator orderByComparator)
3295 throws NoSuchMessageException, SystemException {
3296 List<MBMessage> list = findByThreadId(threadId, 0, 1, orderByComparator);
3297
3298 if (list.isEmpty()) {
3299 StringBundler msg = new StringBundler(4);
3300
3301 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3302
3303 msg.append("threadId=");
3304 msg.append(threadId);
3305
3306 msg.append(StringPool.CLOSE_CURLY_BRACE);
3307
3308 throw new NoSuchMessageException(msg.toString());
3309 }
3310 else {
3311 return list.get(0);
3312 }
3313 }
3314
3315
3328 public MBMessage findByThreadId_Last(long threadId,
3329 OrderByComparator orderByComparator)
3330 throws NoSuchMessageException, SystemException {
3331 int count = countByThreadId(threadId);
3332
3333 List<MBMessage> list = findByThreadId(threadId, count - 1, count,
3334 orderByComparator);
3335
3336 if (list.isEmpty()) {
3337 StringBundler msg = new StringBundler(4);
3338
3339 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3340
3341 msg.append("threadId=");
3342 msg.append(threadId);
3343
3344 msg.append(StringPool.CLOSE_CURLY_BRACE);
3345
3346 throw new NoSuchMessageException(msg.toString());
3347 }
3348 else {
3349 return list.get(0);
3350 }
3351 }
3352
3353
3367 public MBMessage[] findByThreadId_PrevAndNext(long messageId,
3368 long threadId, OrderByComparator orderByComparator)
3369 throws NoSuchMessageException, SystemException {
3370 MBMessage mbMessage = findByPrimaryKey(messageId);
3371
3372 Session session = null;
3373
3374 try {
3375 session = openSession();
3376
3377 MBMessage[] array = new MBMessageImpl[3];
3378
3379 array[0] = getByThreadId_PrevAndNext(session, mbMessage, threadId,
3380 orderByComparator, true);
3381
3382 array[1] = mbMessage;
3383
3384 array[2] = getByThreadId_PrevAndNext(session, mbMessage, threadId,
3385 orderByComparator, false);
3386
3387 return array;
3388 }
3389 catch (Exception e) {
3390 throw processException(e);
3391 }
3392 finally {
3393 closeSession(session);
3394 }
3395 }
3396
3397 protected MBMessage getByThreadId_PrevAndNext(Session session,
3398 MBMessage mbMessage, long threadId,
3399 OrderByComparator orderByComparator, boolean previous) {
3400 StringBundler query = null;
3401
3402 if (orderByComparator != null) {
3403 query = new StringBundler(6 +
3404 (orderByComparator.getOrderByFields().length * 6));
3405 }
3406 else {
3407 query = new StringBundler(3);
3408 }
3409
3410 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
3411
3412 query.append(_FINDER_COLUMN_THREADID_THREADID_2);
3413
3414 if (orderByComparator != null) {
3415 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3416
3417 if (orderByConditionFields.length > 0) {
3418 query.append(WHERE_AND);
3419 }
3420
3421 for (int i = 0; i < orderByConditionFields.length; i++) {
3422 query.append(_ORDER_BY_ENTITY_ALIAS);
3423 query.append(orderByConditionFields[i]);
3424
3425 if ((i + 1) < orderByConditionFields.length) {
3426 if (orderByComparator.isAscending() ^ previous) {
3427 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3428 }
3429 else {
3430 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3431 }
3432 }
3433 else {
3434 if (orderByComparator.isAscending() ^ previous) {
3435 query.append(WHERE_GREATER_THAN);
3436 }
3437 else {
3438 query.append(WHERE_LESSER_THAN);
3439 }
3440 }
3441 }
3442
3443 query.append(ORDER_BY_CLAUSE);
3444
3445 String[] orderByFields = orderByComparator.getOrderByFields();
3446
3447 for (int i = 0; i < orderByFields.length; i++) {
3448 query.append(_ORDER_BY_ENTITY_ALIAS);
3449 query.append(orderByFields[i]);
3450
3451 if ((i + 1) < orderByFields.length) {
3452 if (orderByComparator.isAscending() ^ previous) {
3453 query.append(ORDER_BY_ASC_HAS_NEXT);
3454 }
3455 else {
3456 query.append(ORDER_BY_DESC_HAS_NEXT);
3457 }
3458 }
3459 else {
3460 if (orderByComparator.isAscending() ^ previous) {
3461 query.append(ORDER_BY_ASC);
3462 }
3463 else {
3464 query.append(ORDER_BY_DESC);
3465 }
3466 }
3467 }
3468 }
3469
3470 else {
3471 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
3472 }
3473
3474 String sql = query.toString();
3475
3476 Query q = session.createQuery(sql);
3477
3478 q.setFirstResult(0);
3479 q.setMaxResults(2);
3480
3481 QueryPos qPos = QueryPos.getInstance(q);
3482
3483 qPos.add(threadId);
3484
3485 if (orderByComparator != null) {
3486 Object[] values = orderByComparator.getOrderByConditionValues(mbMessage);
3487
3488 for (Object value : values) {
3489 qPos.add(value);
3490 }
3491 }
3492
3493 List<MBMessage> list = q.list();
3494
3495 if (list.size() == 2) {
3496 return list.get(1);
3497 }
3498 else {
3499 return null;
3500 }
3501 }
3502
3503
3510 public List<MBMessage> findByThreadReplies(long threadId)
3511 throws SystemException {
3512 return findByThreadReplies(threadId, QueryUtil.ALL_POS,
3513 QueryUtil.ALL_POS, null);
3514 }
3515
3516
3529 public List<MBMessage> findByThreadReplies(long threadId, int start, int end)
3530 throws SystemException {
3531 return findByThreadReplies(threadId, start, end, null);
3532 }
3533
3534
3548 public List<MBMessage> findByThreadReplies(long threadId, int start,
3549 int end, OrderByComparator orderByComparator) throws SystemException {
3550 FinderPath finderPath = null;
3551 Object[] finderArgs = null;
3552
3553 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3554 (orderByComparator == null)) {
3555 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_THREADREPLIES;
3556 finderArgs = new Object[] { threadId };
3557 }
3558 else {
3559 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_THREADREPLIES;
3560 finderArgs = new Object[] { threadId, start, end, orderByComparator };
3561 }
3562
3563 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(finderPath,
3564 finderArgs, this);
3565
3566 if (list == null) {
3567 StringBundler query = null;
3568
3569 if (orderByComparator != null) {
3570 query = new StringBundler(3 +
3571 (orderByComparator.getOrderByFields().length * 3));
3572 }
3573 else {
3574 query = new StringBundler(3);
3575 }
3576
3577 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
3578
3579 query.append(_FINDER_COLUMN_THREADREPLIES_THREADID_2);
3580
3581 if (orderByComparator != null) {
3582 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3583 orderByComparator);
3584 }
3585
3586 else {
3587 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
3588 }
3589
3590 String sql = query.toString();
3591
3592 Session session = null;
3593
3594 try {
3595 session = openSession();
3596
3597 Query q = session.createQuery(sql);
3598
3599 QueryPos qPos = QueryPos.getInstance(q);
3600
3601 qPos.add(threadId);
3602
3603 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
3604 end);
3605 }
3606 catch (Exception e) {
3607 throw processException(e);
3608 }
3609 finally {
3610 if (list == null) {
3611 FinderCacheUtil.removeResult(finderPath, finderArgs);
3612 }
3613 else {
3614 cacheResult(list);
3615
3616 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3617 }
3618
3619 closeSession(session);
3620 }
3621 }
3622
3623 return list;
3624 }
3625
3626
3639 public MBMessage findByThreadReplies_First(long threadId,
3640 OrderByComparator orderByComparator)
3641 throws NoSuchMessageException, SystemException {
3642 List<MBMessage> list = findByThreadReplies(threadId, 0, 1,
3643 orderByComparator);
3644
3645 if (list.isEmpty()) {
3646 StringBundler msg = new StringBundler(4);
3647
3648 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3649
3650 msg.append("threadId=");
3651 msg.append(threadId);
3652
3653 msg.append(StringPool.CLOSE_CURLY_BRACE);
3654
3655 throw new NoSuchMessageException(msg.toString());
3656 }
3657 else {
3658 return list.get(0);
3659 }
3660 }
3661
3662
3675 public MBMessage findByThreadReplies_Last(long threadId,
3676 OrderByComparator orderByComparator)
3677 throws NoSuchMessageException, SystemException {
3678 int count = countByThreadReplies(threadId);
3679
3680 List<MBMessage> list = findByThreadReplies(threadId, count - 1, count,
3681 orderByComparator);
3682
3683 if (list.isEmpty()) {
3684 StringBundler msg = new StringBundler(4);
3685
3686 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3687
3688 msg.append("threadId=");
3689 msg.append(threadId);
3690
3691 msg.append(StringPool.CLOSE_CURLY_BRACE);
3692
3693 throw new NoSuchMessageException(msg.toString());
3694 }
3695 else {
3696 return list.get(0);
3697 }
3698 }
3699
3700
3714 public MBMessage[] findByThreadReplies_PrevAndNext(long messageId,
3715 long threadId, OrderByComparator orderByComparator)
3716 throws NoSuchMessageException, SystemException {
3717 MBMessage mbMessage = findByPrimaryKey(messageId);
3718
3719 Session session = null;
3720
3721 try {
3722 session = openSession();
3723
3724 MBMessage[] array = new MBMessageImpl[3];
3725
3726 array[0] = getByThreadReplies_PrevAndNext(session, mbMessage,
3727 threadId, orderByComparator, true);
3728
3729 array[1] = mbMessage;
3730
3731 array[2] = getByThreadReplies_PrevAndNext(session, mbMessage,
3732 threadId, orderByComparator, false);
3733
3734 return array;
3735 }
3736 catch (Exception e) {
3737 throw processException(e);
3738 }
3739 finally {
3740 closeSession(session);
3741 }
3742 }
3743
3744 protected MBMessage getByThreadReplies_PrevAndNext(Session session,
3745 MBMessage mbMessage, long threadId,
3746 OrderByComparator orderByComparator, boolean previous) {
3747 StringBundler query = null;
3748
3749 if (orderByComparator != null) {
3750 query = new StringBundler(6 +
3751 (orderByComparator.getOrderByFields().length * 6));
3752 }
3753 else {
3754 query = new StringBundler(3);
3755 }
3756
3757 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
3758
3759 query.append(_FINDER_COLUMN_THREADREPLIES_THREADID_2);
3760
3761 if (orderByComparator != null) {
3762 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3763
3764 if (orderByConditionFields.length > 0) {
3765 query.append(WHERE_AND);
3766 }
3767
3768 for (int i = 0; i < orderByConditionFields.length; i++) {
3769 query.append(_ORDER_BY_ENTITY_ALIAS);
3770 query.append(orderByConditionFields[i]);
3771
3772 if ((i + 1) < orderByConditionFields.length) {
3773 if (orderByComparator.isAscending() ^ previous) {
3774 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3775 }
3776 else {
3777 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3778 }
3779 }
3780 else {
3781 if (orderByComparator.isAscending() ^ previous) {
3782 query.append(WHERE_GREATER_THAN);
3783 }
3784 else {
3785 query.append(WHERE_LESSER_THAN);
3786 }
3787 }
3788 }
3789
3790 query.append(ORDER_BY_CLAUSE);
3791
3792 String[] orderByFields = orderByComparator.getOrderByFields();
3793
3794 for (int i = 0; i < orderByFields.length; i++) {
3795 query.append(_ORDER_BY_ENTITY_ALIAS);
3796 query.append(orderByFields[i]);
3797
3798 if ((i + 1) < orderByFields.length) {
3799 if (orderByComparator.isAscending() ^ previous) {
3800 query.append(ORDER_BY_ASC_HAS_NEXT);
3801 }
3802 else {
3803 query.append(ORDER_BY_DESC_HAS_NEXT);
3804 }
3805 }
3806 else {
3807 if (orderByComparator.isAscending() ^ previous) {
3808 query.append(ORDER_BY_ASC);
3809 }
3810 else {
3811 query.append(ORDER_BY_DESC);
3812 }
3813 }
3814 }
3815 }
3816
3817 else {
3818 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
3819 }
3820
3821 String sql = query.toString();
3822
3823 Query q = session.createQuery(sql);
3824
3825 q.setFirstResult(0);
3826 q.setMaxResults(2);
3827
3828 QueryPos qPos = QueryPos.getInstance(q);
3829
3830 qPos.add(threadId);
3831
3832 if (orderByComparator != null) {
3833 Object[] values = orderByComparator.getOrderByConditionValues(mbMessage);
3834
3835 for (Object value : values) {
3836 qPos.add(value);
3837 }
3838 }
3839
3840 List<MBMessage> list = q.list();
3841
3842 if (list.size() == 2) {
3843 return list.get(1);
3844 }
3845 else {
3846 return null;
3847 }
3848 }
3849
3850
3857 public List<MBMessage> findByUserId(long userId) throws SystemException {
3858 return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3859 }
3860
3861
3874 public List<MBMessage> findByUserId(long userId, int start, int end)
3875 throws SystemException {
3876 return findByUserId(userId, start, end, null);
3877 }
3878
3879
3893 public List<MBMessage> findByUserId(long userId, int start, int end,
3894 OrderByComparator orderByComparator) throws SystemException {
3895 FinderPath finderPath = null;
3896 Object[] finderArgs = null;
3897
3898 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3899 (orderByComparator == null)) {
3900 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
3901 finderArgs = new Object[] { userId };
3902 }
3903 else {
3904 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
3905 finderArgs = new Object[] { userId, start, end, orderByComparator };
3906 }
3907
3908 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(finderPath,
3909 finderArgs, this);
3910
3911 if (list == null) {
3912 StringBundler query = null;
3913
3914 if (orderByComparator != null) {
3915 query = new StringBundler(3 +
3916 (orderByComparator.getOrderByFields().length * 3));
3917 }
3918 else {
3919 query = new StringBundler(3);
3920 }
3921
3922 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
3923
3924 query.append(_FINDER_COLUMN_USERID_USERID_2);
3925
3926 if (orderByComparator != null) {
3927 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3928 orderByComparator);
3929 }
3930
3931 else {
3932 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
3933 }
3934
3935 String sql = query.toString();
3936
3937 Session session = null;
3938
3939 try {
3940 session = openSession();
3941
3942 Query q = session.createQuery(sql);
3943
3944 QueryPos qPos = QueryPos.getInstance(q);
3945
3946 qPos.add(userId);
3947
3948 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
3949 end);
3950 }
3951 catch (Exception e) {
3952 throw processException(e);
3953 }
3954 finally {
3955 if (list == null) {
3956 FinderCacheUtil.removeResult(finderPath, finderArgs);
3957 }
3958 else {
3959 cacheResult(list);
3960
3961 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3962 }
3963
3964 closeSession(session);
3965 }
3966 }
3967
3968 return list;
3969 }
3970
3971
3984 public MBMessage findByUserId_First(long userId,
3985 OrderByComparator orderByComparator)
3986 throws NoSuchMessageException, SystemException {
3987 List<MBMessage> list = findByUserId(userId, 0, 1, orderByComparator);
3988
3989 if (list.isEmpty()) {
3990 StringBundler msg = new StringBundler(4);
3991
3992 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3993
3994 msg.append("userId=");
3995 msg.append(userId);
3996
3997 msg.append(StringPool.CLOSE_CURLY_BRACE);
3998
3999 throw new NoSuchMessageException(msg.toString());
4000 }
4001 else {
4002 return list.get(0);
4003 }
4004 }
4005
4006
4019 public MBMessage findByUserId_Last(long userId,
4020 OrderByComparator orderByComparator)
4021 throws NoSuchMessageException, SystemException {
4022 int count = countByUserId(userId);
4023
4024 List<MBMessage> list = findByUserId(userId, count - 1, count,
4025 orderByComparator);
4026
4027 if (list.isEmpty()) {
4028 StringBundler msg = new StringBundler(4);
4029
4030 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4031
4032 msg.append("userId=");
4033 msg.append(userId);
4034
4035 msg.append(StringPool.CLOSE_CURLY_BRACE);
4036
4037 throw new NoSuchMessageException(msg.toString());
4038 }
4039 else {
4040 return list.get(0);
4041 }
4042 }
4043
4044
4058 public MBMessage[] findByUserId_PrevAndNext(long messageId, long userId,
4059 OrderByComparator orderByComparator)
4060 throws NoSuchMessageException, SystemException {
4061 MBMessage mbMessage = findByPrimaryKey(messageId);
4062
4063 Session session = null;
4064
4065 try {
4066 session = openSession();
4067
4068 MBMessage[] array = new MBMessageImpl[3];
4069
4070 array[0] = getByUserId_PrevAndNext(session, mbMessage, userId,
4071 orderByComparator, true);
4072
4073 array[1] = mbMessage;
4074
4075 array[2] = getByUserId_PrevAndNext(session, mbMessage, userId,
4076 orderByComparator, false);
4077
4078 return array;
4079 }
4080 catch (Exception e) {
4081 throw processException(e);
4082 }
4083 finally {
4084 closeSession(session);
4085 }
4086 }
4087
4088 protected MBMessage getByUserId_PrevAndNext(Session session,
4089 MBMessage mbMessage, long userId, OrderByComparator orderByComparator,
4090 boolean previous) {
4091 StringBundler query = null;
4092
4093 if (orderByComparator != null) {
4094 query = new StringBundler(6 +
4095 (orderByComparator.getOrderByFields().length * 6));
4096 }
4097 else {
4098 query = new StringBundler(3);
4099 }
4100
4101 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
4102
4103 query.append(_FINDER_COLUMN_USERID_USERID_2);
4104
4105 if (orderByComparator != null) {
4106 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4107
4108 if (orderByConditionFields.length > 0) {
4109 query.append(WHERE_AND);
4110 }
4111
4112 for (int i = 0; i < orderByConditionFields.length; i++) {
4113 query.append(_ORDER_BY_ENTITY_ALIAS);
4114 query.append(orderByConditionFields[i]);
4115
4116 if ((i + 1) < orderByConditionFields.length) {
4117 if (orderByComparator.isAscending() ^ previous) {
4118 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4119 }
4120 else {
4121 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4122 }
4123 }
4124 else {
4125 if (orderByComparator.isAscending() ^ previous) {
4126 query.append(WHERE_GREATER_THAN);
4127 }
4128 else {
4129 query.append(WHERE_LESSER_THAN);
4130 }
4131 }
4132 }
4133
4134 query.append(ORDER_BY_CLAUSE);
4135
4136 String[] orderByFields = orderByComparator.getOrderByFields();
4137
4138 for (int i = 0; i < orderByFields.length; i++) {
4139 query.append(_ORDER_BY_ENTITY_ALIAS);
4140 query.append(orderByFields[i]);
4141
4142 if ((i + 1) < orderByFields.length) {
4143 if (orderByComparator.isAscending() ^ previous) {
4144 query.append(ORDER_BY_ASC_HAS_NEXT);
4145 }
4146 else {
4147 query.append(ORDER_BY_DESC_HAS_NEXT);
4148 }
4149 }
4150 else {
4151 if (orderByComparator.isAscending() ^ previous) {
4152 query.append(ORDER_BY_ASC);
4153 }
4154 else {
4155 query.append(ORDER_BY_DESC);
4156 }
4157 }
4158 }
4159 }
4160
4161 else {
4162 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
4163 }
4164
4165 String sql = query.toString();
4166
4167 Query q = session.createQuery(sql);
4168
4169 q.setFirstResult(0);
4170 q.setMaxResults(2);
4171
4172 QueryPos qPos = QueryPos.getInstance(q);
4173
4174 qPos.add(userId);
4175
4176 if (orderByComparator != null) {
4177 Object[] values = orderByComparator.getOrderByConditionValues(mbMessage);
4178
4179 for (Object value : values) {
4180 qPos.add(value);
4181 }
4182 }
4183
4184 List<MBMessage> list = q.list();
4185
4186 if (list.size() == 2) {
4187 return list.get(1);
4188 }
4189 else {
4190 return null;
4191 }
4192 }
4193
4194
4202 public List<MBMessage> findByG_U(long groupId, long userId)
4203 throws SystemException {
4204 return findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
4205 null);
4206 }
4207
4208
4222 public List<MBMessage> findByG_U(long groupId, long userId, int start,
4223 int end) throws SystemException {
4224 return findByG_U(groupId, userId, start, end, null);
4225 }
4226
4227
4242 public List<MBMessage> findByG_U(long groupId, long userId, int start,
4243 int end, OrderByComparator orderByComparator) throws SystemException {
4244 FinderPath finderPath = null;
4245 Object[] finderArgs = null;
4246
4247 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4248 (orderByComparator == null)) {
4249 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U;
4250 finderArgs = new Object[] { groupId, userId };
4251 }
4252 else {
4253 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U;
4254 finderArgs = new Object[] {
4255 groupId, userId,
4256
4257 start, end, orderByComparator
4258 };
4259 }
4260
4261 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(finderPath,
4262 finderArgs, this);
4263
4264 if (list == null) {
4265 StringBundler query = null;
4266
4267 if (orderByComparator != null) {
4268 query = new StringBundler(4 +
4269 (orderByComparator.getOrderByFields().length * 3));
4270 }
4271 else {
4272 query = new StringBundler(4);
4273 }
4274
4275 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
4276
4277 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
4278
4279 query.append(_FINDER_COLUMN_G_U_USERID_2);
4280
4281 if (orderByComparator != null) {
4282 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4283 orderByComparator);
4284 }
4285
4286 else {
4287 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
4288 }
4289
4290 String sql = query.toString();
4291
4292 Session session = null;
4293
4294 try {
4295 session = openSession();
4296
4297 Query q = session.createQuery(sql);
4298
4299 QueryPos qPos = QueryPos.getInstance(q);
4300
4301 qPos.add(groupId);
4302
4303 qPos.add(userId);
4304
4305 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
4306 end);
4307 }
4308 catch (Exception e) {
4309 throw processException(e);
4310 }
4311 finally {
4312 if (list == null) {
4313 FinderCacheUtil.removeResult(finderPath, finderArgs);
4314 }
4315 else {
4316 cacheResult(list);
4317
4318 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4319 }
4320
4321 closeSession(session);
4322 }
4323 }
4324
4325 return list;
4326 }
4327
4328
4342 public MBMessage findByG_U_First(long groupId, long userId,
4343 OrderByComparator orderByComparator)
4344 throws NoSuchMessageException, SystemException {
4345 List<MBMessage> list = findByG_U(groupId, userId, 0, 1,
4346 orderByComparator);
4347
4348 if (list.isEmpty()) {
4349 StringBundler msg = new StringBundler(6);
4350
4351 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4352
4353 msg.append("groupId=");
4354 msg.append(groupId);
4355
4356 msg.append(", userId=");
4357 msg.append(userId);
4358
4359 msg.append(StringPool.CLOSE_CURLY_BRACE);
4360
4361 throw new NoSuchMessageException(msg.toString());
4362 }
4363 else {
4364 return list.get(0);
4365 }
4366 }
4367
4368
4382 public MBMessage findByG_U_Last(long groupId, long userId,
4383 OrderByComparator orderByComparator)
4384 throws NoSuchMessageException, SystemException {
4385 int count = countByG_U(groupId, userId);
4386
4387 List<MBMessage> list = findByG_U(groupId, userId, count - 1, count,
4388 orderByComparator);
4389
4390 if (list.isEmpty()) {
4391 StringBundler msg = new StringBundler(6);
4392
4393 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4394
4395 msg.append("groupId=");
4396 msg.append(groupId);
4397
4398 msg.append(", userId=");
4399 msg.append(userId);
4400
4401 msg.append(StringPool.CLOSE_CURLY_BRACE);
4402
4403 throw new NoSuchMessageException(msg.toString());
4404 }
4405 else {
4406 return list.get(0);
4407 }
4408 }
4409
4410
4425 public MBMessage[] findByG_U_PrevAndNext(long messageId, long groupId,
4426 long userId, OrderByComparator orderByComparator)
4427 throws NoSuchMessageException, SystemException {
4428 MBMessage mbMessage = findByPrimaryKey(messageId);
4429
4430 Session session = null;
4431
4432 try {
4433 session = openSession();
4434
4435 MBMessage[] array = new MBMessageImpl[3];
4436
4437 array[0] = getByG_U_PrevAndNext(session, mbMessage, groupId,
4438 userId, orderByComparator, true);
4439
4440 array[1] = mbMessage;
4441
4442 array[2] = getByG_U_PrevAndNext(session, mbMessage, groupId,
4443 userId, orderByComparator, false);
4444
4445 return array;
4446 }
4447 catch (Exception e) {
4448 throw processException(e);
4449 }
4450 finally {
4451 closeSession(session);
4452 }
4453 }
4454
4455 protected MBMessage getByG_U_PrevAndNext(Session session,
4456 MBMessage mbMessage, long groupId, long userId,
4457 OrderByComparator orderByComparator, boolean previous) {
4458 StringBundler query = null;
4459
4460 if (orderByComparator != null) {
4461 query = new StringBundler(6 +
4462 (orderByComparator.getOrderByFields().length * 6));
4463 }
4464 else {
4465 query = new StringBundler(3);
4466 }
4467
4468 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
4469
4470 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
4471
4472 query.append(_FINDER_COLUMN_G_U_USERID_2);
4473
4474 if (orderByComparator != null) {
4475 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4476
4477 if (orderByConditionFields.length > 0) {
4478 query.append(WHERE_AND);
4479 }
4480
4481 for (int i = 0; i < orderByConditionFields.length; i++) {
4482 query.append(_ORDER_BY_ENTITY_ALIAS);
4483 query.append(orderByConditionFields[i]);
4484
4485 if ((i + 1) < orderByConditionFields.length) {
4486 if (orderByComparator.isAscending() ^ previous) {
4487 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4488 }
4489 else {
4490 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4491 }
4492 }
4493 else {
4494 if (orderByComparator.isAscending() ^ previous) {
4495 query.append(WHERE_GREATER_THAN);
4496 }
4497 else {
4498 query.append(WHERE_LESSER_THAN);
4499 }
4500 }
4501 }
4502
4503 query.append(ORDER_BY_CLAUSE);
4504
4505 String[] orderByFields = orderByComparator.getOrderByFields();
4506
4507 for (int i = 0; i < orderByFields.length; i++) {
4508 query.append(_ORDER_BY_ENTITY_ALIAS);
4509 query.append(orderByFields[i]);
4510
4511 if ((i + 1) < orderByFields.length) {
4512 if (orderByComparator.isAscending() ^ previous) {
4513 query.append(ORDER_BY_ASC_HAS_NEXT);
4514 }
4515 else {
4516 query.append(ORDER_BY_DESC_HAS_NEXT);
4517 }
4518 }
4519 else {
4520 if (orderByComparator.isAscending() ^ previous) {
4521 query.append(ORDER_BY_ASC);
4522 }
4523 else {
4524 query.append(ORDER_BY_DESC);
4525 }
4526 }
4527 }
4528 }
4529
4530 else {
4531 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
4532 }
4533
4534 String sql = query.toString();
4535
4536 Query q = session.createQuery(sql);
4537
4538 q.setFirstResult(0);
4539 q.setMaxResults(2);
4540
4541 QueryPos qPos = QueryPos.getInstance(q);
4542
4543 qPos.add(groupId);
4544
4545 qPos.add(userId);
4546
4547 if (orderByComparator != null) {
4548 Object[] values = orderByComparator.getOrderByConditionValues(mbMessage);
4549
4550 for (Object value : values) {
4551 qPos.add(value);
4552 }
4553 }
4554
4555 List<MBMessage> list = q.list();
4556
4557 if (list.size() == 2) {
4558 return list.get(1);
4559 }
4560 else {
4561 return null;
4562 }
4563 }
4564
4565
4573 public List<MBMessage> filterFindByG_U(long groupId, long userId)
4574 throws SystemException {
4575 return filterFindByG_U(groupId, userId, QueryUtil.ALL_POS,
4576 QueryUtil.ALL_POS, null);
4577 }
4578
4579
4593 public List<MBMessage> filterFindByG_U(long groupId, long userId,
4594 int start, int end) throws SystemException {
4595 return filterFindByG_U(groupId, userId, start, end, null);
4596 }
4597
4598
4613 public List<MBMessage> filterFindByG_U(long groupId, long userId,
4614 int start, int end, OrderByComparator orderByComparator)
4615 throws SystemException {
4616 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4617 return findByG_U(groupId, userId, start, end, orderByComparator);
4618 }
4619
4620 StringBundler query = null;
4621
4622 if (orderByComparator != null) {
4623 query = new StringBundler(4 +
4624 (orderByComparator.getOrderByFields().length * 3));
4625 }
4626 else {
4627 query = new StringBundler(4);
4628 }
4629
4630 if (getDB().isSupportsInlineDistinct()) {
4631 query.append(_FILTER_SQL_SELECT_MBMESSAGE_WHERE);
4632 }
4633 else {
4634 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1);
4635 }
4636
4637 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
4638
4639 query.append(_FINDER_COLUMN_G_U_USERID_2);
4640
4641 if (!getDB().isSupportsInlineDistinct()) {
4642 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_2);
4643 }
4644
4645 if (orderByComparator != null) {
4646 if (getDB().isSupportsInlineDistinct()) {
4647 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4648 orderByComparator);
4649 }
4650 else {
4651 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4652 orderByComparator);
4653 }
4654 }
4655
4656 else {
4657 if (getDB().isSupportsInlineDistinct()) {
4658 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
4659 }
4660 else {
4661 query.append(MBMessageModelImpl.ORDER_BY_SQL);
4662 }
4663 }
4664
4665 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4666 MBMessage.class.getName(),
4667 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4668
4669 Session session = null;
4670
4671 try {
4672 session = openSession();
4673
4674 SQLQuery q = session.createSQLQuery(sql);
4675
4676 if (getDB().isSupportsInlineDistinct()) {
4677 q.addEntity(_FILTER_ENTITY_ALIAS, MBMessageImpl.class);
4678 }
4679 else {
4680 q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class);
4681 }
4682
4683 QueryPos qPos = QueryPos.getInstance(q);
4684
4685 qPos.add(groupId);
4686
4687 qPos.add(userId);
4688
4689 return (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end);
4690 }
4691 catch (Exception e) {
4692 throw processException(e);
4693 }
4694 finally {
4695 closeSession(session);
4696 }
4697 }
4698
4699
4710 public MBMessage[] filterFindByG_U_PrevAndNext(long messageId,
4711 long groupId, long userId, OrderByComparator orderByComparator)
4712 throws NoSuchMessageException, SystemException {
4713 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4714 return findByG_U_PrevAndNext(messageId, groupId, userId,
4715 orderByComparator);
4716 }
4717
4718 MBMessage mbMessage = findByPrimaryKey(messageId);
4719
4720 Session session = null;
4721
4722 try {
4723 session = openSession();
4724
4725 MBMessage[] array = new MBMessageImpl[3];
4726
4727 array[0] = filterGetByG_U_PrevAndNext(session, mbMessage, groupId,
4728 userId, orderByComparator, true);
4729
4730 array[1] = mbMessage;
4731
4732 array[2] = filterGetByG_U_PrevAndNext(session, mbMessage, groupId,
4733 userId, orderByComparator, false);
4734
4735 return array;
4736 }
4737 catch (Exception e) {
4738 throw processException(e);
4739 }
4740 finally {
4741 closeSession(session);
4742 }
4743 }
4744
4745 protected MBMessage filterGetByG_U_PrevAndNext(Session session,
4746 MBMessage mbMessage, long groupId, long userId,
4747 OrderByComparator orderByComparator, boolean previous) {
4748 StringBundler query = null;
4749
4750 if (orderByComparator != null) {
4751 query = new StringBundler(6 +
4752 (orderByComparator.getOrderByFields().length * 6));
4753 }
4754 else {
4755 query = new StringBundler(3);
4756 }
4757
4758 if (getDB().isSupportsInlineDistinct()) {
4759 query.append(_FILTER_SQL_SELECT_MBMESSAGE_WHERE);
4760 }
4761 else {
4762 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1);
4763 }
4764
4765 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
4766
4767 query.append(_FINDER_COLUMN_G_U_USERID_2);
4768
4769 if (!getDB().isSupportsInlineDistinct()) {
4770 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_2);
4771 }
4772
4773 if (orderByComparator != null) {
4774 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4775
4776 if (orderByConditionFields.length > 0) {
4777 query.append(WHERE_AND);
4778 }
4779
4780 for (int i = 0; i < orderByConditionFields.length; i++) {
4781 if (getDB().isSupportsInlineDistinct()) {
4782 query.append(_ORDER_BY_ENTITY_ALIAS);
4783 }
4784 else {
4785 query.append(_ORDER_BY_ENTITY_TABLE);
4786 }
4787
4788 query.append(orderByConditionFields[i]);
4789
4790 if ((i + 1) < orderByConditionFields.length) {
4791 if (orderByComparator.isAscending() ^ previous) {
4792 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4793 }
4794 else {
4795 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4796 }
4797 }
4798 else {
4799 if (orderByComparator.isAscending() ^ previous) {
4800 query.append(WHERE_GREATER_THAN);
4801 }
4802 else {
4803 query.append(WHERE_LESSER_THAN);
4804 }
4805 }
4806 }
4807
4808 query.append(ORDER_BY_CLAUSE);
4809
4810 String[] orderByFields = orderByComparator.getOrderByFields();
4811
4812 for (int i = 0; i < orderByFields.length; i++) {
4813 if (getDB().isSupportsInlineDistinct()) {
4814 query.append(_ORDER_BY_ENTITY_ALIAS);
4815 }
4816 else {
4817 query.append(_ORDER_BY_ENTITY_TABLE);
4818 }
4819
4820 query.append(orderByFields[i]);
4821
4822 if ((i + 1) < orderByFields.length) {
4823 if (orderByComparator.isAscending() ^ previous) {
4824 query.append(ORDER_BY_ASC_HAS_NEXT);
4825 }
4826 else {
4827 query.append(ORDER_BY_DESC_HAS_NEXT);
4828 }
4829 }
4830 else {
4831 if (orderByComparator.isAscending() ^ previous) {
4832 query.append(ORDER_BY_ASC);
4833 }
4834 else {
4835 query.append(ORDER_BY_DESC);
4836 }
4837 }
4838 }
4839 }
4840
4841 else {
4842 if (getDB().isSupportsInlineDistinct()) {
4843 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
4844 }
4845 else {
4846 query.append(MBMessageModelImpl.ORDER_BY_SQL);
4847 }
4848 }
4849
4850 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4851 MBMessage.class.getName(),
4852 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4853
4854 SQLQuery q = session.createSQLQuery(sql);
4855
4856 q.setFirstResult(0);
4857 q.setMaxResults(2);
4858
4859 if (getDB().isSupportsInlineDistinct()) {
4860 q.addEntity(_FILTER_ENTITY_ALIAS, MBMessageImpl.class);
4861 }
4862 else {
4863 q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class);
4864 }
4865
4866 QueryPos qPos = QueryPos.getInstance(q);
4867
4868 qPos.add(groupId);
4869
4870 qPos.add(userId);
4871
4872 if (orderByComparator != null) {
4873 Object[] values = orderByComparator.getOrderByConditionValues(mbMessage);
4874
4875 for (Object value : values) {
4876 qPos.add(value);
4877 }
4878 }
4879
4880 List<MBMessage> list = q.list();
4881
4882 if (list.size() == 2) {
4883 return list.get(1);
4884 }
4885 else {
4886 return null;
4887 }
4888 }
4889
4890
4898 public List<MBMessage> findByG_C(long groupId, long categoryId)
4899 throws SystemException {
4900 return findByG_C(groupId, categoryId, QueryUtil.ALL_POS,
4901 QueryUtil.ALL_POS, null);
4902 }
4903
4904
4918 public List<MBMessage> findByG_C(long groupId, long categoryId, int start,
4919 int end) throws SystemException {
4920 return findByG_C(groupId, categoryId, start, end, null);
4921 }
4922
4923
4938 public List<MBMessage> findByG_C(long groupId, long categoryId, int start,
4939 int end, OrderByComparator orderByComparator) throws SystemException {
4940 FinderPath finderPath = null;
4941 Object[] finderArgs = null;
4942
4943 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4944 (orderByComparator == null)) {
4945 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C;
4946 finderArgs = new Object[] { groupId, categoryId };
4947 }
4948 else {
4949 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C;
4950 finderArgs = new Object[] {
4951 groupId, categoryId,
4952
4953 start, end, orderByComparator
4954 };
4955 }
4956
4957 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(finderPath,
4958 finderArgs, this);
4959
4960 if (list == null) {
4961 StringBundler query = null;
4962
4963 if (orderByComparator != null) {
4964 query = new StringBundler(4 +
4965 (orderByComparator.getOrderByFields().length * 3));
4966 }
4967 else {
4968 query = new StringBundler(4);
4969 }
4970
4971 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
4972
4973 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
4974
4975 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
4976
4977 if (orderByComparator != null) {
4978 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4979 orderByComparator);
4980 }
4981
4982 else {
4983 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
4984 }
4985
4986 String sql = query.toString();
4987
4988 Session session = null;
4989
4990 try {
4991 session = openSession();
4992
4993 Query q = session.createQuery(sql);
4994
4995 QueryPos qPos = QueryPos.getInstance(q);
4996
4997 qPos.add(groupId);
4998
4999 qPos.add(categoryId);
5000
5001 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
5002 end);
5003 }
5004 catch (Exception e) {
5005 throw processException(e);
5006 }
5007 finally {
5008 if (list == null) {
5009 FinderCacheUtil.removeResult(finderPath, finderArgs);
5010 }
5011 else {
5012 cacheResult(list);
5013
5014 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5015 }
5016
5017 closeSession(session);
5018 }
5019 }
5020
5021 return list;
5022 }
5023
5024
5038 public MBMessage findByG_C_First(long groupId, long categoryId,
5039 OrderByComparator orderByComparator)
5040 throws NoSuchMessageException, SystemException {
5041 List<MBMessage> list = findByG_C(groupId, categoryId, 0, 1,
5042 orderByComparator);
5043
5044 if (list.isEmpty()) {
5045 StringBundler msg = new StringBundler(6);
5046
5047 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5048
5049 msg.append("groupId=");
5050 msg.append(groupId);
5051
5052 msg.append(", categoryId=");
5053 msg.append(categoryId);
5054
5055 msg.append(StringPool.CLOSE_CURLY_BRACE);
5056
5057 throw new NoSuchMessageException(msg.toString());
5058 }
5059 else {
5060 return list.get(0);
5061 }
5062 }
5063
5064
5078 public MBMessage findByG_C_Last(long groupId, long categoryId,
5079 OrderByComparator orderByComparator)
5080 throws NoSuchMessageException, SystemException {
5081 int count = countByG_C(groupId, categoryId);
5082
5083 List<MBMessage> list = findByG_C(groupId, categoryId, count - 1, count,
5084 orderByComparator);
5085
5086 if (list.isEmpty()) {
5087 StringBundler msg = new StringBundler(6);
5088
5089 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5090
5091 msg.append("groupId=");
5092 msg.append(groupId);
5093
5094 msg.append(", categoryId=");
5095 msg.append(categoryId);
5096
5097 msg.append(StringPool.CLOSE_CURLY_BRACE);
5098
5099 throw new NoSuchMessageException(msg.toString());
5100 }
5101 else {
5102 return list.get(0);
5103 }
5104 }
5105
5106
5121 public MBMessage[] findByG_C_PrevAndNext(long messageId, long groupId,
5122 long categoryId, OrderByComparator orderByComparator)
5123 throws NoSuchMessageException, SystemException {
5124 MBMessage mbMessage = findByPrimaryKey(messageId);
5125
5126 Session session = null;
5127
5128 try {
5129 session = openSession();
5130
5131 MBMessage[] array = new MBMessageImpl[3];
5132
5133 array[0] = getByG_C_PrevAndNext(session, mbMessage, groupId,
5134 categoryId, orderByComparator, true);
5135
5136 array[1] = mbMessage;
5137
5138 array[2] = getByG_C_PrevAndNext(session, mbMessage, groupId,
5139 categoryId, orderByComparator, false);
5140
5141 return array;
5142 }
5143 catch (Exception e) {
5144 throw processException(e);
5145 }
5146 finally {
5147 closeSession(session);
5148 }
5149 }
5150
5151 protected MBMessage getByG_C_PrevAndNext(Session session,
5152 MBMessage mbMessage, long groupId, long categoryId,
5153 OrderByComparator orderByComparator, boolean previous) {
5154 StringBundler query = null;
5155
5156 if (orderByComparator != null) {
5157 query = new StringBundler(6 +
5158 (orderByComparator.getOrderByFields().length * 6));
5159 }
5160 else {
5161 query = new StringBundler(3);
5162 }
5163
5164 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
5165
5166 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
5167
5168 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
5169
5170 if (orderByComparator != null) {
5171 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5172
5173 if (orderByConditionFields.length > 0) {
5174 query.append(WHERE_AND);
5175 }
5176
5177 for (int i = 0; i < orderByConditionFields.length; i++) {
5178 query.append(_ORDER_BY_ENTITY_ALIAS);
5179 query.append(orderByConditionFields[i]);
5180
5181 if ((i + 1) < orderByConditionFields.length) {
5182 if (orderByComparator.isAscending() ^ previous) {
5183 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5184 }
5185 else {
5186 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5187 }
5188 }
5189 else {
5190 if (orderByComparator.isAscending() ^ previous) {
5191 query.append(WHERE_GREATER_THAN);
5192 }
5193 else {
5194 query.append(WHERE_LESSER_THAN);
5195 }
5196 }
5197 }
5198
5199 query.append(ORDER_BY_CLAUSE);
5200
5201 String[] orderByFields = orderByComparator.getOrderByFields();
5202
5203 for (int i = 0; i < orderByFields.length; i++) {
5204 query.append(_ORDER_BY_ENTITY_ALIAS);
5205 query.append(orderByFields[i]);
5206
5207 if ((i + 1) < orderByFields.length) {
5208 if (orderByComparator.isAscending() ^ previous) {
5209 query.append(ORDER_BY_ASC_HAS_NEXT);
5210 }
5211 else {
5212 query.append(ORDER_BY_DESC_HAS_NEXT);
5213 }
5214 }
5215 else {
5216 if (orderByComparator.isAscending() ^ previous) {
5217 query.append(ORDER_BY_ASC);
5218 }
5219 else {
5220 query.append(ORDER_BY_DESC);
5221 }
5222 }
5223 }
5224 }
5225
5226 else {
5227 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
5228 }
5229
5230 String sql = query.toString();
5231
5232 Query q = session.createQuery(sql);
5233
5234 q.setFirstResult(0);
5235 q.setMaxResults(2);
5236
5237 QueryPos qPos = QueryPos.getInstance(q);
5238
5239 qPos.add(groupId);
5240
5241 qPos.add(categoryId);
5242
5243 if (orderByComparator != null) {
5244 Object[] values = orderByComparator.getOrderByConditionValues(mbMessage);
5245
5246 for (Object value : values) {
5247 qPos.add(value);
5248 }
5249 }
5250
5251 List<MBMessage> list = q.list();
5252
5253 if (list.size() == 2) {
5254 return list.get(1);
5255 }
5256 else {
5257 return null;
5258 }
5259 }
5260
5261
5269 public List<MBMessage> filterFindByG_C(long groupId, long categoryId)
5270 throws SystemException {
5271 return filterFindByG_C(groupId, categoryId, QueryUtil.ALL_POS,
5272 QueryUtil.ALL_POS, null);
5273 }
5274
5275
5289 public List<MBMessage> filterFindByG_C(long groupId, long categoryId,
5290 int start, int end) throws SystemException {
5291 return filterFindByG_C(groupId, categoryId, start, end, null);
5292 }
5293
5294
5309 public List<MBMessage> filterFindByG_C(long groupId, long categoryId,
5310 int start, int end, OrderByComparator orderByComparator)
5311 throws SystemException {
5312 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5313 return findByG_C(groupId, categoryId, start, end, orderByComparator);
5314 }
5315
5316 StringBundler query = null;
5317
5318 if (orderByComparator != null) {
5319 query = new StringBundler(4 +
5320 (orderByComparator.getOrderByFields().length * 3));
5321 }
5322 else {
5323 query = new StringBundler(4);
5324 }
5325
5326 if (getDB().isSupportsInlineDistinct()) {
5327 query.append(_FILTER_SQL_SELECT_MBMESSAGE_WHERE);
5328 }
5329 else {
5330 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1);
5331 }
5332
5333 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
5334
5335 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
5336
5337 if (!getDB().isSupportsInlineDistinct()) {
5338 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_2);
5339 }
5340
5341 if (orderByComparator != null) {
5342 if (getDB().isSupportsInlineDistinct()) {
5343 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5344 orderByComparator);
5345 }
5346 else {
5347 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
5348 orderByComparator);
5349 }
5350 }
5351
5352 else {
5353 if (getDB().isSupportsInlineDistinct()) {
5354 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
5355 }
5356 else {
5357 query.append(MBMessageModelImpl.ORDER_BY_SQL);
5358 }
5359 }
5360
5361 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5362 MBMessage.class.getName(),
5363 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5364
5365 Session session = null;
5366
5367 try {
5368 session = openSession();
5369
5370 SQLQuery q = session.createSQLQuery(sql);
5371
5372 if (getDB().isSupportsInlineDistinct()) {
5373 q.addEntity(_FILTER_ENTITY_ALIAS, MBMessageImpl.class);
5374 }
5375 else {
5376 q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class);
5377 }
5378
5379 QueryPos qPos = QueryPos.getInstance(q);
5380
5381 qPos.add(groupId);
5382
5383 qPos.add(categoryId);
5384
5385 return (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end);
5386 }
5387 catch (Exception e) {
5388 throw processException(e);
5389 }
5390 finally {
5391 closeSession(session);
5392 }
5393 }
5394
5395
5406 public MBMessage[] filterFindByG_C_PrevAndNext(long messageId,
5407 long groupId, long categoryId, OrderByComparator orderByComparator)
5408 throws NoSuchMessageException, SystemException {
5409 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5410 return findByG_C_PrevAndNext(messageId, groupId, categoryId,
5411 orderByComparator);
5412 }
5413
5414 MBMessage mbMessage = findByPrimaryKey(messageId);
5415
5416 Session session = null;
5417
5418 try {
5419 session = openSession();
5420
5421 MBMessage[] array = new MBMessageImpl[3];
5422
5423 array[0] = filterGetByG_C_PrevAndNext(session, mbMessage, groupId,
5424 categoryId, orderByComparator, true);
5425
5426 array[1] = mbMessage;
5427
5428 array[2] = filterGetByG_C_PrevAndNext(session, mbMessage, groupId,
5429 categoryId, orderByComparator, false);
5430
5431 return array;
5432 }
5433 catch (Exception e) {
5434 throw processException(e);
5435 }
5436 finally {
5437 closeSession(session);
5438 }
5439 }
5440
5441 protected MBMessage filterGetByG_C_PrevAndNext(Session session,
5442 MBMessage mbMessage, long groupId, long categoryId,
5443 OrderByComparator orderByComparator, boolean previous) {
5444 StringBundler query = null;
5445
5446 if (orderByComparator != null) {
5447 query = new StringBundler(6 +
5448 (orderByComparator.getOrderByFields().length * 6));
5449 }
5450 else {
5451 query = new StringBundler(3);
5452 }
5453
5454 if (getDB().isSupportsInlineDistinct()) {
5455 query.append(_FILTER_SQL_SELECT_MBMESSAGE_WHERE);
5456 }
5457 else {
5458 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1);
5459 }
5460
5461 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
5462
5463 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
5464
5465 if (!getDB().isSupportsInlineDistinct()) {
5466 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_2);
5467 }
5468
5469 if (orderByComparator != null) {
5470 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5471
5472 if (orderByConditionFields.length > 0) {
5473 query.append(WHERE_AND);
5474 }
5475
5476 for (int i = 0; i < orderByConditionFields.length; i++) {
5477 if (getDB().isSupportsInlineDistinct()) {
5478 query.append(_ORDER_BY_ENTITY_ALIAS);
5479 }
5480 else {
5481 query.append(_ORDER_BY_ENTITY_TABLE);
5482 }
5483
5484 query.append(orderByConditionFields[i]);
5485
5486 if ((i + 1) < orderByConditionFields.length) {
5487 if (orderByComparator.isAscending() ^ previous) {
5488 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5489 }
5490 else {
5491 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5492 }
5493 }
5494 else {
5495 if (orderByComparator.isAscending() ^ previous) {
5496 query.append(WHERE_GREATER_THAN);
5497 }
5498 else {
5499 query.append(WHERE_LESSER_THAN);
5500 }
5501 }
5502 }
5503
5504 query.append(ORDER_BY_CLAUSE);
5505
5506 String[] orderByFields = orderByComparator.getOrderByFields();
5507
5508 for (int i = 0; i < orderByFields.length; i++) {
5509 if (getDB().isSupportsInlineDistinct()) {
5510 query.append(_ORDER_BY_ENTITY_ALIAS);
5511 }
5512 else {
5513 query.append(_ORDER_BY_ENTITY_TABLE);
5514 }
5515
5516 query.append(orderByFields[i]);
5517
5518 if ((i + 1) < orderByFields.length) {
5519 if (orderByComparator.isAscending() ^ previous) {
5520 query.append(ORDER_BY_ASC_HAS_NEXT);
5521 }
5522 else {
5523 query.append(ORDER_BY_DESC_HAS_NEXT);
5524 }
5525 }
5526 else {
5527 if (orderByComparator.isAscending() ^ previous) {
5528 query.append(ORDER_BY_ASC);
5529 }
5530 else {
5531 query.append(ORDER_BY_DESC);
5532 }
5533 }
5534 }
5535 }
5536
5537 else {
5538 if (getDB().isSupportsInlineDistinct()) {
5539 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
5540 }
5541 else {
5542 query.append(MBMessageModelImpl.ORDER_BY_SQL);
5543 }
5544 }
5545
5546 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5547 MBMessage.class.getName(),
5548 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5549
5550 SQLQuery q = session.createSQLQuery(sql);
5551
5552 q.setFirstResult(0);
5553 q.setMaxResults(2);
5554
5555 if (getDB().isSupportsInlineDistinct()) {
5556 q.addEntity(_FILTER_ENTITY_ALIAS, MBMessageImpl.class);
5557 }
5558 else {
5559 q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class);
5560 }
5561
5562 QueryPos qPos = QueryPos.getInstance(q);
5563
5564 qPos.add(groupId);
5565
5566 qPos.add(categoryId);
5567
5568 if (orderByComparator != null) {
5569 Object[] values = orderByComparator.getOrderByConditionValues(mbMessage);
5570
5571 for (Object value : values) {
5572 qPos.add(value);
5573 }
5574 }
5575
5576 List<MBMessage> list = q.list();
5577
5578 if (list.size() == 2) {
5579 return list.get(1);
5580 }
5581 else {
5582 return null;
5583 }
5584 }
5585
5586
5594 public List<MBMessage> findByG_S(long groupId, int status)
5595 throws SystemException {
5596 return findByG_S(groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
5597 null);
5598 }
5599
5600
5614 public List<MBMessage> findByG_S(long groupId, int status, int start,
5615 int end) throws SystemException {
5616 return findByG_S(groupId, status, start, end, null);
5617 }
5618
5619
5634 public List<MBMessage> findByG_S(long groupId, int status, int start,
5635 int end, OrderByComparator orderByComparator) throws SystemException {
5636 FinderPath finderPath = null;
5637 Object[] finderArgs = null;
5638
5639 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5640 (orderByComparator == null)) {
5641 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
5642 finderArgs = new Object[] { groupId, status };
5643 }
5644 else {
5645 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
5646 finderArgs = new Object[] {
5647 groupId, status,
5648
5649 start, end, orderByComparator
5650 };
5651 }
5652
5653 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(finderPath,
5654 finderArgs, this);
5655
5656 if (list == null) {
5657 StringBundler query = null;
5658
5659 if (orderByComparator != null) {
5660 query = new StringBundler(4 +
5661 (orderByComparator.getOrderByFields().length * 3));
5662 }
5663 else {
5664 query = new StringBundler(4);
5665 }
5666
5667 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
5668
5669 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
5670
5671 query.append(_FINDER_COLUMN_G_S_STATUS_2);
5672
5673 if (orderByComparator != null) {
5674 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5675 orderByComparator);
5676 }
5677
5678 else {
5679 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
5680 }
5681
5682 String sql = query.toString();
5683
5684 Session session = null;
5685
5686 try {
5687 session = openSession();
5688
5689 Query q = session.createQuery(sql);
5690
5691 QueryPos qPos = QueryPos.getInstance(q);
5692
5693 qPos.add(groupId);
5694
5695 qPos.add(status);
5696
5697 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
5698 end);
5699 }
5700 catch (Exception e) {
5701 throw processException(e);
5702 }
5703 finally {
5704 if (list == null) {
5705 FinderCacheUtil.removeResult(finderPath, finderArgs);
5706 }
5707 else {
5708 cacheResult(list);
5709
5710 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5711 }
5712
5713 closeSession(session);
5714 }
5715 }
5716
5717 return list;
5718 }
5719
5720
5734 public MBMessage findByG_S_First(long groupId, int status,
5735 OrderByComparator orderByComparator)
5736 throws NoSuchMessageException, SystemException {
5737 List<MBMessage> list = findByG_S(groupId, status, 0, 1,
5738 orderByComparator);
5739
5740 if (list.isEmpty()) {
5741 StringBundler msg = new StringBundler(6);
5742
5743 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5744
5745 msg.append("groupId=");
5746 msg.append(groupId);
5747
5748 msg.append(", status=");
5749 msg.append(status);
5750
5751 msg.append(StringPool.CLOSE_CURLY_BRACE);
5752
5753 throw new NoSuchMessageException(msg.toString());
5754 }
5755 else {
5756 return list.get(0);
5757 }
5758 }
5759
5760
5774 public MBMessage findByG_S_Last(long groupId, int status,
5775 OrderByComparator orderByComparator)
5776 throws NoSuchMessageException, SystemException {
5777 int count = countByG_S(groupId, status);
5778
5779 List<MBMessage> list = findByG_S(groupId, status, count - 1, count,
5780 orderByComparator);
5781
5782 if (list.isEmpty()) {
5783 StringBundler msg = new StringBundler(6);
5784
5785 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5786
5787 msg.append("groupId=");
5788 msg.append(groupId);
5789
5790 msg.append(", status=");
5791 msg.append(status);
5792
5793 msg.append(StringPool.CLOSE_CURLY_BRACE);
5794
5795 throw new NoSuchMessageException(msg.toString());
5796 }
5797 else {
5798 return list.get(0);
5799 }
5800 }
5801
5802
5817 public MBMessage[] findByG_S_PrevAndNext(long messageId, long groupId,
5818 int status, OrderByComparator orderByComparator)
5819 throws NoSuchMessageException, SystemException {
5820 MBMessage mbMessage = findByPrimaryKey(messageId);
5821
5822 Session session = null;
5823
5824 try {
5825 session = openSession();
5826
5827 MBMessage[] array = new MBMessageImpl[3];
5828
5829 array[0] = getByG_S_PrevAndNext(session, mbMessage, groupId,
5830 status, orderByComparator, true);
5831
5832 array[1] = mbMessage;
5833
5834 array[2] = getByG_S_PrevAndNext(session, mbMessage, groupId,
5835 status, orderByComparator, false);
5836
5837 return array;
5838 }
5839 catch (Exception e) {
5840 throw processException(e);
5841 }
5842 finally {
5843 closeSession(session);
5844 }
5845 }
5846
5847 protected MBMessage getByG_S_PrevAndNext(Session session,
5848 MBMessage mbMessage, long groupId, int status,
5849 OrderByComparator orderByComparator, boolean previous) {
5850 StringBundler query = null;
5851
5852 if (orderByComparator != null) {
5853 query = new StringBundler(6 +
5854 (orderByComparator.getOrderByFields().length * 6));
5855 }
5856 else {
5857 query = new StringBundler(3);
5858 }
5859
5860 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
5861
5862 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
5863
5864 query.append(_FINDER_COLUMN_G_S_STATUS_2);
5865
5866 if (orderByComparator != null) {
5867 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5868
5869 if (orderByConditionFields.length > 0) {
5870 query.append(WHERE_AND);
5871 }
5872
5873 for (int i = 0; i < orderByConditionFields.length; i++) {
5874 query.append(_ORDER_BY_ENTITY_ALIAS);
5875 query.append(orderByConditionFields[i]);
5876
5877 if ((i + 1) < orderByConditionFields.length) {
5878 if (orderByComparator.isAscending() ^ previous) {
5879 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5880 }
5881 else {
5882 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5883 }
5884 }
5885 else {
5886 if (orderByComparator.isAscending() ^ previous) {
5887 query.append(WHERE_GREATER_THAN);
5888 }
5889 else {
5890 query.append(WHERE_LESSER_THAN);
5891 }
5892 }
5893 }
5894
5895 query.append(ORDER_BY_CLAUSE);
5896
5897 String[] orderByFields = orderByComparator.getOrderByFields();
5898
5899 for (int i = 0; i < orderByFields.length; i++) {
5900 query.append(_ORDER_BY_ENTITY_ALIAS);
5901 query.append(orderByFields[i]);
5902
5903 if ((i + 1) < orderByFields.length) {
5904 if (orderByComparator.isAscending() ^ previous) {
5905 query.append(ORDER_BY_ASC_HAS_NEXT);
5906 }
5907 else {
5908 query.append(ORDER_BY_DESC_HAS_NEXT);
5909 }
5910 }
5911 else {
5912 if (orderByComparator.isAscending() ^ previous) {
5913 query.append(ORDER_BY_ASC);
5914 }
5915 else {
5916 query.append(ORDER_BY_DESC);
5917 }
5918 }
5919 }
5920 }
5921
5922 else {
5923 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
5924 }
5925
5926 String sql = query.toString();
5927
5928 Query q = session.createQuery(sql);
5929
5930 q.setFirstResult(0);
5931 q.setMaxResults(2);
5932
5933 QueryPos qPos = QueryPos.getInstance(q);
5934
5935 qPos.add(groupId);
5936
5937 qPos.add(status);
5938
5939 if (orderByComparator != null) {
5940 Object[] values = orderByComparator.getOrderByConditionValues(mbMessage);
5941
5942 for (Object value : values) {
5943 qPos.add(value);
5944 }
5945 }
5946
5947 List<MBMessage> list = q.list();
5948
5949 if (list.size() == 2) {
5950 return list.get(1);
5951 }
5952 else {
5953 return null;
5954 }
5955 }
5956
5957
5965 public List<MBMessage> filterFindByG_S(long groupId, int status)
5966 throws SystemException {
5967 return filterFindByG_S(groupId, status, QueryUtil.ALL_POS,
5968 QueryUtil.ALL_POS, null);
5969 }
5970
5971
5985 public List<MBMessage> filterFindByG_S(long groupId, int status, int start,
5986 int end) throws SystemException {
5987 return filterFindByG_S(groupId, status, start, end, null);
5988 }
5989
5990
6005 public List<MBMessage> filterFindByG_S(long groupId, int status, int start,
6006 int end, OrderByComparator orderByComparator) throws SystemException {
6007 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6008 return findByG_S(groupId, status, start, end, orderByComparator);
6009 }
6010
6011 StringBundler query = null;
6012
6013 if (orderByComparator != null) {
6014 query = new StringBundler(4 +
6015 (orderByComparator.getOrderByFields().length * 3));
6016 }
6017 else {
6018 query = new StringBundler(4);
6019 }
6020
6021 if (getDB().isSupportsInlineDistinct()) {
6022 query.append(_FILTER_SQL_SELECT_MBMESSAGE_WHERE);
6023 }
6024 else {
6025 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1);
6026 }
6027
6028 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
6029
6030 query.append(_FINDER_COLUMN_G_S_STATUS_2);
6031
6032 if (!getDB().isSupportsInlineDistinct()) {
6033 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_2);
6034 }
6035
6036 if (orderByComparator != null) {
6037 if (getDB().isSupportsInlineDistinct()) {
6038 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6039 orderByComparator);
6040 }
6041 else {
6042 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6043 orderByComparator);
6044 }
6045 }
6046
6047 else {
6048 if (getDB().isSupportsInlineDistinct()) {
6049 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
6050 }
6051 else {
6052 query.append(MBMessageModelImpl.ORDER_BY_SQL);
6053 }
6054 }
6055
6056 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6057 MBMessage.class.getName(),
6058 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6059
6060 Session session = null;
6061
6062 try {
6063 session = openSession();
6064
6065 SQLQuery q = session.createSQLQuery(sql);
6066
6067 if (getDB().isSupportsInlineDistinct()) {
6068 q.addEntity(_FILTER_ENTITY_ALIAS, MBMessageImpl.class);
6069 }
6070 else {
6071 q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class);
6072 }
6073
6074 QueryPos qPos = QueryPos.getInstance(q);
6075
6076 qPos.add(groupId);
6077
6078 qPos.add(status);
6079
6080 return (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end);
6081 }
6082 catch (Exception e) {
6083 throw processException(e);
6084 }
6085 finally {
6086 closeSession(session);
6087 }
6088 }
6089
6090
6101 public MBMessage[] filterFindByG_S_PrevAndNext(long messageId,
6102 long groupId, int status, OrderByComparator orderByComparator)
6103 throws NoSuchMessageException, SystemException {
6104 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6105 return findByG_S_PrevAndNext(messageId, groupId, status,
6106 orderByComparator);
6107 }
6108
6109 MBMessage mbMessage = findByPrimaryKey(messageId);
6110
6111 Session session = null;
6112
6113 try {
6114 session = openSession();
6115
6116 MBMessage[] array = new MBMessageImpl[3];
6117
6118 array[0] = filterGetByG_S_PrevAndNext(session, mbMessage, groupId,
6119 status, orderByComparator, true);
6120
6121 array[1] = mbMessage;
6122
6123 array[2] = filterGetByG_S_PrevAndNext(session, mbMessage, groupId,
6124 status, orderByComparator, false);
6125
6126 return array;
6127 }
6128 catch (Exception e) {
6129 throw processException(e);
6130 }
6131 finally {
6132 closeSession(session);
6133 }
6134 }
6135
6136 protected MBMessage filterGetByG_S_PrevAndNext(Session session,
6137 MBMessage mbMessage, long groupId, int status,
6138 OrderByComparator orderByComparator, boolean previous) {
6139 StringBundler query = null;
6140
6141 if (orderByComparator != null) {
6142 query = new StringBundler(6 +
6143 (orderByComparator.getOrderByFields().length * 6));
6144 }
6145 else {
6146 query = new StringBundler(3);
6147 }
6148
6149 if (getDB().isSupportsInlineDistinct()) {
6150 query.append(_FILTER_SQL_SELECT_MBMESSAGE_WHERE);
6151 }
6152 else {
6153 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1);
6154 }
6155
6156 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
6157
6158 query.append(_FINDER_COLUMN_G_S_STATUS_2);
6159
6160 if (!getDB().isSupportsInlineDistinct()) {
6161 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_2);
6162 }
6163
6164 if (orderByComparator != null) {
6165 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6166
6167 if (orderByConditionFields.length > 0) {
6168 query.append(WHERE_AND);
6169 }
6170
6171 for (int i = 0; i < orderByConditionFields.length; i++) {
6172 if (getDB().isSupportsInlineDistinct()) {
6173 query.append(_ORDER_BY_ENTITY_ALIAS);
6174 }
6175 else {
6176 query.append(_ORDER_BY_ENTITY_TABLE);
6177 }
6178
6179 query.append(orderByConditionFields[i]);
6180
6181 if ((i + 1) < orderByConditionFields.length) {
6182 if (orderByComparator.isAscending() ^ previous) {
6183 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6184 }
6185 else {
6186 query.append(WHERE_LESSER_THAN_HAS_NEXT);
6187 }
6188 }
6189 else {
6190 if (orderByComparator.isAscending() ^ previous) {
6191 query.append(WHERE_GREATER_THAN);
6192 }
6193 else {
6194 query.append(WHERE_LESSER_THAN);
6195 }
6196 }
6197 }
6198
6199 query.append(ORDER_BY_CLAUSE);
6200
6201 String[] orderByFields = orderByComparator.getOrderByFields();
6202
6203 for (int i = 0; i < orderByFields.length; i++) {
6204 if (getDB().isSupportsInlineDistinct()) {
6205 query.append(_ORDER_BY_ENTITY_ALIAS);
6206 }
6207 else {
6208 query.append(_ORDER_BY_ENTITY_TABLE);
6209 }
6210
6211 query.append(orderByFields[i]);
6212
6213 if ((i + 1) < orderByFields.length) {
6214 if (orderByComparator.isAscending() ^ previous) {
6215 query.append(ORDER_BY_ASC_HAS_NEXT);
6216 }
6217 else {
6218 query.append(ORDER_BY_DESC_HAS_NEXT);
6219 }
6220 }
6221 else {
6222 if (orderByComparator.isAscending() ^ previous) {
6223 query.append(ORDER_BY_ASC);
6224 }
6225 else {
6226 query.append(ORDER_BY_DESC);
6227 }
6228 }
6229 }
6230 }
6231
6232 else {
6233 if (getDB().isSupportsInlineDistinct()) {
6234 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
6235 }
6236 else {
6237 query.append(MBMessageModelImpl.ORDER_BY_SQL);
6238 }
6239 }
6240
6241 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6242 MBMessage.class.getName(),
6243 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6244
6245 SQLQuery q = session.createSQLQuery(sql);
6246
6247 q.setFirstResult(0);
6248 q.setMaxResults(2);
6249
6250 if (getDB().isSupportsInlineDistinct()) {
6251 q.addEntity(_FILTER_ENTITY_ALIAS, MBMessageImpl.class);
6252 }
6253 else {
6254 q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class);
6255 }
6256
6257 QueryPos qPos = QueryPos.getInstance(q);
6258
6259 qPos.add(groupId);
6260
6261 qPos.add(status);
6262
6263 if (orderByComparator != null) {
6264 Object[] values = orderByComparator.getOrderByConditionValues(mbMessage);
6265
6266 for (Object value : values) {
6267 qPos.add(value);
6268 }
6269 }
6270
6271 List<MBMessage> list = q.list();
6272
6273 if (list.size() == 2) {
6274 return list.get(1);
6275 }
6276 else {
6277 return null;
6278 }
6279 }
6280
6281
6289 public List<MBMessage> findByC_S(long companyId, int status)
6290 throws SystemException {
6291 return findByC_S(companyId, status, QueryUtil.ALL_POS,
6292 QueryUtil.ALL_POS, null);
6293 }
6294
6295
6309 public List<MBMessage> findByC_S(long companyId, int status, int start,
6310 int end) throws SystemException {
6311 return findByC_S(companyId, status, start, end, null);
6312 }
6313
6314
6329 public List<MBMessage> findByC_S(long companyId, int status, int start,
6330 int end, OrderByComparator orderByComparator) throws SystemException {
6331 FinderPath finderPath = null;
6332 Object[] finderArgs = null;
6333
6334 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6335 (orderByComparator == null)) {
6336 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S;
6337 finderArgs = new Object[] { companyId, status };
6338 }
6339 else {
6340 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S;
6341 finderArgs = new Object[] {
6342 companyId, status,
6343
6344 start, end, orderByComparator
6345 };
6346 }
6347
6348 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(finderPath,
6349 finderArgs, this);
6350
6351 if (list == null) {
6352 StringBundler query = null;
6353
6354 if (orderByComparator != null) {
6355 query = new StringBundler(4 +
6356 (orderByComparator.getOrderByFields().length * 3));
6357 }
6358 else {
6359 query = new StringBundler(4);
6360 }
6361
6362 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
6363
6364 query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
6365
6366 query.append(_FINDER_COLUMN_C_S_STATUS_2);
6367
6368 if (orderByComparator != null) {
6369 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6370 orderByComparator);
6371 }
6372
6373 else {
6374 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
6375 }
6376
6377 String sql = query.toString();
6378
6379 Session session = null;
6380
6381 try {
6382 session = openSession();
6383
6384 Query q = session.createQuery(sql);
6385
6386 QueryPos qPos = QueryPos.getInstance(q);
6387
6388 qPos.add(companyId);
6389
6390 qPos.add(status);
6391
6392 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
6393 end);
6394 }
6395 catch (Exception e) {
6396 throw processException(e);
6397 }
6398 finally {
6399 if (list == null) {
6400 FinderCacheUtil.removeResult(finderPath, finderArgs);
6401 }
6402 else {
6403 cacheResult(list);
6404
6405 FinderCacheUtil.putResult(finderPath, finderArgs, list);
6406 }
6407
6408 closeSession(session);
6409 }
6410 }
6411
6412 return list;
6413 }
6414
6415
6429 public MBMessage findByC_S_First(long companyId, int status,
6430 OrderByComparator orderByComparator)
6431 throws NoSuchMessageException, SystemException {
6432 List<MBMessage> list = findByC_S(companyId, status, 0, 1,
6433 orderByComparator);
6434
6435 if (list.isEmpty()) {
6436 StringBundler msg = new StringBundler(6);
6437
6438 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6439
6440 msg.append("companyId=");
6441 msg.append(companyId);
6442
6443 msg.append(", status=");
6444 msg.append(status);
6445
6446 msg.append(StringPool.CLOSE_CURLY_BRACE);
6447
6448 throw new NoSuchMessageException(msg.toString());
6449 }
6450 else {
6451 return list.get(0);
6452 }
6453 }
6454
6455
6469 public MBMessage findByC_S_Last(long companyId, int status,
6470 OrderByComparator orderByComparator)
6471 throws NoSuchMessageException, SystemException {
6472 int count = countByC_S(companyId, status);
6473
6474 List<MBMessage> list = findByC_S(companyId, status, count - 1, count,
6475 orderByComparator);
6476
6477 if (list.isEmpty()) {
6478 StringBundler msg = new StringBundler(6);
6479
6480 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6481
6482 msg.append("companyId=");
6483 msg.append(companyId);
6484
6485 msg.append(", status=");
6486 msg.append(status);
6487
6488 msg.append(StringPool.CLOSE_CURLY_BRACE);
6489
6490 throw new NoSuchMessageException(msg.toString());
6491 }
6492 else {
6493 return list.get(0);
6494 }
6495 }
6496
6497
6512 public MBMessage[] findByC_S_PrevAndNext(long messageId, long companyId,
6513 int status, OrderByComparator orderByComparator)
6514 throws NoSuchMessageException, SystemException {
6515 MBMessage mbMessage = findByPrimaryKey(messageId);
6516
6517 Session session = null;
6518
6519 try {
6520 session = openSession();
6521
6522 MBMessage[] array = new MBMessageImpl[3];
6523
6524 array[0] = getByC_S_PrevAndNext(session, mbMessage, companyId,
6525 status, orderByComparator, true);
6526
6527 array[1] = mbMessage;
6528
6529 array[2] = getByC_S_PrevAndNext(session, mbMessage, companyId,
6530 status, orderByComparator, false);
6531
6532 return array;
6533 }
6534 catch (Exception e) {
6535 throw processException(e);
6536 }
6537 finally {
6538 closeSession(session);
6539 }
6540 }
6541
6542 protected MBMessage getByC_S_PrevAndNext(Session session,
6543 MBMessage mbMessage, long companyId, int status,
6544 OrderByComparator orderByComparator, boolean previous) {
6545 StringBundler query = null;
6546
6547 if (orderByComparator != null) {
6548 query = new StringBundler(6 +
6549 (orderByComparator.getOrderByFields().length * 6));
6550 }
6551 else {
6552 query = new StringBundler(3);
6553 }
6554
6555 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
6556
6557 query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
6558
6559 query.append(_FINDER_COLUMN_C_S_STATUS_2);
6560
6561 if (orderByComparator != null) {
6562 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6563
6564 if (orderByConditionFields.length > 0) {
6565 query.append(WHERE_AND);
6566 }
6567
6568 for (int i = 0; i < orderByConditionFields.length; i++) {
6569 query.append(_ORDER_BY_ENTITY_ALIAS);
6570 query.append(orderByConditionFields[i]);
6571
6572 if ((i + 1) < orderByConditionFields.length) {
6573 if (orderByComparator.isAscending() ^ previous) {
6574 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6575 }
6576 else {
6577 query.append(WHERE_LESSER_THAN_HAS_NEXT);
6578 }
6579 }
6580 else {
6581 if (orderByComparator.isAscending() ^ previous) {
6582 query.append(WHERE_GREATER_THAN);
6583 }
6584 else {
6585 query.append(WHERE_LESSER_THAN);
6586 }
6587 }
6588 }
6589
6590 query.append(ORDER_BY_CLAUSE);
6591
6592 String[] orderByFields = orderByComparator.getOrderByFields();
6593
6594 for (int i = 0; i < orderByFields.length; i++) {
6595 query.append(_ORDER_BY_ENTITY_ALIAS);
6596 query.append(orderByFields[i]);
6597
6598 if ((i + 1) < orderByFields.length) {
6599 if (orderByComparator.isAscending() ^ previous) {
6600 query.append(ORDER_BY_ASC_HAS_NEXT);
6601 }
6602 else {
6603 query.append(ORDER_BY_DESC_HAS_NEXT);
6604 }
6605 }
6606 else {
6607 if (orderByComparator.isAscending() ^ previous) {
6608 query.append(ORDER_BY_ASC);
6609 }
6610 else {
6611 query.append(ORDER_BY_DESC);
6612 }
6613 }
6614 }
6615 }
6616
6617 else {
6618 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
6619 }
6620
6621 String sql = query.toString();
6622
6623 Query q = session.createQuery(sql);
6624
6625 q.setFirstResult(0);
6626 q.setMaxResults(2);
6627
6628 QueryPos qPos = QueryPos.getInstance(q);
6629
6630 qPos.add(companyId);
6631
6632 qPos.add(status);
6633
6634 if (orderByComparator != null) {
6635 Object[] values = orderByComparator.getOrderByConditionValues(mbMessage);
6636
6637 for (Object value : values) {
6638 qPos.add(value);
6639 }
6640 }
6641
6642 List<MBMessage> list = q.list();
6643
6644 if (list.size() == 2) {
6645 return list.get(1);
6646 }
6647 else {
6648 return null;
6649 }
6650 }
6651
6652
6660 public List<MBMessage> findByU_C(long userId, long classNameId)
6661 throws SystemException {
6662 return findByU_C(userId, classNameId, QueryUtil.ALL_POS,
6663 QueryUtil.ALL_POS, null);
6664 }
6665
6666
6680 public List<MBMessage> findByU_C(long userId, long classNameId, int start,
6681 int end) throws SystemException {
6682 return findByU_C(userId, classNameId, start, end, null);
6683 }
6684
6685
6700 public List<MBMessage> findByU_C(long userId, long classNameId, int start,
6701 int end, OrderByComparator orderByComparator) throws SystemException {
6702 FinderPath finderPath = null;
6703 Object[] finderArgs = null;
6704
6705 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6706 (orderByComparator == null)) {
6707 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C;
6708 finderArgs = new Object[] { userId, classNameId };
6709 }
6710 else {
6711 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C;
6712 finderArgs = new Object[] {
6713 userId, classNameId,
6714
6715 start, end, orderByComparator
6716 };
6717 }
6718
6719 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(finderPath,
6720 finderArgs, this);
6721
6722 if (list == null) {
6723 StringBundler query = null;
6724
6725 if (orderByComparator != null) {
6726 query = new StringBundler(4 +
6727 (orderByComparator.getOrderByFields().length * 3));
6728 }
6729 else {
6730 query = new StringBundler(4);
6731 }
6732
6733 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
6734
6735 query.append(_FINDER_COLUMN_U_C_USERID_2);
6736
6737 query.append(_FINDER_COLUMN_U_C_CLASSNAMEID_2);
6738
6739 if (orderByComparator != null) {
6740 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6741 orderByComparator);
6742 }
6743
6744 else {
6745 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
6746 }
6747
6748 String sql = query.toString();
6749
6750 Session session = null;
6751
6752 try {
6753 session = openSession();
6754
6755 Query q = session.createQuery(sql);
6756
6757 QueryPos qPos = QueryPos.getInstance(q);
6758
6759 qPos.add(userId);
6760
6761 qPos.add(classNameId);
6762
6763 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
6764 end);
6765 }
6766 catch (Exception e) {
6767 throw processException(e);
6768 }
6769 finally {
6770 if (list == null) {
6771 FinderCacheUtil.removeResult(finderPath, finderArgs);
6772 }
6773 else {
6774 cacheResult(list);
6775
6776 FinderCacheUtil.putResult(finderPath, finderArgs, list);
6777 }
6778
6779 closeSession(session);
6780 }
6781 }
6782
6783 return list;
6784 }
6785
6786
6800 public MBMessage findByU_C_First(long userId, long classNameId,
6801 OrderByComparator orderByComparator)
6802 throws NoSuchMessageException, SystemException {
6803 List<MBMessage> list = findByU_C(userId, classNameId, 0, 1,
6804 orderByComparator);
6805
6806 if (list.isEmpty()) {
6807 StringBundler msg = new StringBundler(6);
6808
6809 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6810
6811 msg.append("userId=");
6812 msg.append(userId);
6813
6814 msg.append(", classNameId=");
6815 msg.append(classNameId);
6816
6817 msg.append(StringPool.CLOSE_CURLY_BRACE);
6818
6819 throw new NoSuchMessageException(msg.toString());
6820 }
6821 else {
6822 return list.get(0);
6823 }
6824 }
6825
6826
6840 public MBMessage findByU_C_Last(long userId, long classNameId,
6841 OrderByComparator orderByComparator)
6842 throws NoSuchMessageException, SystemException {
6843 int count = countByU_C(userId, classNameId);
6844
6845 List<MBMessage> list = findByU_C(userId, classNameId, count - 1, count,
6846 orderByComparator);
6847
6848 if (list.isEmpty()) {
6849 StringBundler msg = new StringBundler(6);
6850
6851 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6852
6853 msg.append("userId=");
6854 msg.append(userId);
6855
6856 msg.append(", classNameId=");
6857 msg.append(classNameId);
6858
6859 msg.append(StringPool.CLOSE_CURLY_BRACE);
6860
6861 throw new NoSuchMessageException(msg.toString());
6862 }
6863 else {
6864 return list.get(0);
6865 }
6866 }
6867
6868
6883 public MBMessage[] findByU_C_PrevAndNext(long messageId, long userId,
6884 long classNameId, OrderByComparator orderByComparator)
6885 throws NoSuchMessageException, SystemException {
6886 MBMessage mbMessage = findByPrimaryKey(messageId);
6887
6888 Session session = null;
6889
6890 try {
6891 session = openSession();
6892
6893 MBMessage[] array = new MBMessageImpl[3];
6894
6895 array[0] = getByU_C_PrevAndNext(session, mbMessage, userId,
6896 classNameId, orderByComparator, true);
6897
6898 array[1] = mbMessage;
6899
6900 array[2] = getByU_C_PrevAndNext(session, mbMessage, userId,
6901 classNameId, orderByComparator, false);
6902
6903 return array;
6904 }
6905 catch (Exception e) {
6906 throw processException(e);
6907 }
6908 finally {
6909 closeSession(session);
6910 }
6911 }
6912
6913 protected MBMessage getByU_C_PrevAndNext(Session session,
6914 MBMessage mbMessage, long userId, long classNameId,
6915 OrderByComparator orderByComparator, boolean previous) {
6916 StringBundler query = null;
6917
6918 if (orderByComparator != null) {
6919 query = new StringBundler(6 +
6920 (orderByComparator.getOrderByFields().length * 6));
6921 }
6922 else {
6923 query = new StringBundler(3);
6924 }
6925
6926 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
6927
6928 query.append(_FINDER_COLUMN_U_C_USERID_2);
6929
6930 query.append(_FINDER_COLUMN_U_C_CLASSNAMEID_2);
6931
6932 if (orderByComparator != null) {
6933 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6934
6935 if (orderByConditionFields.length > 0) {
6936 query.append(WHERE_AND);
6937 }
6938
6939 for (int i = 0; i < orderByConditionFields.length; i++) {
6940 query.append(_ORDER_BY_ENTITY_ALIAS);
6941 query.append(orderByConditionFields[i]);
6942
6943 if ((i + 1) < orderByConditionFields.length) {
6944 if (orderByComparator.isAscending() ^ previous) {
6945 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6946 }
6947 else {
6948 query.append(WHERE_LESSER_THAN_HAS_NEXT);
6949 }
6950 }
6951 else {
6952 if (orderByComparator.isAscending() ^ previous) {
6953 query.append(WHERE_GREATER_THAN);
6954 }
6955 else {
6956 query.append(WHERE_LESSER_THAN);
6957 }
6958 }
6959 }
6960
6961 query.append(ORDER_BY_CLAUSE);
6962
6963 String[] orderByFields = orderByComparator.getOrderByFields();
6964
6965 for (int i = 0; i < orderByFields.length; i++) {
6966 query.append(_ORDER_BY_ENTITY_ALIAS);
6967 query.append(orderByFields[i]);
6968
6969 if ((i + 1) < orderByFields.length) {
6970 if (orderByComparator.isAscending() ^ previous) {
6971 query.append(ORDER_BY_ASC_HAS_NEXT);
6972 }
6973 else {
6974 query.append(ORDER_BY_DESC_HAS_NEXT);
6975 }
6976 }
6977 else {
6978 if (orderByComparator.isAscending() ^ previous) {
6979 query.append(ORDER_BY_ASC);
6980 }
6981 else {
6982 query.append(ORDER_BY_DESC);
6983 }
6984 }
6985 }
6986 }
6987
6988 else {
6989 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
6990 }
6991
6992 String sql = query.toString();
6993
6994 Query q = session.createQuery(sql);
6995
6996 q.setFirstResult(0);
6997 q.setMaxResults(2);
6998
6999 QueryPos qPos = QueryPos.getInstance(q);
7000
7001 qPos.add(userId);
7002
7003 qPos.add(classNameId);
7004
7005 if (orderByComparator != null) {
7006 Object[] values = orderByComparator.getOrderByConditionValues(mbMessage);
7007
7008 for (Object value : values) {
7009 qPos.add(value);
7010 }
7011 }
7012
7013 List<MBMessage> list = q.list();
7014
7015 if (list.size() == 2) {
7016 return list.get(1);
7017 }
7018 else {
7019 return null;
7020 }
7021 }
7022
7023
7035 public List<MBMessage> findByU_C(long userId, long[] classNameIds)
7036 throws SystemException {
7037 return findByU_C(userId, classNameIds, QueryUtil.ALL_POS,
7038 QueryUtil.ALL_POS, null);
7039 }
7040
7041
7055 public List<MBMessage> findByU_C(long userId, long[] classNameIds,
7056 int start, int end) throws SystemException {
7057 return findByU_C(userId, classNameIds, start, end, null);
7058 }
7059
7060
7075 public List<MBMessage> findByU_C(long userId, long[] classNameIds,
7076 int start, int end, OrderByComparator orderByComparator)
7077 throws SystemException {
7078 FinderPath finderPath = null;
7079 Object[] finderArgs = null;
7080
7081 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7082 (orderByComparator == null)) {
7083 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C;
7084 finderArgs = new Object[] { userId, StringUtil.merge(classNameIds) };
7085 }
7086 else {
7087 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C;
7088 finderArgs = new Object[] {
7089 userId, StringUtil.merge(classNameIds),
7090
7091 start, end, orderByComparator
7092 };
7093 }
7094
7095 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(finderPath,
7096 finderArgs, this);
7097
7098 if (list == null) {
7099 StringBundler query = new StringBundler();
7100
7101 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
7102
7103 boolean conjunctionable = false;
7104
7105 if (conjunctionable) {
7106 query.append(WHERE_AND);
7107 }
7108
7109 query.append(_FINDER_COLUMN_U_C_USERID_5);
7110
7111 conjunctionable = true;
7112
7113 if ((classNameIds == null) || (classNameIds.length > 0)) {
7114 if (conjunctionable) {
7115 query.append(WHERE_AND);
7116 }
7117
7118 query.append(StringPool.OPEN_PARENTHESIS);
7119
7120 for (int i = 0; i < classNameIds.length; i++) {
7121 query.append(_FINDER_COLUMN_U_C_CLASSNAMEID_5);
7122
7123 if ((i + 1) < classNameIds.length) {
7124 query.append(WHERE_OR);
7125 }
7126 }
7127
7128 query.append(StringPool.CLOSE_PARENTHESIS);
7129
7130 conjunctionable = true;
7131 }
7132
7133 if (orderByComparator != null) {
7134 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7135 orderByComparator);
7136 }
7137
7138 else {
7139 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
7140 }
7141
7142 String sql = query.toString();
7143
7144 Session session = null;
7145
7146 try {
7147 session = openSession();
7148
7149 Query q = session.createQuery(sql);
7150
7151 QueryPos qPos = QueryPos.getInstance(q);
7152
7153 qPos.add(userId);
7154
7155 if (classNameIds != null) {
7156 qPos.add(classNameIds);
7157 }
7158
7159 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
7160 end);
7161 }
7162 catch (Exception e) {
7163 throw processException(e);
7164 }
7165 finally {
7166 if (list == null) {
7167 FinderCacheUtil.removeResult(finderPath, finderArgs);
7168 }
7169 else {
7170 cacheResult(list);
7171
7172 FinderCacheUtil.putResult(finderPath, finderArgs, list);
7173 }
7174
7175 closeSession(session);
7176 }
7177 }
7178
7179 return list;
7180 }
7181
7182
7190 public List<MBMessage> findByC_C(long classNameId, long classPK)
7191 throws SystemException {
7192 return findByC_C(classNameId, classPK, QueryUtil.ALL_POS,
7193 QueryUtil.ALL_POS, null);
7194 }
7195
7196
7210 public List<MBMessage> findByC_C(long classNameId, long classPK, int start,
7211 int end) throws SystemException {
7212 return findByC_C(classNameId, classPK, start, end, null);
7213 }
7214
7215
7230 public List<MBMessage> findByC_C(long classNameId, long classPK, int start,
7231 int end, OrderByComparator orderByComparator) throws SystemException {
7232 FinderPath finderPath = null;
7233 Object[] finderArgs = null;
7234
7235 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7236 (orderByComparator == null)) {
7237 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C;
7238 finderArgs = new Object[] { classNameId, classPK };
7239 }
7240 else {
7241 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C;
7242 finderArgs = new Object[] {
7243 classNameId, classPK,
7244
7245 start, end, orderByComparator
7246 };
7247 }
7248
7249 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(finderPath,
7250 finderArgs, this);
7251
7252 if (list == null) {
7253 StringBundler query = null;
7254
7255 if (orderByComparator != null) {
7256 query = new StringBundler(4 +
7257 (orderByComparator.getOrderByFields().length * 3));
7258 }
7259 else {
7260 query = new StringBundler(4);
7261 }
7262
7263 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
7264
7265 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
7266
7267 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
7268
7269 if (orderByComparator != null) {
7270 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7271 orderByComparator);
7272 }
7273
7274 else {
7275 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
7276 }
7277
7278 String sql = query.toString();
7279
7280 Session session = null;
7281
7282 try {
7283 session = openSession();
7284
7285 Query q = session.createQuery(sql);
7286
7287 QueryPos qPos = QueryPos.getInstance(q);
7288
7289 qPos.add(classNameId);
7290
7291 qPos.add(classPK);
7292
7293 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
7294 end);
7295 }
7296 catch (Exception e) {
7297 throw processException(e);
7298 }
7299 finally {
7300 if (list == null) {
7301 FinderCacheUtil.removeResult(finderPath, finderArgs);
7302 }
7303 else {
7304 cacheResult(list);
7305
7306 FinderCacheUtil.putResult(finderPath, finderArgs, list);
7307 }
7308
7309 closeSession(session);
7310 }
7311 }
7312
7313 return list;
7314 }
7315
7316
7330 public MBMessage findByC_C_First(long classNameId, long classPK,
7331 OrderByComparator orderByComparator)
7332 throws NoSuchMessageException, SystemException {
7333 List<MBMessage> list = findByC_C(classNameId, classPK, 0, 1,
7334 orderByComparator);
7335
7336 if (list.isEmpty()) {
7337 StringBundler msg = new StringBundler(6);
7338
7339 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7340
7341 msg.append("classNameId=");
7342 msg.append(classNameId);
7343
7344 msg.append(", classPK=");
7345 msg.append(classPK);
7346
7347 msg.append(StringPool.CLOSE_CURLY_BRACE);
7348
7349 throw new NoSuchMessageException(msg.toString());
7350 }
7351 else {
7352 return list.get(0);
7353 }
7354 }
7355
7356
7370 public MBMessage findByC_C_Last(long classNameId, long classPK,
7371 OrderByComparator orderByComparator)
7372 throws NoSuchMessageException, SystemException {
7373 int count = countByC_C(classNameId, classPK);
7374
7375 List<MBMessage> list = findByC_C(classNameId, classPK, count - 1,
7376 count, orderByComparator);
7377
7378 if (list.isEmpty()) {
7379 StringBundler msg = new StringBundler(6);
7380
7381 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7382
7383 msg.append("classNameId=");
7384 msg.append(classNameId);
7385
7386 msg.append(", classPK=");
7387 msg.append(classPK);
7388
7389 msg.append(StringPool.CLOSE_CURLY_BRACE);
7390
7391 throw new NoSuchMessageException(msg.toString());
7392 }
7393 else {
7394 return list.get(0);
7395 }
7396 }
7397
7398
7413 public MBMessage[] findByC_C_PrevAndNext(long messageId, long classNameId,
7414 long classPK, OrderByComparator orderByComparator)
7415 throws NoSuchMessageException, SystemException {
7416 MBMessage mbMessage = findByPrimaryKey(messageId);
7417
7418 Session session = null;
7419
7420 try {
7421 session = openSession();
7422
7423 MBMessage[] array = new MBMessageImpl[3];
7424
7425 array[0] = getByC_C_PrevAndNext(session, mbMessage, classNameId,
7426 classPK, orderByComparator, true);
7427
7428 array[1] = mbMessage;
7429
7430 array[2] = getByC_C_PrevAndNext(session, mbMessage, classNameId,
7431 classPK, orderByComparator, false);
7432
7433 return array;
7434 }
7435 catch (Exception e) {
7436 throw processException(e);
7437 }
7438 finally {
7439 closeSession(session);
7440 }
7441 }
7442
7443 protected MBMessage getByC_C_PrevAndNext(Session session,
7444 MBMessage mbMessage, long classNameId, long classPK,
7445 OrderByComparator orderByComparator, boolean previous) {
7446 StringBundler query = null;
7447
7448 if (orderByComparator != null) {
7449 query = new StringBundler(6 +
7450 (orderByComparator.getOrderByFields().length * 6));
7451 }
7452 else {
7453 query = new StringBundler(3);
7454 }
7455
7456 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
7457
7458 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
7459
7460 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
7461
7462 if (orderByComparator != null) {
7463 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7464
7465 if (orderByConditionFields.length > 0) {
7466 query.append(WHERE_AND);
7467 }
7468
7469 for (int i = 0; i < orderByConditionFields.length; i++) {
7470 query.append(_ORDER_BY_ENTITY_ALIAS);
7471 query.append(orderByConditionFields[i]);
7472
7473 if ((i + 1) < orderByConditionFields.length) {
7474 if (orderByComparator.isAscending() ^ previous) {
7475 query.append(WHERE_GREATER_THAN_HAS_NEXT);
7476 }
7477 else {
7478 query.append(WHERE_LESSER_THAN_HAS_NEXT);
7479 }
7480 }
7481 else {
7482 if (orderByComparator.isAscending() ^ previous) {
7483 query.append(WHERE_GREATER_THAN);
7484 }
7485 else {
7486 query.append(WHERE_LESSER_THAN);
7487 }
7488 }
7489 }
7490
7491 query.append(ORDER_BY_CLAUSE);
7492
7493 String[] orderByFields = orderByComparator.getOrderByFields();
7494
7495 for (int i = 0; i < orderByFields.length; i++) {
7496 query.append(_ORDER_BY_ENTITY_ALIAS);
7497 query.append(orderByFields[i]);
7498
7499 if ((i + 1) < orderByFields.length) {
7500 if (orderByComparator.isAscending() ^ previous) {
7501 query.append(ORDER_BY_ASC_HAS_NEXT);
7502 }
7503 else {
7504 query.append(ORDER_BY_DESC_HAS_NEXT);
7505 }
7506 }
7507 else {
7508 if (orderByComparator.isAscending() ^ previous) {
7509 query.append(ORDER_BY_ASC);
7510 }
7511 else {
7512 query.append(ORDER_BY_DESC);
7513 }
7514 }
7515 }
7516 }
7517
7518 else {
7519 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
7520 }
7521
7522 String sql = query.toString();
7523
7524 Query q = session.createQuery(sql);
7525
7526 q.setFirstResult(0);
7527 q.setMaxResults(2);
7528
7529 QueryPos qPos = QueryPos.getInstance(q);
7530
7531 qPos.add(classNameId);
7532
7533 qPos.add(classPK);
7534
7535 if (orderByComparator != null) {
7536 Object[] values = orderByComparator.getOrderByConditionValues(mbMessage);
7537
7538 for (Object value : values) {
7539 qPos.add(value);
7540 }
7541 }
7542
7543 List<MBMessage> list = q.list();
7544
7545 if (list.size() == 2) {
7546 return list.get(1);
7547 }
7548 else {
7549 return null;
7550 }
7551 }
7552
7553
7561 public List<MBMessage> findByT_P(long threadId, long parentMessageId)
7562 throws SystemException {
7563 return findByT_P(threadId, parentMessageId, QueryUtil.ALL_POS,
7564 QueryUtil.ALL_POS, null);
7565 }
7566
7567
7581 public List<MBMessage> findByT_P(long threadId, long parentMessageId,
7582 int start, int end) throws SystemException {
7583 return findByT_P(threadId, parentMessageId, start, end, null);
7584 }
7585
7586
7601 public List<MBMessage> findByT_P(long threadId, long parentMessageId,
7602 int start, int end, OrderByComparator orderByComparator)
7603 throws SystemException {
7604 FinderPath finderPath = null;
7605 Object[] finderArgs = null;
7606
7607 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7608 (orderByComparator == null)) {
7609 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_P;
7610 finderArgs = new Object[] { threadId, parentMessageId };
7611 }
7612 else {
7613 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_T_P;
7614 finderArgs = new Object[] {
7615 threadId, parentMessageId,
7616
7617 start, end, orderByComparator
7618 };
7619 }
7620
7621 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(finderPath,
7622 finderArgs, this);
7623
7624 if (list == null) {
7625 StringBundler query = null;
7626
7627 if (orderByComparator != null) {
7628 query = new StringBundler(4 +
7629 (orderByComparator.getOrderByFields().length * 3));
7630 }
7631 else {
7632 query = new StringBundler(4);
7633 }
7634
7635 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
7636
7637 query.append(_FINDER_COLUMN_T_P_THREADID_2);
7638
7639 query.append(_FINDER_COLUMN_T_P_PARENTMESSAGEID_2);
7640
7641 if (orderByComparator != null) {
7642 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7643 orderByComparator);
7644 }
7645
7646 else {
7647 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
7648 }
7649
7650 String sql = query.toString();
7651
7652 Session session = null;
7653
7654 try {
7655 session = openSession();
7656
7657 Query q = session.createQuery(sql);
7658
7659 QueryPos qPos = QueryPos.getInstance(q);
7660
7661 qPos.add(threadId);
7662
7663 qPos.add(parentMessageId);
7664
7665 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
7666 end);
7667 }
7668 catch (Exception e) {
7669 throw processException(e);
7670 }
7671 finally {
7672 if (list == null) {
7673 FinderCacheUtil.removeResult(finderPath, finderArgs);
7674 }
7675 else {
7676 cacheResult(list);
7677
7678 FinderCacheUtil.putResult(finderPath, finderArgs, list);
7679 }
7680
7681 closeSession(session);
7682 }
7683 }
7684
7685 return list;
7686 }
7687
7688
7702 public MBMessage findByT_P_First(long threadId, long parentMessageId,
7703 OrderByComparator orderByComparator)
7704 throws NoSuchMessageException, SystemException {
7705 List<MBMessage> list = findByT_P(threadId, parentMessageId, 0, 1,
7706 orderByComparator);
7707
7708 if (list.isEmpty()) {
7709 StringBundler msg = new StringBundler(6);
7710
7711 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7712
7713 msg.append("threadId=");
7714 msg.append(threadId);
7715
7716 msg.append(", parentMessageId=");
7717 msg.append(parentMessageId);
7718
7719 msg.append(StringPool.CLOSE_CURLY_BRACE);
7720
7721 throw new NoSuchMessageException(msg.toString());
7722 }
7723 else {
7724 return list.get(0);
7725 }
7726 }
7727
7728
7742 public MBMessage findByT_P_Last(long threadId, long parentMessageId,
7743 OrderByComparator orderByComparator)
7744 throws NoSuchMessageException, SystemException {
7745 int count = countByT_P(threadId, parentMessageId);
7746
7747 List<MBMessage> list = findByT_P(threadId, parentMessageId, count - 1,
7748 count, orderByComparator);
7749
7750 if (list.isEmpty()) {
7751 StringBundler msg = new StringBundler(6);
7752
7753 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7754
7755 msg.append("threadId=");
7756 msg.append(threadId);
7757
7758 msg.append(", parentMessageId=");
7759 msg.append(parentMessageId);
7760
7761 msg.append(StringPool.CLOSE_CURLY_BRACE);
7762
7763 throw new NoSuchMessageException(msg.toString());
7764 }
7765 else {
7766 return list.get(0);
7767 }
7768 }
7769
7770
7785 public MBMessage[] findByT_P_PrevAndNext(long messageId, long threadId,
7786 long parentMessageId, OrderByComparator orderByComparator)
7787 throws NoSuchMessageException, SystemException {
7788 MBMessage mbMessage = findByPrimaryKey(messageId);
7789
7790 Session session = null;
7791
7792 try {
7793 session = openSession();
7794
7795 MBMessage[] array = new MBMessageImpl[3];
7796
7797 array[0] = getByT_P_PrevAndNext(session, mbMessage, threadId,
7798 parentMessageId, orderByComparator, true);
7799
7800 array[1] = mbMessage;
7801
7802 array[2] = getByT_P_PrevAndNext(session, mbMessage, threadId,
7803 parentMessageId, orderByComparator, false);
7804
7805 return array;
7806 }
7807 catch (Exception e) {
7808 throw processException(e);
7809 }
7810 finally {
7811 closeSession(session);
7812 }
7813 }
7814
7815 protected MBMessage getByT_P_PrevAndNext(Session session,
7816 MBMessage mbMessage, long threadId, long parentMessageId,
7817 OrderByComparator orderByComparator, boolean previous) {
7818 StringBundler query = null;
7819
7820 if (orderByComparator != null) {
7821 query = new StringBundler(6 +
7822 (orderByComparator.getOrderByFields().length * 6));
7823 }
7824 else {
7825 query = new StringBundler(3);
7826 }
7827
7828 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
7829
7830 query.append(_FINDER_COLUMN_T_P_THREADID_2);
7831
7832 query.append(_FINDER_COLUMN_T_P_PARENTMESSAGEID_2);
7833
7834 if (orderByComparator != null) {
7835 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7836
7837 if (orderByConditionFields.length > 0) {
7838 query.append(WHERE_AND);
7839 }
7840
7841 for (int i = 0; i < orderByConditionFields.length; i++) {
7842 query.append(_ORDER_BY_ENTITY_ALIAS);
7843 query.append(orderByConditionFields[i]);
7844
7845 if ((i + 1) < orderByConditionFields.length) {
7846 if (orderByComparator.isAscending() ^ previous) {
7847 query.append(WHERE_GREATER_THAN_HAS_NEXT);
7848 }
7849 else {
7850 query.append(WHERE_LESSER_THAN_HAS_NEXT);
7851 }
7852 }
7853 else {
7854 if (orderByComparator.isAscending() ^ previous) {
7855 query.append(WHERE_GREATER_THAN);
7856 }
7857 else {
7858 query.append(WHERE_LESSER_THAN);
7859 }
7860 }
7861 }
7862
7863 query.append(ORDER_BY_CLAUSE);
7864
7865 String[] orderByFields = orderByComparator.getOrderByFields();
7866
7867 for (int i = 0; i < orderByFields.length; i++) {
7868 query.append(_ORDER_BY_ENTITY_ALIAS);
7869 query.append(orderByFields[i]);
7870
7871 if ((i + 1) < orderByFields.length) {
7872 if (orderByComparator.isAscending() ^ previous) {
7873 query.append(ORDER_BY_ASC_HAS_NEXT);
7874 }
7875 else {
7876 query.append(ORDER_BY_DESC_HAS_NEXT);
7877 }
7878 }
7879 else {
7880 if (orderByComparator.isAscending() ^ previous) {
7881 query.append(ORDER_BY_ASC);
7882 }
7883 else {
7884 query.append(ORDER_BY_DESC);
7885 }
7886 }
7887 }
7888 }
7889
7890 else {
7891 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
7892 }
7893
7894 String sql = query.toString();
7895
7896 Query q = session.createQuery(sql);
7897
7898 q.setFirstResult(0);
7899 q.setMaxResults(2);
7900
7901 QueryPos qPos = QueryPos.getInstance(q);
7902
7903 qPos.add(threadId);
7904
7905 qPos.add(parentMessageId);
7906
7907 if (orderByComparator != null) {
7908 Object[] values = orderByComparator.getOrderByConditionValues(mbMessage);
7909
7910 for (Object value : values) {
7911 qPos.add(value);
7912 }
7913 }
7914
7915 List<MBMessage> list = q.list();
7916
7917 if (list.size() == 2) {
7918 return list.get(1);
7919 }
7920 else {
7921 return null;
7922 }
7923 }
7924
7925
7933 public List<MBMessage> findByT_A(long threadId, boolean answer)
7934 throws SystemException {
7935 return findByT_A(threadId, answer, QueryUtil.ALL_POS,
7936 QueryUtil.ALL_POS, null);
7937 }
7938
7939
7953 public List<MBMessage> findByT_A(long threadId, boolean answer, int start,
7954 int end) throws SystemException {
7955 return findByT_A(threadId, answer, start, end, null);
7956 }
7957
7958
7973 public List<MBMessage> findByT_A(long threadId, boolean answer, int start,
7974 int end, OrderByComparator orderByComparator) throws SystemException {
7975 FinderPath finderPath = null;
7976 Object[] finderArgs = null;
7977
7978 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7979 (orderByComparator == null)) {
7980 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A;
7981 finderArgs = new Object[] { threadId, answer };
7982 }
7983 else {
7984 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_T_A;
7985 finderArgs = new Object[] {
7986 threadId, answer,
7987
7988 start, end, orderByComparator
7989 };
7990 }
7991
7992 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(finderPath,
7993 finderArgs, this);
7994
7995 if (list == null) {
7996 StringBundler query = null;
7997
7998 if (orderByComparator != null) {
7999 query = new StringBundler(4 +
8000 (orderByComparator.getOrderByFields().length * 3));
8001 }
8002 else {
8003 query = new StringBundler(4);
8004 }
8005
8006 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
8007
8008 query.append(_FINDER_COLUMN_T_A_THREADID_2);
8009
8010 query.append(_FINDER_COLUMN_T_A_ANSWER_2);
8011
8012 if (orderByComparator != null) {
8013 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8014 orderByComparator);
8015 }
8016
8017 else {
8018 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
8019 }
8020
8021 String sql = query.toString();
8022
8023 Session session = null;
8024
8025 try {
8026 session = openSession();
8027
8028 Query q = session.createQuery(sql);
8029
8030 QueryPos qPos = QueryPos.getInstance(q);
8031
8032 qPos.add(threadId);
8033
8034 qPos.add(answer);
8035
8036 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
8037 end);
8038 }
8039 catch (Exception e) {
8040 throw processException(e);
8041 }
8042 finally {
8043 if (list == null) {
8044 FinderCacheUtil.removeResult(finderPath, finderArgs);
8045 }
8046 else {
8047 cacheResult(list);
8048
8049 FinderCacheUtil.putResult(finderPath, finderArgs, list);
8050 }
8051
8052 closeSession(session);
8053 }
8054 }
8055
8056 return list;
8057 }
8058
8059
8073 public MBMessage findByT_A_First(long threadId, boolean answer,
8074 OrderByComparator orderByComparator)
8075 throws NoSuchMessageException, SystemException {
8076 List<MBMessage> list = findByT_A(threadId, answer, 0, 1,
8077 orderByComparator);
8078
8079 if (list.isEmpty()) {
8080 StringBundler msg = new StringBundler(6);
8081
8082 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8083
8084 msg.append("threadId=");
8085 msg.append(threadId);
8086
8087 msg.append(", answer=");
8088 msg.append(answer);
8089
8090 msg.append(StringPool.CLOSE_CURLY_BRACE);
8091
8092 throw new NoSuchMessageException(msg.toString());
8093 }
8094 else {
8095 return list.get(0);
8096 }
8097 }
8098
8099
8113 public MBMessage findByT_A_Last(long threadId, boolean answer,
8114 OrderByComparator orderByComparator)
8115 throws NoSuchMessageException, SystemException {
8116 int count = countByT_A(threadId, answer);
8117
8118 List<MBMessage> list = findByT_A(threadId, answer, count - 1, count,
8119 orderByComparator);
8120
8121 if (list.isEmpty()) {
8122 StringBundler msg = new StringBundler(6);
8123
8124 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8125
8126 msg.append("threadId=");
8127 msg.append(threadId);
8128
8129 msg.append(", answer=");
8130 msg.append(answer);
8131
8132 msg.append(StringPool.CLOSE_CURLY_BRACE);
8133
8134 throw new NoSuchMessageException(msg.toString());
8135 }
8136 else {
8137 return list.get(0);
8138 }
8139 }
8140
8141
8156 public MBMessage[] findByT_A_PrevAndNext(long messageId, long threadId,
8157 boolean answer, OrderByComparator orderByComparator)
8158 throws NoSuchMessageException, SystemException {
8159 MBMessage mbMessage = findByPrimaryKey(messageId);
8160
8161 Session session = null;
8162
8163 try {
8164 session = openSession();
8165
8166 MBMessage[] array = new MBMessageImpl[3];
8167
8168 array[0] = getByT_A_PrevAndNext(session, mbMessage, threadId,
8169 answer, orderByComparator, true);
8170
8171 array[1] = mbMessage;
8172
8173 array[2] = getByT_A_PrevAndNext(session, mbMessage, threadId,
8174 answer, orderByComparator, false);
8175
8176 return array;
8177 }
8178 catch (Exception e) {
8179 throw processException(e);
8180 }
8181 finally {
8182 closeSession(session);
8183 }
8184 }
8185
8186 protected MBMessage getByT_A_PrevAndNext(Session session,
8187 MBMessage mbMessage, long threadId, boolean answer,
8188 OrderByComparator orderByComparator, boolean previous) {
8189 StringBundler query = null;
8190
8191 if (orderByComparator != null) {
8192 query = new StringBundler(6 +
8193 (orderByComparator.getOrderByFields().length * 6));
8194 }
8195 else {
8196 query = new StringBundler(3);
8197 }
8198
8199 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
8200
8201 query.append(_FINDER_COLUMN_T_A_THREADID_2);
8202
8203 query.append(_FINDER_COLUMN_T_A_ANSWER_2);
8204
8205 if (orderByComparator != null) {
8206 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8207
8208 if (orderByConditionFields.length > 0) {
8209 query.append(WHERE_AND);
8210 }
8211
8212 for (int i = 0; i < orderByConditionFields.length; i++) {
8213 query.append(_ORDER_BY_ENTITY_ALIAS);
8214 query.append(orderByConditionFields[i]);
8215
8216 if ((i + 1) < orderByConditionFields.length) {
8217 if (orderByComparator.isAscending() ^ previous) {
8218 query.append(WHERE_GREATER_THAN_HAS_NEXT);
8219 }
8220 else {
8221 query.append(WHERE_LESSER_THAN_HAS_NEXT);
8222 }
8223 }
8224 else {
8225 if (orderByComparator.isAscending() ^ previous) {
8226 query.append(WHERE_GREATER_THAN);
8227 }
8228 else {
8229 query.append(WHERE_LESSER_THAN);
8230 }
8231 }
8232 }
8233
8234 query.append(ORDER_BY_CLAUSE);
8235
8236 String[] orderByFields = orderByComparator.getOrderByFields();
8237
8238 for (int i = 0; i < orderByFields.length; i++) {
8239 query.append(_ORDER_BY_ENTITY_ALIAS);
8240 query.append(orderByFields[i]);
8241
8242 if ((i + 1) < orderByFields.length) {
8243 if (orderByComparator.isAscending() ^ previous) {
8244 query.append(ORDER_BY_ASC_HAS_NEXT);
8245 }
8246 else {
8247 query.append(ORDER_BY_DESC_HAS_NEXT);
8248 }
8249 }
8250 else {
8251 if (orderByComparator.isAscending() ^ previous) {
8252 query.append(ORDER_BY_ASC);
8253 }
8254 else {
8255 query.append(ORDER_BY_DESC);
8256 }
8257 }
8258 }
8259 }
8260
8261 else {
8262 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
8263 }
8264
8265 String sql = query.toString();
8266
8267 Query q = session.createQuery(sql);
8268
8269 q.setFirstResult(0);
8270 q.setMaxResults(2);
8271
8272 QueryPos qPos = QueryPos.getInstance(q);
8273
8274 qPos.add(threadId);
8275
8276 qPos.add(answer);
8277
8278 if (orderByComparator != null) {
8279 Object[] values = orderByComparator.getOrderByConditionValues(mbMessage);
8280
8281 for (Object value : values) {
8282 qPos.add(value);
8283 }
8284 }
8285
8286 List<MBMessage> list = q.list();
8287
8288 if (list.size() == 2) {
8289 return list.get(1);
8290 }
8291 else {
8292 return null;
8293 }
8294 }
8295
8296
8304 public List<MBMessage> findByT_S(long threadId, int status)
8305 throws SystemException {
8306 return findByT_S(threadId, status, QueryUtil.ALL_POS,
8307 QueryUtil.ALL_POS, null);
8308 }
8309
8310
8324 public List<MBMessage> findByT_S(long threadId, int status, int start,
8325 int end) throws SystemException {
8326 return findByT_S(threadId, status, start, end, null);
8327 }
8328
8329
8344 public List<MBMessage> findByT_S(long threadId, int status, int start,
8345 int end, OrderByComparator orderByComparator) throws SystemException {
8346 FinderPath finderPath = null;
8347 Object[] finderArgs = null;
8348
8349 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8350 (orderByComparator == null)) {
8351 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_S;
8352 finderArgs = new Object[] { threadId, status };
8353 }
8354 else {
8355 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_T_S;
8356 finderArgs = new Object[] {
8357 threadId, status,
8358
8359 start, end, orderByComparator
8360 };
8361 }
8362
8363 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(finderPath,
8364 finderArgs, this);
8365
8366 if (list == null) {
8367 StringBundler query = null;
8368
8369 if (orderByComparator != null) {
8370 query = new StringBundler(4 +
8371 (orderByComparator.getOrderByFields().length * 3));
8372 }
8373 else {
8374 query = new StringBundler(4);
8375 }
8376
8377 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
8378
8379 query.append(_FINDER_COLUMN_T_S_THREADID_2);
8380
8381 query.append(_FINDER_COLUMN_T_S_STATUS_2);
8382
8383 if (orderByComparator != null) {
8384 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8385 orderByComparator);
8386 }
8387
8388 else {
8389 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
8390 }
8391
8392 String sql = query.toString();
8393
8394 Session session = null;
8395
8396 try {
8397 session = openSession();
8398
8399 Query q = session.createQuery(sql);
8400
8401 QueryPos qPos = QueryPos.getInstance(q);
8402
8403 qPos.add(threadId);
8404
8405 qPos.add(status);
8406
8407 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
8408 end);
8409 }
8410 catch (Exception e) {
8411 throw processException(e);
8412 }
8413 finally {
8414 if (list == null) {
8415 FinderCacheUtil.removeResult(finderPath, finderArgs);
8416 }
8417 else {
8418 cacheResult(list);
8419
8420 FinderCacheUtil.putResult(finderPath, finderArgs, list);
8421 }
8422
8423 closeSession(session);
8424 }
8425 }
8426
8427 return list;
8428 }
8429
8430
8444 public MBMessage findByT_S_First(long threadId, int status,
8445 OrderByComparator orderByComparator)
8446 throws NoSuchMessageException, SystemException {
8447 List<MBMessage> list = findByT_S(threadId, status, 0, 1,
8448 orderByComparator);
8449
8450 if (list.isEmpty()) {
8451 StringBundler msg = new StringBundler(6);
8452
8453 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8454
8455 msg.append("threadId=");
8456 msg.append(threadId);
8457
8458 msg.append(", status=");
8459 msg.append(status);
8460
8461 msg.append(StringPool.CLOSE_CURLY_BRACE);
8462
8463 throw new NoSuchMessageException(msg.toString());
8464 }
8465 else {
8466 return list.get(0);
8467 }
8468 }
8469
8470
8484 public MBMessage findByT_S_Last(long threadId, int status,
8485 OrderByComparator orderByComparator)
8486 throws NoSuchMessageException, SystemException {
8487 int count = countByT_S(threadId, status);
8488
8489 List<MBMessage> list = findByT_S(threadId, status, count - 1, count,
8490 orderByComparator);
8491
8492 if (list.isEmpty()) {
8493 StringBundler msg = new StringBundler(6);
8494
8495 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8496
8497 msg.append("threadId=");
8498 msg.append(threadId);
8499
8500 msg.append(", status=");
8501 msg.append(status);
8502
8503 msg.append(StringPool.CLOSE_CURLY_BRACE);
8504
8505 throw new NoSuchMessageException(msg.toString());
8506 }
8507 else {
8508 return list.get(0);
8509 }
8510 }
8511
8512
8527 public MBMessage[] findByT_S_PrevAndNext(long messageId, long threadId,
8528 int status, OrderByComparator orderByComparator)
8529 throws NoSuchMessageException, SystemException {
8530 MBMessage mbMessage = findByPrimaryKey(messageId);
8531
8532 Session session = null;
8533
8534 try {
8535 session = openSession();
8536
8537 MBMessage[] array = new MBMessageImpl[3];
8538
8539 array[0] = getByT_S_PrevAndNext(session, mbMessage, threadId,
8540 status, orderByComparator, true);
8541
8542 array[1] = mbMessage;
8543
8544 array[2] = getByT_S_PrevAndNext(session, mbMessage, threadId,
8545 status, orderByComparator, false);
8546
8547 return array;
8548 }
8549 catch (Exception e) {
8550 throw processException(e);
8551 }
8552 finally {
8553 closeSession(session);
8554 }
8555 }
8556
8557 protected MBMessage getByT_S_PrevAndNext(Session session,
8558 MBMessage mbMessage, long threadId, int status,
8559 OrderByComparator orderByComparator, boolean previous) {
8560 StringBundler query = null;
8561
8562 if (orderByComparator != null) {
8563 query = new StringBundler(6 +
8564 (orderByComparator.getOrderByFields().length * 6));
8565 }
8566 else {
8567 query = new StringBundler(3);
8568 }
8569
8570 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
8571
8572 query.append(_FINDER_COLUMN_T_S_THREADID_2);
8573
8574 query.append(_FINDER_COLUMN_T_S_STATUS_2);
8575
8576 if (orderByComparator != null) {
8577 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8578
8579 if (orderByConditionFields.length > 0) {
8580 query.append(WHERE_AND);
8581 }
8582
8583 for (int i = 0; i < orderByConditionFields.length; i++) {
8584 query.append(_ORDER_BY_ENTITY_ALIAS);
8585 query.append(orderByConditionFields[i]);
8586
8587 if ((i + 1) < orderByConditionFields.length) {
8588 if (orderByComparator.isAscending() ^ previous) {
8589 query.append(WHERE_GREATER_THAN_HAS_NEXT);
8590 }
8591 else {
8592 query.append(WHERE_LESSER_THAN_HAS_NEXT);
8593 }
8594 }
8595 else {
8596 if (orderByComparator.isAscending() ^ previous) {
8597 query.append(WHERE_GREATER_THAN);
8598 }
8599 else {
8600 query.append(WHERE_LESSER_THAN);
8601 }
8602 }
8603 }
8604
8605 query.append(ORDER_BY_CLAUSE);
8606
8607 String[] orderByFields = orderByComparator.getOrderByFields();
8608
8609 for (int i = 0; i < orderByFields.length; i++) {
8610 query.append(_ORDER_BY_ENTITY_ALIAS);
8611 query.append(orderByFields[i]);
8612
8613 if ((i + 1) < orderByFields.length) {
8614 if (orderByComparator.isAscending() ^ previous) {
8615 query.append(ORDER_BY_ASC_HAS_NEXT);
8616 }
8617 else {
8618 query.append(ORDER_BY_DESC_HAS_NEXT);
8619 }
8620 }
8621 else {
8622 if (orderByComparator.isAscending() ^ previous) {
8623 query.append(ORDER_BY_ASC);
8624 }
8625 else {
8626 query.append(ORDER_BY_DESC);
8627 }
8628 }
8629 }
8630 }
8631
8632 else {
8633 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
8634 }
8635
8636 String sql = query.toString();
8637
8638 Query q = session.createQuery(sql);
8639
8640 q.setFirstResult(0);
8641 q.setMaxResults(2);
8642
8643 QueryPos qPos = QueryPos.getInstance(q);
8644
8645 qPos.add(threadId);
8646
8647 qPos.add(status);
8648
8649 if (orderByComparator != null) {
8650 Object[] values = orderByComparator.getOrderByConditionValues(mbMessage);
8651
8652 for (Object value : values) {
8653 qPos.add(value);
8654 }
8655 }
8656
8657 List<MBMessage> list = q.list();
8658
8659 if (list.size() == 2) {
8660 return list.get(1);
8661 }
8662 else {
8663 return null;
8664 }
8665 }
8666
8667
8675 public List<MBMessage> findByTR_S(long threadId, int status)
8676 throws SystemException {
8677 return findByTR_S(threadId, status, QueryUtil.ALL_POS,
8678 QueryUtil.ALL_POS, null);
8679 }
8680
8681
8695 public List<MBMessage> findByTR_S(long threadId, int status, int start,
8696 int end) throws SystemException {
8697 return findByTR_S(threadId, status, start, end, null);
8698 }
8699
8700
8715 public List<MBMessage> findByTR_S(long threadId, int status, int start,
8716 int end, OrderByComparator orderByComparator) throws SystemException {
8717 FinderPath finderPath = null;
8718 Object[] finderArgs = null;
8719
8720 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8721 (orderByComparator == null)) {
8722 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TR_S;
8723 finderArgs = new Object[] { threadId, status };
8724 }
8725 else {
8726 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_TR_S;
8727 finderArgs = new Object[] {
8728 threadId, status,
8729
8730 start, end, orderByComparator
8731 };
8732 }
8733
8734 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(finderPath,
8735 finderArgs, this);
8736
8737 if (list == null) {
8738 StringBundler query = null;
8739
8740 if (orderByComparator != null) {
8741 query = new StringBundler(4 +
8742 (orderByComparator.getOrderByFields().length * 3));
8743 }
8744 else {
8745 query = new StringBundler(4);
8746 }
8747
8748 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
8749
8750 query.append(_FINDER_COLUMN_TR_S_THREADID_2);
8751
8752 query.append(_FINDER_COLUMN_TR_S_STATUS_2);
8753
8754 if (orderByComparator != null) {
8755 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8756 orderByComparator);
8757 }
8758
8759 else {
8760 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
8761 }
8762
8763 String sql = query.toString();
8764
8765 Session session = null;
8766
8767 try {
8768 session = openSession();
8769
8770 Query q = session.createQuery(sql);
8771
8772 QueryPos qPos = QueryPos.getInstance(q);
8773
8774 qPos.add(threadId);
8775
8776 qPos.add(status);
8777
8778 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
8779 end);
8780 }
8781 catch (Exception e) {
8782 throw processException(e);
8783 }
8784 finally {
8785 if (list == null) {
8786 FinderCacheUtil.removeResult(finderPath, finderArgs);
8787 }
8788 else {
8789 cacheResult(list);
8790
8791 FinderCacheUtil.putResult(finderPath, finderArgs, list);
8792 }
8793
8794 closeSession(session);
8795 }
8796 }
8797
8798 return list;
8799 }
8800
8801
8815 public MBMessage findByTR_S_First(long threadId, int status,
8816 OrderByComparator orderByComparator)
8817 throws NoSuchMessageException, SystemException {
8818 List<MBMessage> list = findByTR_S(threadId, status, 0, 1,
8819 orderByComparator);
8820
8821 if (list.isEmpty()) {
8822 StringBundler msg = new StringBundler(6);
8823
8824 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8825
8826 msg.append("threadId=");
8827 msg.append(threadId);
8828
8829 msg.append(", status=");
8830 msg.append(status);
8831
8832 msg.append(StringPool.CLOSE_CURLY_BRACE);
8833
8834 throw new NoSuchMessageException(msg.toString());
8835 }
8836 else {
8837 return list.get(0);
8838 }
8839 }
8840
8841
8855 public MBMessage findByTR_S_Last(long threadId, int status,
8856 OrderByComparator orderByComparator)
8857 throws NoSuchMessageException, SystemException {
8858 int count = countByTR_S(threadId, status);
8859
8860 List<MBMessage> list = findByTR_S(threadId, status, count - 1, count,
8861 orderByComparator);
8862
8863 if (list.isEmpty()) {
8864 StringBundler msg = new StringBundler(6);
8865
8866 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8867
8868 msg.append("threadId=");
8869 msg.append(threadId);
8870
8871 msg.append(", status=");
8872 msg.append(status);
8873
8874 msg.append(StringPool.CLOSE_CURLY_BRACE);
8875
8876 throw new NoSuchMessageException(msg.toString());
8877 }
8878 else {
8879 return list.get(0);
8880 }
8881 }
8882
8883
8898 public MBMessage[] findByTR_S_PrevAndNext(long messageId, long threadId,
8899 int status, OrderByComparator orderByComparator)
8900 throws NoSuchMessageException, SystemException {
8901 MBMessage mbMessage = findByPrimaryKey(messageId);
8902
8903 Session session = null;
8904
8905 try {
8906 session = openSession();
8907
8908 MBMessage[] array = new MBMessageImpl[3];
8909
8910 array[0] = getByTR_S_PrevAndNext(session, mbMessage, threadId,
8911 status, orderByComparator, true);
8912
8913 array[1] = mbMessage;
8914
8915 array[2] = getByTR_S_PrevAndNext(session, mbMessage, threadId,
8916 status, orderByComparator, false);
8917
8918 return array;
8919 }
8920 catch (Exception e) {
8921 throw processException(e);
8922 }
8923 finally {
8924 closeSession(session);
8925 }
8926 }
8927
8928 protected MBMessage getByTR_S_PrevAndNext(Session session,
8929 MBMessage mbMessage, long threadId, int status,
8930 OrderByComparator orderByComparator, boolean previous) {
8931 StringBundler query = null;
8932
8933 if (orderByComparator != null) {
8934 query = new StringBundler(6 +
8935 (orderByComparator.getOrderByFields().length * 6));
8936 }
8937 else {
8938 query = new StringBundler(3);
8939 }
8940
8941 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
8942
8943 query.append(_FINDER_COLUMN_TR_S_THREADID_2);
8944
8945 query.append(_FINDER_COLUMN_TR_S_STATUS_2);
8946
8947 if (orderByComparator != null) {
8948 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8949
8950 if (orderByConditionFields.length > 0) {
8951 query.append(WHERE_AND);
8952 }
8953
8954 for (int i = 0; i < orderByConditionFields.length; i++) {
8955 query.append(_ORDER_BY_ENTITY_ALIAS);
8956 query.append(orderByConditionFields[i]);
8957
8958 if ((i + 1) < orderByConditionFields.length) {
8959 if (orderByComparator.isAscending() ^ previous) {
8960 query.append(WHERE_GREATER_THAN_HAS_NEXT);
8961 }
8962 else {
8963 query.append(WHERE_LESSER_THAN_HAS_NEXT);
8964 }
8965 }
8966 else {
8967 if (orderByComparator.isAscending() ^ previous) {
8968 query.append(WHERE_GREATER_THAN);
8969 }
8970 else {
8971 query.append(WHERE_LESSER_THAN);
8972 }
8973 }
8974 }
8975
8976 query.append(ORDER_BY_CLAUSE);
8977
8978 String[] orderByFields = orderByComparator.getOrderByFields();
8979
8980 for (int i = 0; i < orderByFields.length; i++) {
8981 query.append(_ORDER_BY_ENTITY_ALIAS);
8982 query.append(orderByFields[i]);
8983
8984 if ((i + 1) < orderByFields.length) {
8985 if (orderByComparator.isAscending() ^ previous) {
8986 query.append(ORDER_BY_ASC_HAS_NEXT);
8987 }
8988 else {
8989 query.append(ORDER_BY_DESC_HAS_NEXT);
8990 }
8991 }
8992 else {
8993 if (orderByComparator.isAscending() ^ previous) {
8994 query.append(ORDER_BY_ASC);
8995 }
8996 else {
8997 query.append(ORDER_BY_DESC);
8998 }
8999 }
9000 }
9001 }
9002
9003 else {
9004 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
9005 }
9006
9007 String sql = query.toString();
9008
9009 Query q = session.createQuery(sql);
9010
9011 q.setFirstResult(0);
9012 q.setMaxResults(2);
9013
9014 QueryPos qPos = QueryPos.getInstance(q);
9015
9016 qPos.add(threadId);
9017
9018 qPos.add(status);
9019
9020 if (orderByComparator != null) {
9021 Object[] values = orderByComparator.getOrderByConditionValues(mbMessage);
9022
9023 for (Object value : values) {
9024 qPos.add(value);
9025 }
9026 }
9027
9028 List<MBMessage> list = q.list();
9029
9030 if (list.size() == 2) {
9031 return list.get(1);
9032 }
9033 else {
9034 return null;
9035 }
9036 }
9037
9038
9047 public List<MBMessage> findByG_U_S(long groupId, long userId, int status)
9048 throws SystemException {
9049 return findByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
9050 QueryUtil.ALL_POS, null);
9051 }
9052
9053
9068 public List<MBMessage> findByG_U_S(long groupId, long userId, int status,
9069 int start, int end) throws SystemException {
9070 return findByG_U_S(groupId, userId, status, start, end, null);
9071 }
9072
9073
9089 public List<MBMessage> findByG_U_S(long groupId, long userId, int status,
9090 int start, int end, OrderByComparator orderByComparator)
9091 throws SystemException {
9092 FinderPath finderPath = null;
9093 Object[] finderArgs = null;
9094
9095 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9096 (orderByComparator == null)) {
9097 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S;
9098 finderArgs = new Object[] { groupId, userId, status };
9099 }
9100 else {
9101 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S;
9102 finderArgs = new Object[] {
9103 groupId, userId, status,
9104
9105 start, end, orderByComparator
9106 };
9107 }
9108
9109 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(finderPath,
9110 finderArgs, this);
9111
9112 if (list == null) {
9113 StringBundler query = null;
9114
9115 if (orderByComparator != null) {
9116 query = new StringBundler(5 +
9117 (orderByComparator.getOrderByFields().length * 3));
9118 }
9119 else {
9120 query = new StringBundler(5);
9121 }
9122
9123 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
9124
9125 query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
9126
9127 query.append(_FINDER_COLUMN_G_U_S_USERID_2);
9128
9129 query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
9130
9131 if (orderByComparator != null) {
9132 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9133 orderByComparator);
9134 }
9135
9136 else {
9137 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
9138 }
9139
9140 String sql = query.toString();
9141
9142 Session session = null;
9143
9144 try {
9145 session = openSession();
9146
9147 Query q = session.createQuery(sql);
9148
9149 QueryPos qPos = QueryPos.getInstance(q);
9150
9151 qPos.add(groupId);
9152
9153 qPos.add(userId);
9154
9155 qPos.add(status);
9156
9157 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
9158 end);
9159 }
9160 catch (Exception e) {
9161 throw processException(e);
9162 }
9163 finally {
9164 if (list == null) {
9165 FinderCacheUtil.removeResult(finderPath, finderArgs);
9166 }
9167 else {
9168 cacheResult(list);
9169
9170 FinderCacheUtil.putResult(finderPath, finderArgs, list);
9171 }
9172
9173 closeSession(session);
9174 }
9175 }
9176
9177 return list;
9178 }
9179
9180
9195 public MBMessage findByG_U_S_First(long groupId, long userId, int status,
9196 OrderByComparator orderByComparator)
9197 throws NoSuchMessageException, SystemException {
9198 List<MBMessage> list = findByG_U_S(groupId, userId, status, 0, 1,
9199 orderByComparator);
9200
9201 if (list.isEmpty()) {
9202 StringBundler msg = new StringBundler(8);
9203
9204 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9205
9206 msg.append("groupId=");
9207 msg.append(groupId);
9208
9209 msg.append(", userId=");
9210 msg.append(userId);
9211
9212 msg.append(", status=");
9213 msg.append(status);
9214
9215 msg.append(StringPool.CLOSE_CURLY_BRACE);
9216
9217 throw new NoSuchMessageException(msg.toString());
9218 }
9219 else {
9220 return list.get(0);
9221 }
9222 }
9223
9224
9239 public MBMessage findByG_U_S_Last(long groupId, long userId, int status,
9240 OrderByComparator orderByComparator)
9241 throws NoSuchMessageException, SystemException {
9242 int count = countByG_U_S(groupId, userId, status);
9243
9244 List<MBMessage> list = findByG_U_S(groupId, userId, status, count - 1,
9245 count, orderByComparator);
9246
9247 if (list.isEmpty()) {
9248 StringBundler msg = new StringBundler(8);
9249
9250 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9251
9252 msg.append("groupId=");
9253 msg.append(groupId);
9254
9255 msg.append(", userId=");
9256 msg.append(userId);
9257
9258 msg.append(", status=");
9259 msg.append(status);
9260
9261 msg.append(StringPool.CLOSE_CURLY_BRACE);
9262
9263 throw new NoSuchMessageException(msg.toString());
9264 }
9265 else {
9266 return list.get(0);
9267 }
9268 }
9269
9270
9286 public MBMessage[] findByG_U_S_PrevAndNext(long messageId, long groupId,
9287 long userId, int status, OrderByComparator orderByComparator)
9288 throws NoSuchMessageException, SystemException {
9289 MBMessage mbMessage = findByPrimaryKey(messageId);
9290
9291 Session session = null;
9292
9293 try {
9294 session = openSession();
9295
9296 MBMessage[] array = new MBMessageImpl[3];
9297
9298 array[0] = getByG_U_S_PrevAndNext(session, mbMessage, groupId,
9299 userId, status, orderByComparator, true);
9300
9301 array[1] = mbMessage;
9302
9303 array[2] = getByG_U_S_PrevAndNext(session, mbMessage, groupId,
9304 userId, status, orderByComparator, false);
9305
9306 return array;
9307 }
9308 catch (Exception e) {
9309 throw processException(e);
9310 }
9311 finally {
9312 closeSession(session);
9313 }
9314 }
9315
9316 protected MBMessage getByG_U_S_PrevAndNext(Session session,
9317 MBMessage mbMessage, long groupId, long userId, int status,
9318 OrderByComparator orderByComparator, boolean previous) {
9319 StringBundler query = null;
9320
9321 if (orderByComparator != null) {
9322 query = new StringBundler(6 +
9323 (orderByComparator.getOrderByFields().length * 6));
9324 }
9325 else {
9326 query = new StringBundler(3);
9327 }
9328
9329 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
9330
9331 query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
9332
9333 query.append(_FINDER_COLUMN_G_U_S_USERID_2);
9334
9335 query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
9336
9337 if (orderByComparator != null) {
9338 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9339
9340 if (orderByConditionFields.length > 0) {
9341 query.append(WHERE_AND);
9342 }
9343
9344 for (int i = 0; i < orderByConditionFields.length; i++) {
9345 query.append(_ORDER_BY_ENTITY_ALIAS);
9346 query.append(orderByConditionFields[i]);
9347
9348 if ((i + 1) < orderByConditionFields.length) {
9349 if (orderByComparator.isAscending() ^ previous) {
9350 query.append(WHERE_GREATER_THAN_HAS_NEXT);
9351 }
9352 else {
9353 query.append(WHERE_LESSER_THAN_HAS_NEXT);
9354 }
9355 }
9356 else {
9357 if (orderByComparator.isAscending() ^ previous) {
9358 query.append(WHERE_GREATER_THAN);
9359 }
9360 else {
9361 query.append(WHERE_LESSER_THAN);
9362 }
9363 }
9364 }
9365
9366 query.append(ORDER_BY_CLAUSE);
9367
9368 String[] orderByFields = orderByComparator.getOrderByFields();
9369
9370 for (int i = 0; i < orderByFields.length; i++) {
9371 query.append(_ORDER_BY_ENTITY_ALIAS);
9372 query.append(orderByFields[i]);
9373
9374 if ((i + 1) < orderByFields.length) {
9375 if (orderByComparator.isAscending() ^ previous) {
9376 query.append(ORDER_BY_ASC_HAS_NEXT);
9377 }
9378 else {
9379 query.append(ORDER_BY_DESC_HAS_NEXT);
9380 }
9381 }
9382 else {
9383 if (orderByComparator.isAscending() ^ previous) {
9384 query.append(ORDER_BY_ASC);
9385 }
9386 else {
9387 query.append(ORDER_BY_DESC);
9388 }
9389 }
9390 }
9391 }
9392
9393 else {
9394 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
9395 }
9396
9397 String sql = query.toString();
9398
9399 Query q = session.createQuery(sql);
9400
9401 q.setFirstResult(0);
9402 q.setMaxResults(2);
9403
9404 QueryPos qPos = QueryPos.getInstance(q);
9405
9406 qPos.add(groupId);
9407
9408 qPos.add(userId);
9409
9410 qPos.add(status);
9411
9412 if (orderByComparator != null) {
9413 Object[] values = orderByComparator.getOrderByConditionValues(mbMessage);
9414
9415 for (Object value : values) {
9416 qPos.add(value);
9417 }
9418 }
9419
9420 List<MBMessage> list = q.list();
9421
9422 if (list.size() == 2) {
9423 return list.get(1);
9424 }
9425 else {
9426 return null;
9427 }
9428 }
9429
9430
9439 public List<MBMessage> filterFindByG_U_S(long groupId, long userId,
9440 int status) throws SystemException {
9441 return filterFindByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
9442 QueryUtil.ALL_POS, null);
9443 }
9444
9445
9460 public List<MBMessage> filterFindByG_U_S(long groupId, long userId,
9461 int status, int start, int end) throws SystemException {
9462 return filterFindByG_U_S(groupId, userId, status, start, end, null);
9463 }
9464
9465
9481 public List<MBMessage> filterFindByG_U_S(long groupId, long userId,
9482 int status, int start, int end, OrderByComparator orderByComparator)
9483 throws SystemException {
9484 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9485 return findByG_U_S(groupId, userId, status, start, end,
9486 orderByComparator);
9487 }
9488
9489 StringBundler query = null;
9490
9491 if (orderByComparator != null) {
9492 query = new StringBundler(5 +
9493 (orderByComparator.getOrderByFields().length * 3));
9494 }
9495 else {
9496 query = new StringBundler(5);
9497 }
9498
9499 if (getDB().isSupportsInlineDistinct()) {
9500 query.append(_FILTER_SQL_SELECT_MBMESSAGE_WHERE);
9501 }
9502 else {
9503 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1);
9504 }
9505
9506 query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
9507
9508 query.append(_FINDER_COLUMN_G_U_S_USERID_2);
9509
9510 query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
9511
9512 if (!getDB().isSupportsInlineDistinct()) {
9513 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_2);
9514 }
9515
9516 if (orderByComparator != null) {
9517 if (getDB().isSupportsInlineDistinct()) {
9518 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9519 orderByComparator);
9520 }
9521 else {
9522 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
9523 orderByComparator);
9524 }
9525 }
9526
9527 else {
9528 if (getDB().isSupportsInlineDistinct()) {
9529 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
9530 }
9531 else {
9532 query.append(MBMessageModelImpl.ORDER_BY_SQL);
9533 }
9534 }
9535
9536 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9537 MBMessage.class.getName(),
9538 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9539
9540 Session session = null;
9541
9542 try {
9543 session = openSession();
9544
9545 SQLQuery q = session.createSQLQuery(sql);
9546
9547 if (getDB().isSupportsInlineDistinct()) {
9548 q.addEntity(_FILTER_ENTITY_ALIAS, MBMessageImpl.class);
9549 }
9550 else {
9551 q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class);
9552 }
9553
9554 QueryPos qPos = QueryPos.getInstance(q);
9555
9556 qPos.add(groupId);
9557
9558 qPos.add(userId);
9559
9560 qPos.add(status);
9561
9562 return (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end);
9563 }
9564 catch (Exception e) {
9565 throw processException(e);
9566 }
9567 finally {
9568 closeSession(session);
9569 }
9570 }
9571
9572
9584 public MBMessage[] filterFindByG_U_S_PrevAndNext(long messageId,
9585 long groupId, long userId, int status,
9586 OrderByComparator orderByComparator)
9587 throws NoSuchMessageException, SystemException {
9588 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9589 return findByG_U_S_PrevAndNext(messageId, groupId, userId, status,
9590 orderByComparator);
9591 }
9592
9593 MBMessage mbMessage = findByPrimaryKey(messageId);
9594
9595 Session session = null;
9596
9597 try {
9598 session = openSession();
9599
9600 MBMessage[] array = new MBMessageImpl[3];
9601
9602 array[0] = filterGetByG_U_S_PrevAndNext(session, mbMessage,
9603 groupId, userId, status, orderByComparator, true);
9604
9605 array[1] = mbMessage;
9606
9607 array[2] = filterGetByG_U_S_PrevAndNext(session, mbMessage,
9608 groupId, userId, status, orderByComparator, false);
9609
9610 return array;
9611 }
9612 catch (Exception e) {
9613 throw processException(e);
9614 }
9615 finally {
9616 closeSession(session);
9617 }
9618 }
9619
9620 protected MBMessage filterGetByG_U_S_PrevAndNext(Session session,
9621 MBMessage mbMessage, long groupId, long userId, int status,
9622 OrderByComparator orderByComparator, boolean previous) {
9623 StringBundler query = null;
9624
9625 if (orderByComparator != null) {
9626 query = new StringBundler(6 +
9627 (orderByComparator.getOrderByFields().length * 6));
9628 }
9629 else {
9630 query = new StringBundler(3);
9631 }
9632
9633 if (getDB().isSupportsInlineDistinct()) {
9634 query.append(_FILTER_SQL_SELECT_MBMESSAGE_WHERE);
9635 }
9636 else {
9637 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1);
9638 }
9639
9640 query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
9641
9642 query.append(_FINDER_COLUMN_G_U_S_USERID_2);
9643
9644 query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
9645
9646 if (!getDB().isSupportsInlineDistinct()) {
9647 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_2);
9648 }
9649
9650 if (orderByComparator != null) {
9651 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9652
9653 if (orderByConditionFields.length > 0) {
9654 query.append(WHERE_AND);
9655 }
9656
9657 for (int i = 0; i < orderByConditionFields.length; i++) {
9658 if (getDB().isSupportsInlineDistinct()) {
9659 query.append(_ORDER_BY_ENTITY_ALIAS);
9660 }
9661 else {
9662 query.append(_ORDER_BY_ENTITY_TABLE);
9663 }
9664
9665 query.append(orderByConditionFields[i]);
9666
9667 if ((i + 1) < orderByConditionFields.length) {
9668 if (orderByComparator.isAscending() ^ previous) {
9669 query.append(WHERE_GREATER_THAN_HAS_NEXT);
9670 }
9671 else {
9672 query.append(WHERE_LESSER_THAN_HAS_NEXT);
9673 }
9674 }
9675 else {
9676 if (orderByComparator.isAscending() ^ previous) {
9677 query.append(WHERE_GREATER_THAN);
9678 }
9679 else {
9680 query.append(WHERE_LESSER_THAN);
9681 }
9682 }
9683 }
9684
9685 query.append(ORDER_BY_CLAUSE);
9686
9687 String[] orderByFields = orderByComparator.getOrderByFields();
9688
9689 for (int i = 0; i < orderByFields.length; i++) {
9690 if (getDB().isSupportsInlineDistinct()) {
9691 query.append(_ORDER_BY_ENTITY_ALIAS);
9692 }
9693 else {
9694 query.append(_ORDER_BY_ENTITY_TABLE);
9695 }
9696
9697 query.append(orderByFields[i]);
9698
9699 if ((i + 1) < orderByFields.length) {
9700 if (orderByComparator.isAscending() ^ previous) {
9701 query.append(ORDER_BY_ASC_HAS_NEXT);
9702 }
9703 else {
9704 query.append(ORDER_BY_DESC_HAS_NEXT);
9705 }
9706 }
9707 else {
9708 if (orderByComparator.isAscending() ^ previous) {
9709 query.append(ORDER_BY_ASC);
9710 }
9711 else {
9712 query.append(ORDER_BY_DESC);
9713 }
9714 }
9715 }
9716 }
9717
9718 else {
9719 if (getDB().isSupportsInlineDistinct()) {
9720 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
9721 }
9722 else {
9723 query.append(MBMessageModelImpl.ORDER_BY_SQL);
9724 }
9725 }
9726
9727 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9728 MBMessage.class.getName(),
9729 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9730
9731 SQLQuery q = session.createSQLQuery(sql);
9732
9733 q.setFirstResult(0);
9734 q.setMaxResults(2);
9735
9736 if (getDB().isSupportsInlineDistinct()) {
9737 q.addEntity(_FILTER_ENTITY_ALIAS, MBMessageImpl.class);
9738 }
9739 else {
9740 q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class);
9741 }
9742
9743 QueryPos qPos = QueryPos.getInstance(q);
9744
9745 qPos.add(groupId);
9746
9747 qPos.add(userId);
9748
9749 qPos.add(status);
9750
9751 if (orderByComparator != null) {
9752 Object[] values = orderByComparator.getOrderByConditionValues(mbMessage);
9753
9754 for (Object value : values) {
9755 qPos.add(value);
9756 }
9757 }
9758
9759 List<MBMessage> list = q.list();
9760
9761 if (list.size() == 2) {
9762 return list.get(1);
9763 }
9764 else {
9765 return null;
9766 }
9767 }
9768
9769
9778 public List<MBMessage> findByG_C_T(long groupId, long categoryId,
9779 long threadId) throws SystemException {
9780 return findByG_C_T(groupId, categoryId, threadId, QueryUtil.ALL_POS,
9781 QueryUtil.ALL_POS, null);
9782 }
9783
9784
9799 public List<MBMessage> findByG_C_T(long groupId, long categoryId,
9800 long threadId, int start, int end) throws SystemException {
9801 return findByG_C_T(groupId, categoryId, threadId, start, end, null);
9802 }
9803
9804
9820 public List<MBMessage> findByG_C_T(long groupId, long categoryId,
9821 long threadId, int start, int end, OrderByComparator orderByComparator)
9822 throws SystemException {
9823 FinderPath finderPath = null;
9824 Object[] finderArgs = null;
9825
9826 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9827 (orderByComparator == null)) {
9828 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T;
9829 finderArgs = new Object[] { groupId, categoryId, threadId };
9830 }
9831 else {
9832 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T;
9833 finderArgs = new Object[] {
9834 groupId, categoryId, threadId,
9835
9836 start, end, orderByComparator
9837 };
9838 }
9839
9840 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(finderPath,
9841 finderArgs, this);
9842
9843 if (list == null) {
9844 StringBundler query = null;
9845
9846 if (orderByComparator != null) {
9847 query = new StringBundler(5 +
9848 (orderByComparator.getOrderByFields().length * 3));
9849 }
9850 else {
9851 query = new StringBundler(5);
9852 }
9853
9854 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
9855
9856 query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
9857
9858 query.append(_FINDER_COLUMN_G_C_T_CATEGORYID_2);
9859
9860 query.append(_FINDER_COLUMN_G_C_T_THREADID_2);
9861
9862 if (orderByComparator != null) {
9863 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9864 orderByComparator);
9865 }
9866
9867 else {
9868 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
9869 }
9870
9871 String sql = query.toString();
9872
9873 Session session = null;
9874
9875 try {
9876 session = openSession();
9877
9878 Query q = session.createQuery(sql);
9879
9880 QueryPos qPos = QueryPos.getInstance(q);
9881
9882 qPos.add(groupId);
9883
9884 qPos.add(categoryId);
9885
9886 qPos.add(threadId);
9887
9888 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
9889 end);
9890 }
9891 catch (Exception e) {
9892 throw processException(e);
9893 }
9894 finally {
9895 if (list == null) {
9896 FinderCacheUtil.removeResult(finderPath, finderArgs);
9897 }
9898 else {
9899 cacheResult(list);
9900
9901 FinderCacheUtil.putResult(finderPath, finderArgs, list);
9902 }
9903
9904 closeSession(session);
9905 }
9906 }
9907
9908 return list;
9909 }
9910
9911
9926 public MBMessage findByG_C_T_First(long groupId, long categoryId,
9927 long threadId, OrderByComparator orderByComparator)
9928 throws NoSuchMessageException, SystemException {
9929 List<MBMessage> list = findByG_C_T(groupId, categoryId, threadId, 0, 1,
9930 orderByComparator);
9931
9932 if (list.isEmpty()) {
9933 StringBundler msg = new StringBundler(8);
9934
9935 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9936
9937 msg.append("groupId=");
9938 msg.append(groupId);
9939
9940 msg.append(", categoryId=");
9941 msg.append(categoryId);
9942
9943 msg.append(", threadId=");
9944 msg.append(threadId);
9945
9946 msg.append(StringPool.CLOSE_CURLY_BRACE);
9947
9948 throw new NoSuchMessageException(msg.toString());
9949 }
9950 else {
9951 return list.get(0);
9952 }
9953 }
9954
9955
9970 public MBMessage findByG_C_T_Last(long groupId, long categoryId,
9971 long threadId, OrderByComparator orderByComparator)
9972 throws NoSuchMessageException, SystemException {
9973 int count = countByG_C_T(groupId, categoryId, threadId);
9974
9975 List<MBMessage> list = findByG_C_T(groupId, categoryId, threadId,
9976 count - 1, count, orderByComparator);
9977
9978 if (list.isEmpty()) {
9979 StringBundler msg = new StringBundler(8);
9980
9981 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9982
9983 msg.append("groupId=");
9984 msg.append(groupId);
9985
9986 msg.append(", categoryId=");
9987 msg.append(categoryId);
9988
9989 msg.append(", threadId=");
9990 msg.append(threadId);
9991
9992 msg.append(StringPool.CLOSE_CURLY_BRACE);
9993
9994 throw new NoSuchMessageException(msg.toString());
9995 }
9996 else {
9997 return list.get(0);
9998 }
9999 }
10000
10001
10017 public MBMessage[] findByG_C_T_PrevAndNext(long messageId, long groupId,
10018 long categoryId, long threadId, OrderByComparator orderByComparator)
10019 throws NoSuchMessageException, SystemException {
10020 MBMessage mbMessage = findByPrimaryKey(messageId);
10021
10022 Session session = null;
10023
10024 try {
10025 session = openSession();
10026
10027 MBMessage[] array = new MBMessageImpl[3];
10028
10029 array[0] = getByG_C_T_PrevAndNext(session, mbMessage, groupId,
10030 categoryId, threadId, orderByComparator, true);
10031
10032 array[1] = mbMessage;
10033
10034 array[2] = getByG_C_T_PrevAndNext(session, mbMessage, groupId,
10035 categoryId, threadId, orderByComparator, false);
10036
10037 return array;
10038 }
10039 catch (Exception e) {
10040 throw processException(e);
10041 }
10042 finally {
10043 closeSession(session);
10044 }
10045 }
10046
10047 protected MBMessage getByG_C_T_PrevAndNext(Session session,
10048 MBMessage mbMessage, long groupId, long categoryId, long threadId,
10049 OrderByComparator orderByComparator, boolean previous) {
10050 StringBundler query = null;
10051
10052 if (orderByComparator != null) {
10053 query = new StringBundler(6 +
10054 (orderByComparator.getOrderByFields().length * 6));
10055 }
10056 else {
10057 query = new StringBundler(3);
10058 }
10059
10060 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
10061
10062 query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
10063
10064 query.append(_FINDER_COLUMN_G_C_T_CATEGORYID_2);
10065
10066 query.append(_FINDER_COLUMN_G_C_T_THREADID_2);
10067
10068 if (orderByComparator != null) {
10069 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10070
10071 if (orderByConditionFields.length > 0) {
10072 query.append(WHERE_AND);
10073 }
10074
10075 for (int i = 0; i < orderByConditionFields.length; i++) {
10076 query.append(_ORDER_BY_ENTITY_ALIAS);
10077 query.append(orderByConditionFields[i]);
10078
10079 if ((i + 1) < orderByConditionFields.length) {
10080 if (orderByComparator.isAscending() ^ previous) {
10081 query.append(WHERE_GREATER_THAN_HAS_NEXT);
10082 }
10083 else {
10084 query.append(WHERE_LESSER_THAN_HAS_NEXT);
10085 }
10086 }
10087 else {
10088 if (orderByComparator.isAscending() ^ previous) {
10089 query.append(WHERE_GREATER_THAN);
10090 }
10091 else {
10092 query.append(WHERE_LESSER_THAN);
10093 }
10094 }
10095 }
10096
10097 query.append(ORDER_BY_CLAUSE);
10098
10099 String[] orderByFields = orderByComparator.getOrderByFields();
10100
10101 for (int i = 0; i < orderByFields.length; i++) {
10102 query.append(_ORDER_BY_ENTITY_ALIAS);
10103 query.append(orderByFields[i]);
10104
10105 if ((i + 1) < orderByFields.length) {
10106 if (orderByComparator.isAscending() ^ previous) {
10107 query.append(ORDER_BY_ASC_HAS_NEXT);
10108 }
10109 else {
10110 query.append(ORDER_BY_DESC_HAS_NEXT);
10111 }
10112 }
10113 else {
10114 if (orderByComparator.isAscending() ^ previous) {
10115 query.append(ORDER_BY_ASC);
10116 }
10117 else {
10118 query.append(ORDER_BY_DESC);
10119 }
10120 }
10121 }
10122 }
10123
10124 else {
10125 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
10126 }
10127
10128 String sql = query.toString();
10129
10130 Query q = session.createQuery(sql);
10131
10132 q.setFirstResult(0);
10133 q.setMaxResults(2);
10134
10135 QueryPos qPos = QueryPos.getInstance(q);
10136
10137 qPos.add(groupId);
10138
10139 qPos.add(categoryId);
10140
10141 qPos.add(threadId);
10142
10143 if (orderByComparator != null) {
10144 Object[] values = orderByComparator.getOrderByConditionValues(mbMessage);
10145
10146 for (Object value : values) {
10147 qPos.add(value);
10148 }
10149 }
10150
10151 List<MBMessage> list = q.list();
10152
10153 if (list.size() == 2) {
10154 return list.get(1);
10155 }
10156 else {
10157 return null;
10158 }
10159 }
10160
10161
10170 public List<MBMessage> filterFindByG_C_T(long groupId, long categoryId,
10171 long threadId) throws SystemException {
10172 return filterFindByG_C_T(groupId, categoryId, threadId,
10173 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
10174 }
10175
10176
10191 public List<MBMessage> filterFindByG_C_T(long groupId, long categoryId,
10192 long threadId, int start, int end) throws SystemException {
10193 return filterFindByG_C_T(groupId, categoryId, threadId, start, end, null);
10194 }
10195
10196
10212 public List<MBMessage> filterFindByG_C_T(long groupId, long categoryId,
10213 long threadId, int start, int end, OrderByComparator orderByComparator)
10214 throws SystemException {
10215 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10216 return findByG_C_T(groupId, categoryId, threadId, start, end,
10217 orderByComparator);
10218 }
10219
10220 StringBundler query = null;
10221
10222 if (orderByComparator != null) {
10223 query = new StringBundler(5 +
10224 (orderByComparator.getOrderByFields().length * 3));
10225 }
10226 else {
10227 query = new StringBundler(5);
10228 }
10229
10230 if (getDB().isSupportsInlineDistinct()) {
10231 query.append(_FILTER_SQL_SELECT_MBMESSAGE_WHERE);
10232 }
10233 else {
10234 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1);
10235 }
10236
10237 query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
10238
10239 query.append(_FINDER_COLUMN_G_C_T_CATEGORYID_2);
10240
10241 query.append(_FINDER_COLUMN_G_C_T_THREADID_2);
10242
10243 if (!getDB().isSupportsInlineDistinct()) {
10244 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_2);
10245 }
10246
10247 if (orderByComparator != null) {
10248 if (getDB().isSupportsInlineDistinct()) {
10249 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10250 orderByComparator);
10251 }
10252 else {
10253 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10254 orderByComparator);
10255 }
10256 }
10257
10258 else {
10259 if (getDB().isSupportsInlineDistinct()) {
10260 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
10261 }
10262 else {
10263 query.append(MBMessageModelImpl.ORDER_BY_SQL);
10264 }
10265 }
10266
10267 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10268 MBMessage.class.getName(),
10269 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10270
10271 Session session = null;
10272
10273 try {
10274 session = openSession();
10275
10276 SQLQuery q = session.createSQLQuery(sql);
10277
10278 if (getDB().isSupportsInlineDistinct()) {
10279 q.addEntity(_FILTER_ENTITY_ALIAS, MBMessageImpl.class);
10280 }
10281 else {
10282 q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class);
10283 }
10284
10285 QueryPos qPos = QueryPos.getInstance(q);
10286
10287 qPos.add(groupId);
10288
10289 qPos.add(categoryId);
10290
10291 qPos.add(threadId);
10292
10293 return (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end);
10294 }
10295 catch (Exception e) {
10296 throw processException(e);
10297 }
10298 finally {
10299 closeSession(session);
10300 }
10301 }
10302
10303
10315 public MBMessage[] filterFindByG_C_T_PrevAndNext(long messageId,
10316 long groupId, long categoryId, long threadId,
10317 OrderByComparator orderByComparator)
10318 throws NoSuchMessageException, SystemException {
10319 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10320 return findByG_C_T_PrevAndNext(messageId, groupId, categoryId,
10321 threadId, orderByComparator);
10322 }
10323
10324 MBMessage mbMessage = findByPrimaryKey(messageId);
10325
10326 Session session = null;
10327
10328 try {
10329 session = openSession();
10330
10331 MBMessage[] array = new MBMessageImpl[3];
10332
10333 array[0] = filterGetByG_C_T_PrevAndNext(session, mbMessage,
10334 groupId, categoryId, threadId, orderByComparator, true);
10335
10336 array[1] = mbMessage;
10337
10338 array[2] = filterGetByG_C_T_PrevAndNext(session, mbMessage,
10339 groupId, categoryId, threadId, orderByComparator, false);
10340
10341 return array;
10342 }
10343 catch (Exception e) {
10344 throw processException(e);
10345 }
10346 finally {
10347 closeSession(session);
10348 }
10349 }
10350
10351 protected MBMessage filterGetByG_C_T_PrevAndNext(Session session,
10352 MBMessage mbMessage, long groupId, long categoryId, long threadId,
10353 OrderByComparator orderByComparator, boolean previous) {
10354 StringBundler query = null;
10355
10356 if (orderByComparator != null) {
10357 query = new StringBundler(6 +
10358 (orderByComparator.getOrderByFields().length * 6));
10359 }
10360 else {
10361 query = new StringBundler(3);
10362 }
10363
10364 if (getDB().isSupportsInlineDistinct()) {
10365 query.append(_FILTER_SQL_SELECT_MBMESSAGE_WHERE);
10366 }
10367 else {
10368 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1);
10369 }
10370
10371 query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
10372
10373 query.append(_FINDER_COLUMN_G_C_T_CATEGORYID_2);
10374
10375 query.append(_FINDER_COLUMN_G_C_T_THREADID_2);
10376
10377 if (!getDB().isSupportsInlineDistinct()) {
10378 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_2);
10379 }
10380
10381 if (orderByComparator != null) {
10382 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10383
10384 if (orderByConditionFields.length > 0) {
10385 query.append(WHERE_AND);
10386 }
10387
10388 for (int i = 0; i < orderByConditionFields.length; i++) {
10389 if (getDB().isSupportsInlineDistinct()) {
10390 query.append(_ORDER_BY_ENTITY_ALIAS);
10391 }
10392 else {
10393 query.append(_ORDER_BY_ENTITY_TABLE);
10394 }
10395
10396 query.append(orderByConditionFields[i]);
10397
10398 if ((i + 1) < orderByConditionFields.length) {
10399 if (orderByComparator.isAscending() ^ previous) {
10400 query.append(WHERE_GREATER_THAN_HAS_NEXT);
10401 }
10402 else {
10403 query.append(WHERE_LESSER_THAN_HAS_NEXT);
10404 }
10405 }
10406 else {
10407 if (orderByComparator.isAscending() ^ previous) {
10408 query.append(WHERE_GREATER_THAN);
10409 }
10410 else {
10411 query.append(WHERE_LESSER_THAN);
10412 }
10413 }
10414 }
10415
10416 query.append(ORDER_BY_CLAUSE);
10417
10418 String[] orderByFields = orderByComparator.getOrderByFields();
10419
10420 for (int i = 0; i < orderByFields.length; i++) {
10421 if (getDB().isSupportsInlineDistinct()) {
10422 query.append(_ORDER_BY_ENTITY_ALIAS);
10423 }
10424 else {
10425 query.append(_ORDER_BY_ENTITY_TABLE);
10426 }
10427
10428 query.append(orderByFields[i]);
10429
10430 if ((i + 1) < orderByFields.length) {
10431 if (orderByComparator.isAscending() ^ previous) {
10432 query.append(ORDER_BY_ASC_HAS_NEXT);
10433 }
10434 else {
10435 query.append(ORDER_BY_DESC_HAS_NEXT);
10436 }
10437 }
10438 else {
10439 if (orderByComparator.isAscending() ^ previous) {
10440 query.append(ORDER_BY_ASC);
10441 }
10442 else {
10443 query.append(ORDER_BY_DESC);
10444 }
10445 }
10446 }
10447 }
10448
10449 else {
10450 if (getDB().isSupportsInlineDistinct()) {
10451 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
10452 }
10453 else {
10454 query.append(MBMessageModelImpl.ORDER_BY_SQL);
10455 }
10456 }
10457
10458 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10459 MBMessage.class.getName(),
10460 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10461
10462 SQLQuery q = session.createSQLQuery(sql);
10463
10464 q.setFirstResult(0);
10465 q.setMaxResults(2);
10466
10467 if (getDB().isSupportsInlineDistinct()) {
10468 q.addEntity(_FILTER_ENTITY_ALIAS, MBMessageImpl.class);
10469 }
10470 else {
10471 q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class);
10472 }
10473
10474 QueryPos qPos = QueryPos.getInstance(q);
10475
10476 qPos.add(groupId);
10477
10478 qPos.add(categoryId);
10479
10480 qPos.add(threadId);
10481
10482 if (orderByComparator != null) {
10483 Object[] values = orderByComparator.getOrderByConditionValues(mbMessage);
10484
10485 for (Object value : values) {
10486 qPos.add(value);
10487 }
10488 }
10489
10490 List<MBMessage> list = q.list();
10491
10492 if (list.size() == 2) {
10493 return list.get(1);
10494 }
10495 else {
10496 return null;
10497 }
10498 }
10499
10500
10509 public List<MBMessage> findByG_C_S(long groupId, long categoryId, int status)
10510 throws SystemException {
10511 return findByG_C_S(groupId, categoryId, status, QueryUtil.ALL_POS,
10512 QueryUtil.ALL_POS, null);
10513 }
10514
10515
10530 public List<MBMessage> findByG_C_S(long groupId, long categoryId,
10531 int status, int start, int end) throws SystemException {
10532 return findByG_C_S(groupId, categoryId, status, start, end, null);
10533 }
10534
10535
10551 public List<MBMessage> findByG_C_S(long groupId, long categoryId,
10552 int status, int start, int end, OrderByComparator orderByComparator)
10553 throws SystemException {
10554 FinderPath finderPath = null;
10555 Object[] finderArgs = null;
10556
10557 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10558 (orderByComparator == null)) {
10559 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_S;
10560 finderArgs = new Object[] { groupId, categoryId, status };
10561 }
10562 else {
10563 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_S;
10564 finderArgs = new Object[] {
10565 groupId, categoryId, status,
10566
10567 start, end, orderByComparator
10568 };
10569 }
10570
10571 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(finderPath,
10572 finderArgs, this);
10573
10574 if (list == null) {
10575 StringBundler query = null;
10576
10577 if (orderByComparator != null) {
10578 query = new StringBundler(5 +
10579 (orderByComparator.getOrderByFields().length * 3));
10580 }
10581 else {
10582 query = new StringBundler(5);
10583 }
10584
10585 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
10586
10587 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
10588
10589 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
10590
10591 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
10592
10593 if (orderByComparator != null) {
10594 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10595 orderByComparator);
10596 }
10597
10598 else {
10599 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
10600 }
10601
10602 String sql = query.toString();
10603
10604 Session session = null;
10605
10606 try {
10607 session = openSession();
10608
10609 Query q = session.createQuery(sql);
10610
10611 QueryPos qPos = QueryPos.getInstance(q);
10612
10613 qPos.add(groupId);
10614
10615 qPos.add(categoryId);
10616
10617 qPos.add(status);
10618
10619 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
10620 end);
10621 }
10622 catch (Exception e) {
10623 throw processException(e);
10624 }
10625 finally {
10626 if (list == null) {
10627 FinderCacheUtil.removeResult(finderPath, finderArgs);
10628 }
10629 else {
10630 cacheResult(list);
10631
10632 FinderCacheUtil.putResult(finderPath, finderArgs, list);
10633 }
10634
10635 closeSession(session);
10636 }
10637 }
10638
10639 return list;
10640 }
10641
10642
10657 public MBMessage findByG_C_S_First(long groupId, long categoryId,
10658 int status, OrderByComparator orderByComparator)
10659 throws NoSuchMessageException, SystemException {
10660 List<MBMessage> list = findByG_C_S(groupId, categoryId, status, 0, 1,
10661 orderByComparator);
10662
10663 if (list.isEmpty()) {
10664 StringBundler msg = new StringBundler(8);
10665
10666 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10667
10668 msg.append("groupId=");
10669 msg.append(groupId);
10670
10671 msg.append(", categoryId=");
10672 msg.append(categoryId);
10673
10674 msg.append(", status=");
10675 msg.append(status);
10676
10677 msg.append(StringPool.CLOSE_CURLY_BRACE);
10678
10679 throw new NoSuchMessageException(msg.toString());
10680 }
10681 else {
10682 return list.get(0);
10683 }
10684 }
10685
10686
10701 public MBMessage findByG_C_S_Last(long groupId, long categoryId,
10702 int status, OrderByComparator orderByComparator)
10703 throws NoSuchMessageException, SystemException {
10704 int count = countByG_C_S(groupId, categoryId, status);
10705
10706 List<MBMessage> list = findByG_C_S(groupId, categoryId, status,
10707 count - 1, count, orderByComparator);
10708
10709 if (list.isEmpty()) {
10710 StringBundler msg = new StringBundler(8);
10711
10712 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10713
10714 msg.append("groupId=");
10715 msg.append(groupId);
10716
10717 msg.append(", categoryId=");
10718 msg.append(categoryId);
10719
10720 msg.append(", status=");
10721 msg.append(status);
10722
10723 msg.append(StringPool.CLOSE_CURLY_BRACE);
10724
10725 throw new NoSuchMessageException(msg.toString());
10726 }
10727 else {
10728 return list.get(0);
10729 }
10730 }
10731
10732
10748 public MBMessage[] findByG_C_S_PrevAndNext(long messageId, long groupId,
10749 long categoryId, int status, OrderByComparator orderByComparator)
10750 throws NoSuchMessageException, SystemException {
10751 MBMessage mbMessage = findByPrimaryKey(messageId);
10752
10753 Session session = null;
10754
10755 try {
10756 session = openSession();
10757
10758 MBMessage[] array = new MBMessageImpl[3];
10759
10760 array[0] = getByG_C_S_PrevAndNext(session, mbMessage, groupId,
10761 categoryId, status, orderByComparator, true);
10762
10763 array[1] = mbMessage;
10764
10765 array[2] = getByG_C_S_PrevAndNext(session, mbMessage, groupId,
10766 categoryId, status, orderByComparator, false);
10767
10768 return array;
10769 }
10770 catch (Exception e) {
10771 throw processException(e);
10772 }
10773 finally {
10774 closeSession(session);
10775 }
10776 }
10777
10778 protected MBMessage getByG_C_S_PrevAndNext(Session session,
10779 MBMessage mbMessage, long groupId, long categoryId, int status,
10780 OrderByComparator orderByComparator, boolean previous) {
10781 StringBundler query = null;
10782
10783 if (orderByComparator != null) {
10784 query = new StringBundler(6 +
10785 (orderByComparator.getOrderByFields().length * 6));
10786 }
10787 else {
10788 query = new StringBundler(3);
10789 }
10790
10791 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
10792
10793 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
10794
10795 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
10796
10797 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
10798
10799 if (orderByComparator != null) {
10800 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10801
10802 if (orderByConditionFields.length > 0) {
10803 query.append(WHERE_AND);
10804 }
10805
10806 for (int i = 0; i < orderByConditionFields.length; i++) {
10807 query.append(_ORDER_BY_ENTITY_ALIAS);
10808 query.append(orderByConditionFields[i]);
10809
10810 if ((i + 1) < orderByConditionFields.length) {
10811 if (orderByComparator.isAscending() ^ previous) {
10812 query.append(WHERE_GREATER_THAN_HAS_NEXT);
10813 }
10814 else {
10815 query.append(WHERE_LESSER_THAN_HAS_NEXT);
10816 }
10817 }
10818 else {
10819 if (orderByComparator.isAscending() ^ previous) {
10820 query.append(WHERE_GREATER_THAN);
10821 }
10822 else {
10823 query.append(WHERE_LESSER_THAN);
10824 }
10825 }
10826 }
10827
10828 query.append(ORDER_BY_CLAUSE);
10829
10830 String[] orderByFields = orderByComparator.getOrderByFields();
10831
10832 for (int i = 0; i < orderByFields.length; i++) {
10833 query.append(_ORDER_BY_ENTITY_ALIAS);
10834 query.append(orderByFields[i]);
10835
10836 if ((i + 1) < orderByFields.length) {
10837 if (orderByComparator.isAscending() ^ previous) {
10838 query.append(ORDER_BY_ASC_HAS_NEXT);
10839 }
10840 else {
10841 query.append(ORDER_BY_DESC_HAS_NEXT);
10842 }
10843 }
10844 else {
10845 if (orderByComparator.isAscending() ^ previous) {
10846 query.append(ORDER_BY_ASC);
10847 }
10848 else {
10849 query.append(ORDER_BY_DESC);
10850 }
10851 }
10852 }
10853 }
10854
10855 else {
10856 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
10857 }
10858
10859 String sql = query.toString();
10860
10861 Query q = session.createQuery(sql);
10862
10863 q.setFirstResult(0);
10864 q.setMaxResults(2);
10865
10866 QueryPos qPos = QueryPos.getInstance(q);
10867
10868 qPos.add(groupId);
10869
10870 qPos.add(categoryId);
10871
10872 qPos.add(status);
10873
10874 if (orderByComparator != null) {
10875 Object[] values = orderByComparator.getOrderByConditionValues(mbMessage);
10876
10877 for (Object value : values) {
10878 qPos.add(value);
10879 }
10880 }
10881
10882 List<MBMessage> list = q.list();
10883
10884 if (list.size() == 2) {
10885 return list.get(1);
10886 }
10887 else {
10888 return null;
10889 }
10890 }
10891
10892
10901 public List<MBMessage> filterFindByG_C_S(long groupId, long categoryId,
10902 int status) throws SystemException {
10903 return filterFindByG_C_S(groupId, categoryId, status,
10904 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
10905 }
10906
10907
10922 public List<MBMessage> filterFindByG_C_S(long groupId, long categoryId,
10923 int status, int start, int end) throws SystemException {
10924 return filterFindByG_C_S(groupId, categoryId, status, start, end, null);
10925 }
10926
10927
10943 public List<MBMessage> filterFindByG_C_S(long groupId, long categoryId,
10944 int status, int start, int end, OrderByComparator orderByComparator)
10945 throws SystemException {
10946 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10947 return findByG_C_S(groupId, categoryId, status, start, end,
10948 orderByComparator);
10949 }
10950
10951 StringBundler query = null;
10952
10953 if (orderByComparator != null) {
10954 query = new StringBundler(5 +
10955 (orderByComparator.getOrderByFields().length * 3));
10956 }
10957 else {
10958 query = new StringBundler(5);
10959 }
10960
10961 if (getDB().isSupportsInlineDistinct()) {
10962 query.append(_FILTER_SQL_SELECT_MBMESSAGE_WHERE);
10963 }
10964 else {
10965 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1);
10966 }
10967
10968 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
10969
10970 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
10971
10972 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
10973
10974 if (!getDB().isSupportsInlineDistinct()) {
10975 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_2);
10976 }
10977
10978 if (orderByComparator != null) {
10979 if (getDB().isSupportsInlineDistinct()) {
10980 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10981 orderByComparator);
10982 }
10983 else {
10984 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10985 orderByComparator);
10986 }
10987 }
10988
10989 else {
10990 if (getDB().isSupportsInlineDistinct()) {
10991 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
10992 }
10993 else {
10994 query.append(MBMessageModelImpl.ORDER_BY_SQL);
10995 }
10996 }
10997
10998 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10999 MBMessage.class.getName(),
11000 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11001
11002 Session session = null;
11003
11004 try {
11005 session = openSession();
11006
11007 SQLQuery q = session.createSQLQuery(sql);
11008
11009 if (getDB().isSupportsInlineDistinct()) {
11010 q.addEntity(_FILTER_ENTITY_ALIAS, MBMessageImpl.class);
11011 }
11012 else {
11013 q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class);
11014 }
11015
11016 QueryPos qPos = QueryPos.getInstance(q);
11017
11018 qPos.add(groupId);
11019
11020 qPos.add(categoryId);
11021
11022 qPos.add(status);
11023
11024 return (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end);
11025 }
11026 catch (Exception e) {
11027 throw processException(e);
11028 }
11029 finally {
11030 closeSession(session);
11031 }
11032 }
11033
11034
11046 public MBMessage[] filterFindByG_C_S_PrevAndNext(long messageId,
11047 long groupId, long categoryId, int status,
11048 OrderByComparator orderByComparator)
11049 throws NoSuchMessageException, SystemException {
11050 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11051 return findByG_C_S_PrevAndNext(messageId, groupId, categoryId,
11052 status, orderByComparator);
11053 }
11054
11055 MBMessage mbMessage = findByPrimaryKey(messageId);
11056
11057 Session session = null;
11058
11059 try {
11060 session = openSession();
11061
11062 MBMessage[] array = new MBMessageImpl[3];
11063
11064 array[0] = filterGetByG_C_S_PrevAndNext(session, mbMessage,
11065 groupId, categoryId, status, orderByComparator, true);
11066
11067 array[1] = mbMessage;
11068
11069 array[2] = filterGetByG_C_S_PrevAndNext(session, mbMessage,
11070 groupId, categoryId, status, orderByComparator, false);
11071
11072 return array;
11073 }
11074 catch (Exception e) {
11075 throw processException(e);
11076 }
11077 finally {
11078 closeSession(session);
11079 }
11080 }
11081
11082 protected MBMessage filterGetByG_C_S_PrevAndNext(Session session,
11083 MBMessage mbMessage, long groupId, long categoryId, int status,
11084 OrderByComparator orderByComparator, boolean previous) {
11085 StringBundler query = null;
11086
11087 if (orderByComparator != null) {
11088 query = new StringBundler(6 +
11089 (orderByComparator.getOrderByFields().length * 6));
11090 }
11091 else {
11092 query = new StringBundler(3);
11093 }
11094
11095 if (getDB().isSupportsInlineDistinct()) {
11096 query.append(_FILTER_SQL_SELECT_MBMESSAGE_WHERE);
11097 }
11098 else {
11099 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1);
11100 }
11101
11102 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
11103
11104 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
11105
11106 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
11107
11108 if (!getDB().isSupportsInlineDistinct()) {
11109 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_2);
11110 }
11111
11112 if (orderByComparator != null) {
11113 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11114
11115 if (orderByConditionFields.length > 0) {
11116 query.append(WHERE_AND);
11117 }
11118
11119 for (int i = 0; i < orderByConditionFields.length; i++) {
11120 if (getDB().isSupportsInlineDistinct()) {
11121 query.append(_ORDER_BY_ENTITY_ALIAS);
11122 }
11123 else {
11124 query.append(_ORDER_BY_ENTITY_TABLE);
11125 }
11126
11127 query.append(orderByConditionFields[i]);
11128
11129 if ((i + 1) < orderByConditionFields.length) {
11130 if (orderByComparator.isAscending() ^ previous) {
11131 query.append(WHERE_GREATER_THAN_HAS_NEXT);
11132 }
11133 else {
11134 query.append(WHERE_LESSER_THAN_HAS_NEXT);
11135 }
11136 }
11137 else {
11138 if (orderByComparator.isAscending() ^ previous) {
11139 query.append(WHERE_GREATER_THAN);
11140 }
11141 else {
11142 query.append(WHERE_LESSER_THAN);
11143 }
11144 }
11145 }
11146
11147 query.append(ORDER_BY_CLAUSE);
11148
11149 String[] orderByFields = orderByComparator.getOrderByFields();
11150
11151 for (int i = 0; i < orderByFields.length; i++) {
11152 if (getDB().isSupportsInlineDistinct()) {
11153 query.append(_ORDER_BY_ENTITY_ALIAS);
11154 }
11155 else {
11156 query.append(_ORDER_BY_ENTITY_TABLE);
11157 }
11158
11159 query.append(orderByFields[i]);
11160
11161 if ((i + 1) < orderByFields.length) {
11162 if (orderByComparator.isAscending() ^ previous) {
11163 query.append(ORDER_BY_ASC_HAS_NEXT);
11164 }
11165 else {
11166 query.append(ORDER_BY_DESC_HAS_NEXT);
11167 }
11168 }
11169 else {
11170 if (orderByComparator.isAscending() ^ previous) {
11171 query.append(ORDER_BY_ASC);
11172 }
11173 else {
11174 query.append(ORDER_BY_DESC);
11175 }
11176 }
11177 }
11178 }
11179
11180 else {
11181 if (getDB().isSupportsInlineDistinct()) {
11182 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
11183 }
11184 else {
11185 query.append(MBMessageModelImpl.ORDER_BY_SQL);
11186 }
11187 }
11188
11189 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11190 MBMessage.class.getName(),
11191 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11192
11193 SQLQuery q = session.createSQLQuery(sql);
11194
11195 q.setFirstResult(0);
11196 q.setMaxResults(2);
11197
11198 if (getDB().isSupportsInlineDistinct()) {
11199 q.addEntity(_FILTER_ENTITY_ALIAS, MBMessageImpl.class);
11200 }
11201 else {
11202 q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class);
11203 }
11204
11205 QueryPos qPos = QueryPos.getInstance(q);
11206
11207 qPos.add(groupId);
11208
11209 qPos.add(categoryId);
11210
11211 qPos.add(status);
11212
11213 if (orderByComparator != null) {
11214 Object[] values = orderByComparator.getOrderByConditionValues(mbMessage);
11215
11216 for (Object value : values) {
11217 qPos.add(value);
11218 }
11219 }
11220
11221 List<MBMessage> list = q.list();
11222
11223 if (list.size() == 2) {
11224 return list.get(1);
11225 }
11226 else {
11227 return null;
11228 }
11229 }
11230
11231
11240 public List<MBMessage> findByU_C_C(long userId, long classNameId,
11241 long classPK) throws SystemException {
11242 return findByU_C_C(userId, classNameId, classPK, QueryUtil.ALL_POS,
11243 QueryUtil.ALL_POS, null);
11244 }
11245
11246
11261 public List<MBMessage> findByU_C_C(long userId, long classNameId,
11262 long classPK, int start, int end) throws SystemException {
11263 return findByU_C_C(userId, classNameId, classPK, start, end, null);
11264 }
11265
11266
11282 public List<MBMessage> findByU_C_C(long userId, long classNameId,
11283 long classPK, int start, int end, OrderByComparator orderByComparator)
11284 throws SystemException {
11285 FinderPath finderPath = null;
11286 Object[] finderArgs = null;
11287
11288 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11289 (orderByComparator == null)) {
11290 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_C;
11291 finderArgs = new Object[] { userId, classNameId, classPK };
11292 }
11293 else {
11294 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C_C;
11295 finderArgs = new Object[] {
11296 userId, classNameId, classPK,
11297
11298 start, end, orderByComparator
11299 };
11300 }
11301
11302 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(finderPath,
11303 finderArgs, this);
11304
11305 if (list == null) {
11306 StringBundler query = null;
11307
11308 if (orderByComparator != null) {
11309 query = new StringBundler(5 +
11310 (orderByComparator.getOrderByFields().length * 3));
11311 }
11312 else {
11313 query = new StringBundler(5);
11314 }
11315
11316 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
11317
11318 query.append(_FINDER_COLUMN_U_C_C_USERID_2);
11319
11320 query.append(_FINDER_COLUMN_U_C_C_CLASSNAMEID_2);
11321
11322 query.append(_FINDER_COLUMN_U_C_C_CLASSPK_2);
11323
11324 if (orderByComparator != null) {
11325 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11326 orderByComparator);
11327 }
11328
11329 else {
11330 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
11331 }
11332
11333 String sql = query.toString();
11334
11335 Session session = null;
11336
11337 try {
11338 session = openSession();
11339
11340 Query q = session.createQuery(sql);
11341
11342 QueryPos qPos = QueryPos.getInstance(q);
11343
11344 qPos.add(userId);
11345
11346 qPos.add(classNameId);
11347
11348 qPos.add(classPK);
11349
11350 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
11351 end);
11352 }
11353 catch (Exception e) {
11354 throw processException(e);
11355 }
11356 finally {
11357 if (list == null) {
11358 FinderCacheUtil.removeResult(finderPath, finderArgs);
11359 }
11360 else {
11361 cacheResult(list);
11362
11363 FinderCacheUtil.putResult(finderPath, finderArgs, list);
11364 }
11365
11366 closeSession(session);
11367 }
11368 }
11369
11370 return list;
11371 }
11372
11373
11388 public MBMessage findByU_C_C_First(long userId, long classNameId,
11389 long classPK, OrderByComparator orderByComparator)
11390 throws NoSuchMessageException, SystemException {
11391 List<MBMessage> list = findByU_C_C(userId, classNameId, classPK, 0, 1,
11392 orderByComparator);
11393
11394 if (list.isEmpty()) {
11395 StringBundler msg = new StringBundler(8);
11396
11397 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11398
11399 msg.append("userId=");
11400 msg.append(userId);
11401
11402 msg.append(", classNameId=");
11403 msg.append(classNameId);
11404
11405 msg.append(", classPK=");
11406 msg.append(classPK);
11407
11408 msg.append(StringPool.CLOSE_CURLY_BRACE);
11409
11410 throw new NoSuchMessageException(msg.toString());
11411 }
11412 else {
11413 return list.get(0);
11414 }
11415 }
11416
11417
11432 public MBMessage findByU_C_C_Last(long userId, long classNameId,
11433 long classPK, OrderByComparator orderByComparator)
11434 throws NoSuchMessageException, SystemException {
11435 int count = countByU_C_C(userId, classNameId, classPK);
11436
11437 List<MBMessage> list = findByU_C_C(userId, classNameId, classPK,
11438 count - 1, count, orderByComparator);
11439
11440 if (list.isEmpty()) {
11441 StringBundler msg = new StringBundler(8);
11442
11443 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11444
11445 msg.append("userId=");
11446 msg.append(userId);
11447
11448 msg.append(", classNameId=");
11449 msg.append(classNameId);
11450
11451 msg.append(", classPK=");
11452 msg.append(classPK);
11453
11454 msg.append(StringPool.CLOSE_CURLY_BRACE);
11455
11456 throw new NoSuchMessageException(msg.toString());
11457 }
11458 else {
11459 return list.get(0);
11460 }
11461 }
11462
11463
11479 public MBMessage[] findByU_C_C_PrevAndNext(long messageId, long userId,
11480 long classNameId, long classPK, OrderByComparator orderByComparator)
11481 throws NoSuchMessageException, SystemException {
11482 MBMessage mbMessage = findByPrimaryKey(messageId);
11483
11484 Session session = null;
11485
11486 try {
11487 session = openSession();
11488
11489 MBMessage[] array = new MBMessageImpl[3];
11490
11491 array[0] = getByU_C_C_PrevAndNext(session, mbMessage, userId,
11492 classNameId, classPK, orderByComparator, true);
11493
11494 array[1] = mbMessage;
11495
11496 array[2] = getByU_C_C_PrevAndNext(session, mbMessage, userId,
11497 classNameId, classPK, orderByComparator, false);
11498
11499 return array;
11500 }
11501 catch (Exception e) {
11502 throw processException(e);
11503 }
11504 finally {
11505 closeSession(session);
11506 }
11507 }
11508
11509 protected MBMessage getByU_C_C_PrevAndNext(Session session,
11510 MBMessage mbMessage, long userId, long classNameId, long classPK,
11511 OrderByComparator orderByComparator, boolean previous) {
11512 StringBundler query = null;
11513
11514 if (orderByComparator != null) {
11515 query = new StringBundler(6 +
11516 (orderByComparator.getOrderByFields().length * 6));
11517 }
11518 else {
11519 query = new StringBundler(3);
11520 }
11521
11522 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
11523
11524 query.append(_FINDER_COLUMN_U_C_C_USERID_2);
11525
11526 query.append(_FINDER_COLUMN_U_C_C_CLASSNAMEID_2);
11527
11528 query.append(_FINDER_COLUMN_U_C_C_CLASSPK_2);
11529
11530 if (orderByComparator != null) {
11531 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11532
11533 if (orderByConditionFields.length > 0) {
11534 query.append(WHERE_AND);
11535 }
11536
11537 for (int i = 0; i < orderByConditionFields.length; i++) {
11538 query.append(_ORDER_BY_ENTITY_ALIAS);
11539 query.append(orderByConditionFields[i]);
11540
11541 if ((i + 1) < orderByConditionFields.length) {
11542 if (orderByComparator.isAscending() ^ previous) {
11543 query.append(WHERE_GREATER_THAN_HAS_NEXT);
11544 }
11545 else {
11546 query.append(WHERE_LESSER_THAN_HAS_NEXT);
11547 }
11548 }
11549 else {
11550 if (orderByComparator.isAscending() ^ previous) {
11551 query.append(WHERE_GREATER_THAN);
11552 }
11553 else {
11554 query.append(WHERE_LESSER_THAN);
11555 }
11556 }
11557 }
11558
11559 query.append(ORDER_BY_CLAUSE);
11560
11561 String[] orderByFields = orderByComparator.getOrderByFields();
11562
11563 for (int i = 0; i < orderByFields.length; i++) {
11564 query.append(_ORDER_BY_ENTITY_ALIAS);
11565 query.append(orderByFields[i]);
11566
11567 if ((i + 1) < orderByFields.length) {
11568 if (orderByComparator.isAscending() ^ previous) {
11569 query.append(ORDER_BY_ASC_HAS_NEXT);
11570 }
11571 else {
11572 query.append(ORDER_BY_DESC_HAS_NEXT);
11573 }
11574 }
11575 else {
11576 if (orderByComparator.isAscending() ^ previous) {
11577 query.append(ORDER_BY_ASC);
11578 }
11579 else {
11580 query.append(ORDER_BY_DESC);
11581 }
11582 }
11583 }
11584 }
11585
11586 else {
11587 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
11588 }
11589
11590 String sql = query.toString();
11591
11592 Query q = session.createQuery(sql);
11593
11594 q.setFirstResult(0);
11595 q.setMaxResults(2);
11596
11597 QueryPos qPos = QueryPos.getInstance(q);
11598
11599 qPos.add(userId);
11600
11601 qPos.add(classNameId);
11602
11603 qPos.add(classPK);
11604
11605 if (orderByComparator != null) {
11606 Object[] values = orderByComparator.getOrderByConditionValues(mbMessage);
11607
11608 for (Object value : values) {
11609 qPos.add(value);
11610 }
11611 }
11612
11613 List<MBMessage> list = q.list();
11614
11615 if (list.size() == 2) {
11616 return list.get(1);
11617 }
11618 else {
11619 return null;
11620 }
11621 }
11622
11623
11632 public List<MBMessage> findByU_C_S(long userId, long classNameId, int status)
11633 throws SystemException {
11634 return findByU_C_S(userId, classNameId, status, QueryUtil.ALL_POS,
11635 QueryUtil.ALL_POS, null);
11636 }
11637
11638
11653 public List<MBMessage> findByU_C_S(long userId, long classNameId,
11654 int status, int start, int end) throws SystemException {
11655 return findByU_C_S(userId, classNameId, status, start, end, null);
11656 }
11657
11658
11674 public List<MBMessage> findByU_C_S(long userId, long classNameId,
11675 int status, int start, int end, OrderByComparator orderByComparator)
11676 throws SystemException {
11677 FinderPath finderPath = null;
11678 Object[] finderArgs = null;
11679
11680 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11681 (orderByComparator == null)) {
11682 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_S;
11683 finderArgs = new Object[] { userId, classNameId, status };
11684 }
11685 else {
11686 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C_S;
11687 finderArgs = new Object[] {
11688 userId, classNameId, status,
11689
11690 start, end, orderByComparator
11691 };
11692 }
11693
11694 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(finderPath,
11695 finderArgs, this);
11696
11697 if (list == null) {
11698 StringBundler query = null;
11699
11700 if (orderByComparator != null) {
11701 query = new StringBundler(5 +
11702 (orderByComparator.getOrderByFields().length * 3));
11703 }
11704 else {
11705 query = new StringBundler(5);
11706 }
11707
11708 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
11709
11710 query.append(_FINDER_COLUMN_U_C_S_USERID_2);
11711
11712 query.append(_FINDER_COLUMN_U_C_S_CLASSNAMEID_2);
11713
11714 query.append(_FINDER_COLUMN_U_C_S_STATUS_2);
11715
11716 if (orderByComparator != null) {
11717 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11718 orderByComparator);
11719 }
11720
11721 else {
11722 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
11723 }
11724
11725 String sql = query.toString();
11726
11727 Session session = null;
11728
11729 try {
11730 session = openSession();
11731
11732 Query q = session.createQuery(sql);
11733
11734 QueryPos qPos = QueryPos.getInstance(q);
11735
11736 qPos.add(userId);
11737
11738 qPos.add(classNameId);
11739
11740 qPos.add(status);
11741
11742 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
11743 end);
11744 }
11745 catch (Exception e) {
11746 throw processException(e);
11747 }
11748 finally {
11749 if (list == null) {
11750 FinderCacheUtil.removeResult(finderPath, finderArgs);
11751 }
11752 else {
11753 cacheResult(list);
11754
11755 FinderCacheUtil.putResult(finderPath, finderArgs, list);
11756 }
11757
11758 closeSession(session);
11759 }
11760 }
11761
11762 return list;
11763 }
11764
11765
11780 public MBMessage findByU_C_S_First(long userId, long classNameId,
11781 int status, OrderByComparator orderByComparator)
11782 throws NoSuchMessageException, SystemException {
11783 List<MBMessage> list = findByU_C_S(userId, classNameId, status, 0, 1,
11784 orderByComparator);
11785
11786 if (list.isEmpty()) {
11787 StringBundler msg = new StringBundler(8);
11788
11789 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11790
11791 msg.append("userId=");
11792 msg.append(userId);
11793
11794 msg.append(", classNameId=");
11795 msg.append(classNameId);
11796
11797 msg.append(", status=");
11798 msg.append(status);
11799
11800 msg.append(StringPool.CLOSE_CURLY_BRACE);
11801
11802 throw new NoSuchMessageException(msg.toString());
11803 }
11804 else {
11805 return list.get(0);
11806 }
11807 }
11808
11809
11824 public MBMessage findByU_C_S_Last(long userId, long classNameId,
11825 int status, OrderByComparator orderByComparator)
11826 throws NoSuchMessageException, SystemException {
11827 int count = countByU_C_S(userId, classNameId, status);
11828
11829 List<MBMessage> list = findByU_C_S(userId, classNameId, status,
11830 count - 1, count, orderByComparator);
11831
11832 if (list.isEmpty()) {
11833 StringBundler msg = new StringBundler(8);
11834
11835 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11836
11837 msg.append("userId=");
11838 msg.append(userId);
11839
11840 msg.append(", classNameId=");
11841 msg.append(classNameId);
11842
11843 msg.append(", status=");
11844 msg.append(status);
11845
11846 msg.append(StringPool.CLOSE_CURLY_BRACE);
11847
11848 throw new NoSuchMessageException(msg.toString());
11849 }
11850 else {
11851 return list.get(0);
11852 }
11853 }
11854
11855
11871 public MBMessage[] findByU_C_S_PrevAndNext(long messageId, long userId,
11872 long classNameId, int status, OrderByComparator orderByComparator)
11873 throws NoSuchMessageException, SystemException {
11874 MBMessage mbMessage = findByPrimaryKey(messageId);
11875
11876 Session session = null;
11877
11878 try {
11879 session = openSession();
11880
11881 MBMessage[] array = new MBMessageImpl[3];
11882
11883 array[0] = getByU_C_S_PrevAndNext(session, mbMessage, userId,
11884 classNameId, status, orderByComparator, true);
11885
11886 array[1] = mbMessage;
11887
11888 array[2] = getByU_C_S_PrevAndNext(session, mbMessage, userId,
11889 classNameId, status, orderByComparator, false);
11890
11891 return array;
11892 }
11893 catch (Exception e) {
11894 throw processException(e);
11895 }
11896 finally {
11897 closeSession(session);
11898 }
11899 }
11900
11901 protected MBMessage getByU_C_S_PrevAndNext(Session session,
11902 MBMessage mbMessage, long userId, long classNameId, int status,
11903 OrderByComparator orderByComparator, boolean previous) {
11904 StringBundler query = null;
11905
11906 if (orderByComparator != null) {
11907 query = new StringBundler(6 +
11908 (orderByComparator.getOrderByFields().length * 6));
11909 }
11910 else {
11911 query = new StringBundler(3);
11912 }
11913
11914 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
11915
11916 query.append(_FINDER_COLUMN_U_C_S_USERID_2);
11917
11918 query.append(_FINDER_COLUMN_U_C_S_CLASSNAMEID_2);
11919
11920 query.append(_FINDER_COLUMN_U_C_S_STATUS_2);
11921
11922 if (orderByComparator != null) {
11923 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11924
11925 if (orderByConditionFields.length > 0) {
11926 query.append(WHERE_AND);
11927 }
11928
11929 for (int i = 0; i < orderByConditionFields.length; i++) {
11930 query.append(_ORDER_BY_ENTITY_ALIAS);
11931 query.append(orderByConditionFields[i]);
11932
11933 if ((i + 1) < orderByConditionFields.length) {
11934 if (orderByComparator.isAscending() ^ previous) {
11935 query.append(WHERE_GREATER_THAN_HAS_NEXT);
11936 }
11937 else {
11938 query.append(WHERE_LESSER_THAN_HAS_NEXT);
11939 }
11940 }
11941 else {
11942 if (orderByComparator.isAscending() ^ previous) {
11943 query.append(WHERE_GREATER_THAN);
11944 }
11945 else {
11946 query.append(WHERE_LESSER_THAN);
11947 }
11948 }
11949 }
11950
11951 query.append(ORDER_BY_CLAUSE);
11952
11953 String[] orderByFields = orderByComparator.getOrderByFields();
11954
11955 for (int i = 0; i < orderByFields.length; i++) {
11956 query.append(_ORDER_BY_ENTITY_ALIAS);
11957 query.append(orderByFields[i]);
11958
11959 if ((i + 1) < orderByFields.length) {
11960 if (orderByComparator.isAscending() ^ previous) {
11961 query.append(ORDER_BY_ASC_HAS_NEXT);
11962 }
11963 else {
11964 query.append(ORDER_BY_DESC_HAS_NEXT);
11965 }
11966 }
11967 else {
11968 if (orderByComparator.isAscending() ^ previous) {
11969 query.append(ORDER_BY_ASC);
11970 }
11971 else {
11972 query.append(ORDER_BY_DESC);
11973 }
11974 }
11975 }
11976 }
11977
11978 else {
11979 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
11980 }
11981
11982 String sql = query.toString();
11983
11984 Query q = session.createQuery(sql);
11985
11986 q.setFirstResult(0);
11987 q.setMaxResults(2);
11988
11989 QueryPos qPos = QueryPos.getInstance(q);
11990
11991 qPos.add(userId);
11992
11993 qPos.add(classNameId);
11994
11995 qPos.add(status);
11996
11997 if (orderByComparator != null) {
11998 Object[] values = orderByComparator.getOrderByConditionValues(mbMessage);
11999
12000 for (Object value : values) {
12001 qPos.add(value);
12002 }
12003 }
12004
12005 List<MBMessage> list = q.list();
12006
12007 if (list.size() == 2) {
12008 return list.get(1);
12009 }
12010 else {
12011 return null;
12012 }
12013 }
12014
12015
12028 public List<MBMessage> findByU_C_S(long userId, long[] classNameIds,
12029 int status) throws SystemException {
12030 return findByU_C_S(userId, classNameIds, status, QueryUtil.ALL_POS,
12031 QueryUtil.ALL_POS, null);
12032 }
12033
12034
12049 public List<MBMessage> findByU_C_S(long userId, long[] classNameIds,
12050 int status, int start, int end) throws SystemException {
12051 return findByU_C_S(userId, classNameIds, status, start, end, null);
12052 }
12053
12054
12070 public List<MBMessage> findByU_C_S(long userId, long[] classNameIds,
12071 int status, int start, int end, OrderByComparator orderByComparator)
12072 throws SystemException {
12073 FinderPath finderPath = null;
12074 Object[] finderArgs = null;
12075
12076 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
12077 (orderByComparator == null)) {
12078 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_S;
12079 finderArgs = new Object[] {
12080 userId, StringUtil.merge(classNameIds), status
12081 };
12082 }
12083 else {
12084 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C_S;
12085 finderArgs = new Object[] {
12086 userId, StringUtil.merge(classNameIds), status,
12087
12088 start, end, orderByComparator
12089 };
12090 }
12091
12092 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(finderPath,
12093 finderArgs, this);
12094
12095 if (list == null) {
12096 StringBundler query = new StringBundler();
12097
12098 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
12099
12100 boolean conjunctionable = false;
12101
12102 if (conjunctionable) {
12103 query.append(WHERE_AND);
12104 }
12105
12106 query.append(_FINDER_COLUMN_U_C_S_USERID_5);
12107
12108 conjunctionable = true;
12109
12110 if ((classNameIds == null) || (classNameIds.length > 0)) {
12111 if (conjunctionable) {
12112 query.append(WHERE_AND);
12113 }
12114
12115 query.append(StringPool.OPEN_PARENTHESIS);
12116
12117 for (int i = 0; i < classNameIds.length; i++) {
12118 query.append(_FINDER_COLUMN_U_C_S_CLASSNAMEID_5);
12119
12120 if ((i + 1) < classNameIds.length) {
12121 query.append(WHERE_OR);
12122 }
12123 }
12124
12125 query.append(StringPool.CLOSE_PARENTHESIS);
12126
12127 conjunctionable = true;
12128 }
12129
12130 if (conjunctionable) {
12131 query.append(WHERE_AND);
12132 }
12133
12134 query.append(_FINDER_COLUMN_U_C_S_STATUS_5);
12135
12136 conjunctionable = true;
12137
12138 if (orderByComparator != null) {
12139 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12140 orderByComparator);
12141 }
12142
12143 else {
12144 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
12145 }
12146
12147 String sql = query.toString();
12148
12149 Session session = null;
12150
12151 try {
12152 session = openSession();
12153
12154 Query q = session.createQuery(sql);
12155
12156 QueryPos qPos = QueryPos.getInstance(q);
12157
12158 qPos.add(userId);
12159
12160 if (classNameIds != null) {
12161 qPos.add(classNameIds);
12162 }
12163
12164 qPos.add(status);
12165
12166 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
12167 end);
12168 }
12169 catch (Exception e) {
12170 throw processException(e);
12171 }
12172 finally {
12173 if (list == null) {
12174 FinderCacheUtil.removeResult(finderPath, finderArgs);
12175 }
12176 else {
12177 cacheResult(list);
12178
12179 FinderCacheUtil.putResult(finderPath, finderArgs, list);
12180 }
12181
12182 closeSession(session);
12183 }
12184 }
12185
12186 return list;
12187 }
12188
12189
12198 public List<MBMessage> findByC_C_S(long classNameId, long classPK,
12199 int status) throws SystemException {
12200 return findByC_C_S(classNameId, classPK, status, QueryUtil.ALL_POS,
12201 QueryUtil.ALL_POS, null);
12202 }
12203
12204
12219 public List<MBMessage> findByC_C_S(long classNameId, long classPK,
12220 int status, int start, int end) throws SystemException {
12221 return findByC_C_S(classNameId, classPK, status, start, end, null);
12222 }
12223
12224
12240 public List<MBMessage> findByC_C_S(long classNameId, long classPK,
12241 int status, int start, int end, OrderByComparator orderByComparator)
12242 throws SystemException {
12243 FinderPath finderPath = null;
12244 Object[] finderArgs = null;
12245
12246 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
12247 (orderByComparator == null)) {
12248 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_S;
12249 finderArgs = new Object[] { classNameId, classPK, status };
12250 }
12251 else {
12252 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_S;
12253 finderArgs = new Object[] {
12254 classNameId, classPK, status,
12255
12256 start, end, orderByComparator
12257 };
12258 }
12259
12260 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(finderPath,
12261 finderArgs, this);
12262
12263 if (list == null) {
12264 StringBundler query = null;
12265
12266 if (orderByComparator != null) {
12267 query = new StringBundler(5 +
12268 (orderByComparator.getOrderByFields().length * 3));
12269 }
12270 else {
12271 query = new StringBundler(5);
12272 }
12273
12274 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
12275
12276 query.append(_FINDER_COLUMN_C_C_S_CLASSNAMEID_2);
12277
12278 query.append(_FINDER_COLUMN_C_C_S_CLASSPK_2);
12279
12280 query.append(_FINDER_COLUMN_C_C_S_STATUS_2);
12281
12282 if (orderByComparator != null) {
12283 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12284 orderByComparator);
12285 }
12286
12287 else {
12288 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
12289 }
12290
12291 String sql = query.toString();
12292
12293 Session session = null;
12294
12295 try {
12296 session = openSession();
12297
12298 Query q = session.createQuery(sql);
12299
12300 QueryPos qPos = QueryPos.getInstance(q);
12301
12302 qPos.add(classNameId);
12303
12304 qPos.add(classPK);
12305
12306 qPos.add(status);
12307
12308 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
12309 end);
12310 }
12311 catch (Exception e) {
12312 throw processException(e);
12313 }
12314 finally {
12315 if (list == null) {
12316 FinderCacheUtil.removeResult(finderPath, finderArgs);
12317 }
12318 else {
12319 cacheResult(list);
12320
12321 FinderCacheUtil.putResult(finderPath, finderArgs, list);
12322 }
12323
12324 closeSession(session);
12325 }
12326 }
12327
12328 return list;
12329 }
12330
12331
12346 public MBMessage findByC_C_S_First(long classNameId, long classPK,
12347 int status, OrderByComparator orderByComparator)
12348 throws NoSuchMessageException, SystemException {
12349 List<MBMessage> list = findByC_C_S(classNameId, classPK, status, 0, 1,
12350 orderByComparator);
12351
12352 if (list.isEmpty()) {
12353 StringBundler msg = new StringBundler(8);
12354
12355 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12356
12357 msg.append("classNameId=");
12358 msg.append(classNameId);
12359
12360 msg.append(", classPK=");
12361 msg.append(classPK);
12362
12363 msg.append(", status=");
12364 msg.append(status);
12365
12366 msg.append(StringPool.CLOSE_CURLY_BRACE);
12367
12368 throw new NoSuchMessageException(msg.toString());
12369 }
12370 else {
12371 return list.get(0);
12372 }
12373 }
12374
12375
12390 public MBMessage findByC_C_S_Last(long classNameId, long classPK,
12391 int status, OrderByComparator orderByComparator)
12392 throws NoSuchMessageException, SystemException {
12393 int count = countByC_C_S(classNameId, classPK, status);
12394
12395 List<MBMessage> list = findByC_C_S(classNameId, classPK, status,
12396 count - 1, count, orderByComparator);
12397
12398 if (list.isEmpty()) {
12399 StringBundler msg = new StringBundler(8);
12400
12401 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12402
12403 msg.append("classNameId=");
12404 msg.append(classNameId);
12405
12406 msg.append(", classPK=");
12407 msg.append(classPK);
12408
12409 msg.append(", status=");
12410 msg.append(status);
12411
12412 msg.append(StringPool.CLOSE_CURLY_BRACE);
12413
12414 throw new NoSuchMessageException(msg.toString());
12415 }
12416 else {
12417 return list.get(0);
12418 }
12419 }
12420
12421
12437 public MBMessage[] findByC_C_S_PrevAndNext(long messageId,
12438 long classNameId, long classPK, int status,
12439 OrderByComparator orderByComparator)
12440 throws NoSuchMessageException, SystemException {
12441 MBMessage mbMessage = findByPrimaryKey(messageId);
12442
12443 Session session = null;
12444
12445 try {
12446 session = openSession();
12447
12448 MBMessage[] array = new MBMessageImpl[3];
12449
12450 array[0] = getByC_C_S_PrevAndNext(session, mbMessage, classNameId,
12451 classPK, status, orderByComparator, true);
12452
12453 array[1] = mbMessage;
12454
12455 array[2] = getByC_C_S_PrevAndNext(session, mbMessage, classNameId,
12456 classPK, status, orderByComparator, false);
12457
12458 return array;
12459 }
12460 catch (Exception e) {
12461 throw processException(e);
12462 }
12463 finally {
12464 closeSession(session);
12465 }
12466 }
12467
12468 protected MBMessage getByC_C_S_PrevAndNext(Session session,
12469 MBMessage mbMessage, long classNameId, long classPK, int status,
12470 OrderByComparator orderByComparator, boolean previous) {
12471 StringBundler query = null;
12472
12473 if (orderByComparator != null) {
12474 query = new StringBundler(6 +
12475 (orderByComparator.getOrderByFields().length * 6));
12476 }
12477 else {
12478 query = new StringBundler(3);
12479 }
12480
12481 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
12482
12483 query.append(_FINDER_COLUMN_C_C_S_CLASSNAMEID_2);
12484
12485 query.append(_FINDER_COLUMN_C_C_S_CLASSPK_2);
12486
12487 query.append(_FINDER_COLUMN_C_C_S_STATUS_2);
12488
12489 if (orderByComparator != null) {
12490 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12491
12492 if (orderByConditionFields.length > 0) {
12493 query.append(WHERE_AND);
12494 }
12495
12496 for (int i = 0; i < orderByConditionFields.length; i++) {
12497 query.append(_ORDER_BY_ENTITY_ALIAS);
12498 query.append(orderByConditionFields[i]);
12499
12500 if ((i + 1) < orderByConditionFields.length) {
12501 if (orderByComparator.isAscending() ^ previous) {
12502 query.append(WHERE_GREATER_THAN_HAS_NEXT);
12503 }
12504 else {
12505 query.append(WHERE_LESSER_THAN_HAS_NEXT);
12506 }
12507 }
12508 else {
12509 if (orderByComparator.isAscending() ^ previous) {
12510 query.append(WHERE_GREATER_THAN);
12511 }
12512 else {
12513 query.append(WHERE_LESSER_THAN);
12514 }
12515 }
12516 }
12517
12518 query.append(ORDER_BY_CLAUSE);
12519
12520 String[] orderByFields = orderByComparator.getOrderByFields();
12521
12522 for (int i = 0; i < orderByFields.length; i++) {
12523 query.append(_ORDER_BY_ENTITY_ALIAS);
12524 query.append(orderByFields[i]);
12525
12526 if ((i + 1) < orderByFields.length) {
12527 if (orderByComparator.isAscending() ^ previous) {
12528 query.append(ORDER_BY_ASC_HAS_NEXT);
12529 }
12530 else {
12531 query.append(ORDER_BY_DESC_HAS_NEXT);
12532 }
12533 }
12534 else {
12535 if (orderByComparator.isAscending() ^ previous) {
12536 query.append(ORDER_BY_ASC);
12537 }
12538 else {
12539 query.append(ORDER_BY_DESC);
12540 }
12541 }
12542 }
12543 }
12544
12545 else {
12546 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
12547 }
12548
12549 String sql = query.toString();
12550
12551 Query q = session.createQuery(sql);
12552
12553 q.setFirstResult(0);
12554 q.setMaxResults(2);
12555
12556 QueryPos qPos = QueryPos.getInstance(q);
12557
12558 qPos.add(classNameId);
12559
12560 qPos.add(classPK);
12561
12562 qPos.add(status);
12563
12564 if (orderByComparator != null) {
12565 Object[] values = orderByComparator.getOrderByConditionValues(mbMessage);
12566
12567 for (Object value : values) {
12568 qPos.add(value);
12569 }
12570 }
12571
12572 List<MBMessage> list = q.list();
12573
12574 if (list.size() == 2) {
12575 return list.get(1);
12576 }
12577 else {
12578 return null;
12579 }
12580 }
12581
12582
12592 public List<MBMessage> findByG_C_T_A(long groupId, long categoryId,
12593 long threadId, boolean answer) throws SystemException {
12594 return findByG_C_T_A(groupId, categoryId, threadId, answer,
12595 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
12596 }
12597
12598
12614 public List<MBMessage> findByG_C_T_A(long groupId, long categoryId,
12615 long threadId, boolean answer, int start, int end)
12616 throws SystemException {
12617 return findByG_C_T_A(groupId, categoryId, threadId, answer, start, end,
12618 null);
12619 }
12620
12621
12638 public List<MBMessage> findByG_C_T_A(long groupId, long categoryId,
12639 long threadId, boolean answer, int start, int end,
12640 OrderByComparator orderByComparator) throws SystemException {
12641 FinderPath finderPath = null;
12642 Object[] finderArgs = null;
12643
12644 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
12645 (orderByComparator == null)) {
12646 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T_A;
12647 finderArgs = new Object[] { groupId, categoryId, threadId, answer };
12648 }
12649 else {
12650 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T_A;
12651 finderArgs = new Object[] {
12652 groupId, categoryId, threadId, answer,
12653
12654 start, end, orderByComparator
12655 };
12656 }
12657
12658 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(finderPath,
12659 finderArgs, this);
12660
12661 if (list == null) {
12662 StringBundler query = null;
12663
12664 if (orderByComparator != null) {
12665 query = new StringBundler(6 +
12666 (orderByComparator.getOrderByFields().length * 3));
12667 }
12668 else {
12669 query = new StringBundler(6);
12670 }
12671
12672 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
12673
12674 query.append(_FINDER_COLUMN_G_C_T_A_GROUPID_2);
12675
12676 query.append(_FINDER_COLUMN_G_C_T_A_CATEGORYID_2);
12677
12678 query.append(_FINDER_COLUMN_G_C_T_A_THREADID_2);
12679
12680 query.append(_FINDER_COLUMN_G_C_T_A_ANSWER_2);
12681
12682 if (orderByComparator != null) {
12683 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12684 orderByComparator);
12685 }
12686
12687 else {
12688 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
12689 }
12690
12691 String sql = query.toString();
12692
12693 Session session = null;
12694
12695 try {
12696 session = openSession();
12697
12698 Query q = session.createQuery(sql);
12699
12700 QueryPos qPos = QueryPos.getInstance(q);
12701
12702 qPos.add(groupId);
12703
12704 qPos.add(categoryId);
12705
12706 qPos.add(threadId);
12707
12708 qPos.add(answer);
12709
12710 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
12711 end);
12712 }
12713 catch (Exception e) {
12714 throw processException(e);
12715 }
12716 finally {
12717 if (list == null) {
12718 FinderCacheUtil.removeResult(finderPath, finderArgs);
12719 }
12720 else {
12721 cacheResult(list);
12722
12723 FinderCacheUtil.putResult(finderPath, finderArgs, list);
12724 }
12725
12726 closeSession(session);
12727 }
12728 }
12729
12730 return list;
12731 }
12732
12733
12749 public MBMessage findByG_C_T_A_First(long groupId, long categoryId,
12750 long threadId, boolean answer, OrderByComparator orderByComparator)
12751 throws NoSuchMessageException, SystemException {
12752 List<MBMessage> list = findByG_C_T_A(groupId, categoryId, threadId,
12753 answer, 0, 1, orderByComparator);
12754
12755 if (list.isEmpty()) {
12756 StringBundler msg = new StringBundler(10);
12757
12758 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12759
12760 msg.append("groupId=");
12761 msg.append(groupId);
12762
12763 msg.append(", categoryId=");
12764 msg.append(categoryId);
12765
12766 msg.append(", threadId=");
12767 msg.append(threadId);
12768
12769 msg.append(", answer=");
12770 msg.append(answer);
12771
12772 msg.append(StringPool.CLOSE_CURLY_BRACE);
12773
12774 throw new NoSuchMessageException(msg.toString());
12775 }
12776 else {
12777 return list.get(0);
12778 }
12779 }
12780
12781
12797 public MBMessage findByG_C_T_A_Last(long groupId, long categoryId,
12798 long threadId, boolean answer, OrderByComparator orderByComparator)
12799 throws NoSuchMessageException, SystemException {
12800 int count = countByG_C_T_A(groupId, categoryId, threadId, answer);
12801
12802 List<MBMessage> list = findByG_C_T_A(groupId, categoryId, threadId,
12803 answer, count - 1, count, orderByComparator);
12804
12805 if (list.isEmpty()) {
12806 StringBundler msg = new StringBundler(10);
12807
12808 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12809
12810 msg.append("groupId=");
12811 msg.append(groupId);
12812
12813 msg.append(", categoryId=");
12814 msg.append(categoryId);
12815
12816 msg.append(", threadId=");
12817 msg.append(threadId);
12818
12819 msg.append(", answer=");
12820 msg.append(answer);
12821
12822 msg.append(StringPool.CLOSE_CURLY_BRACE);
12823
12824 throw new NoSuchMessageException(msg.toString());
12825 }
12826 else {
12827 return list.get(0);
12828 }
12829 }
12830
12831
12848 public MBMessage[] findByG_C_T_A_PrevAndNext(long messageId, long groupId,
12849 long categoryId, long threadId, boolean answer,
12850 OrderByComparator orderByComparator)
12851 throws NoSuchMessageException, SystemException {
12852 MBMessage mbMessage = findByPrimaryKey(messageId);
12853
12854 Session session = null;
12855
12856 try {
12857 session = openSession();
12858
12859 MBMessage[] array = new MBMessageImpl[3];
12860
12861 array[0] = getByG_C_T_A_PrevAndNext(session, mbMessage, groupId,
12862 categoryId, threadId, answer, orderByComparator, true);
12863
12864 array[1] = mbMessage;
12865
12866 array[2] = getByG_C_T_A_PrevAndNext(session, mbMessage, groupId,
12867 categoryId, threadId, answer, orderByComparator, false);
12868
12869 return array;
12870 }
12871 catch (Exception e) {
12872 throw processException(e);
12873 }
12874 finally {
12875 closeSession(session);
12876 }
12877 }
12878
12879 protected MBMessage getByG_C_T_A_PrevAndNext(Session session,
12880 MBMessage mbMessage, long groupId, long categoryId, long threadId,
12881 boolean answer, OrderByComparator orderByComparator, boolean previous) {
12882 StringBundler query = null;
12883
12884 if (orderByComparator != null) {
12885 query = new StringBundler(6 +
12886 (orderByComparator.getOrderByFields().length * 6));
12887 }
12888 else {
12889 query = new StringBundler(3);
12890 }
12891
12892 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
12893
12894 query.append(_FINDER_COLUMN_G_C_T_A_GROUPID_2);
12895
12896 query.append(_FINDER_COLUMN_G_C_T_A_CATEGORYID_2);
12897
12898 query.append(_FINDER_COLUMN_G_C_T_A_THREADID_2);
12899
12900 query.append(_FINDER_COLUMN_G_C_T_A_ANSWER_2);
12901
12902 if (orderByComparator != null) {
12903 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12904
12905 if (orderByConditionFields.length > 0) {
12906 query.append(WHERE_AND);
12907 }
12908
12909 for (int i = 0; i < orderByConditionFields.length; i++) {
12910 query.append(_ORDER_BY_ENTITY_ALIAS);
12911 query.append(orderByConditionFields[i]);
12912
12913 if ((i + 1) < orderByConditionFields.length) {
12914 if (orderByComparator.isAscending() ^ previous) {
12915 query.append(WHERE_GREATER_THAN_HAS_NEXT);
12916 }
12917 else {
12918 query.append(WHERE_LESSER_THAN_HAS_NEXT);
12919 }
12920 }
12921 else {
12922 if (orderByComparator.isAscending() ^ previous) {
12923 query.append(WHERE_GREATER_THAN);
12924 }
12925 else {
12926 query.append(WHERE_LESSER_THAN);
12927 }
12928 }
12929 }
12930
12931 query.append(ORDER_BY_CLAUSE);
12932
12933 String[] orderByFields = orderByComparator.getOrderByFields();
12934
12935 for (int i = 0; i < orderByFields.length; i++) {
12936 query.append(_ORDER_BY_ENTITY_ALIAS);
12937 query.append(orderByFields[i]);
12938
12939 if ((i + 1) < orderByFields.length) {
12940 if (orderByComparator.isAscending() ^ previous) {
12941 query.append(ORDER_BY_ASC_HAS_NEXT);
12942 }
12943 else {
12944 query.append(ORDER_BY_DESC_HAS_NEXT);
12945 }
12946 }
12947 else {
12948 if (orderByComparator.isAscending() ^ previous) {
12949 query.append(ORDER_BY_ASC);
12950 }
12951 else {
12952 query.append(ORDER_BY_DESC);
12953 }
12954 }
12955 }
12956 }
12957
12958 else {
12959 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
12960 }
12961
12962 String sql = query.toString();
12963
12964 Query q = session.createQuery(sql);
12965
12966 q.setFirstResult(0);
12967 q.setMaxResults(2);
12968
12969 QueryPos qPos = QueryPos.getInstance(q);
12970
12971 qPos.add(groupId);
12972
12973 qPos.add(categoryId);
12974
12975 qPos.add(threadId);
12976
12977 qPos.add(answer);
12978
12979 if (orderByComparator != null) {
12980 Object[] values = orderByComparator.getOrderByConditionValues(mbMessage);
12981
12982 for (Object value : values) {
12983 qPos.add(value);
12984 }
12985 }
12986
12987 List<MBMessage> list = q.list();
12988
12989 if (list.size() == 2) {
12990 return list.get(1);
12991 }
12992 else {
12993 return null;
12994 }
12995 }
12996
12997
13007 public List<MBMessage> filterFindByG_C_T_A(long groupId, long categoryId,
13008 long threadId, boolean answer) throws SystemException {
13009 return filterFindByG_C_T_A(groupId, categoryId, threadId, answer,
13010 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
13011 }
13012
13013
13029 public List<MBMessage> filterFindByG_C_T_A(long groupId, long categoryId,
13030 long threadId, boolean answer, int start, int end)
13031 throws SystemException {
13032 return filterFindByG_C_T_A(groupId, categoryId, threadId, answer,
13033 start, end, null);
13034 }
13035
13036
13053 public List<MBMessage> filterFindByG_C_T_A(long groupId, long categoryId,
13054 long threadId, boolean answer, int start, int end,
13055 OrderByComparator orderByComparator) throws SystemException {
13056 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13057 return findByG_C_T_A(groupId, categoryId, threadId, answer, start,
13058 end, orderByComparator);
13059 }
13060
13061 StringBundler query = null;
13062
13063 if (orderByComparator != null) {
13064 query = new StringBundler(6 +
13065 (orderByComparator.getOrderByFields().length * 3));
13066 }
13067 else {
13068 query = new StringBundler(6);
13069 }
13070
13071 if (getDB().isSupportsInlineDistinct()) {
13072 query.append(_FILTER_SQL_SELECT_MBMESSAGE_WHERE);
13073 }
13074 else {
13075 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1);
13076 }
13077
13078 query.append(_FINDER_COLUMN_G_C_T_A_GROUPID_2);
13079
13080 query.append(_FINDER_COLUMN_G_C_T_A_CATEGORYID_2);
13081
13082 query.append(_FINDER_COLUMN_G_C_T_A_THREADID_2);
13083
13084 query.append(_FINDER_COLUMN_G_C_T_A_ANSWER_2);
13085
13086 if (!getDB().isSupportsInlineDistinct()) {
13087 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_2);
13088 }
13089
13090 if (orderByComparator != null) {
13091 if (getDB().isSupportsInlineDistinct()) {
13092 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13093 orderByComparator);
13094 }
13095 else {
13096 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
13097 orderByComparator);
13098 }
13099 }
13100
13101 else {
13102 if (getDB().isSupportsInlineDistinct()) {
13103 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
13104 }
13105 else {
13106 query.append(MBMessageModelImpl.ORDER_BY_SQL);
13107 }
13108 }
13109
13110 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13111 MBMessage.class.getName(),
13112 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13113
13114 Session session = null;
13115
13116 try {
13117 session = openSession();
13118
13119 SQLQuery q = session.createSQLQuery(sql);
13120
13121 if (getDB().isSupportsInlineDistinct()) {
13122 q.addEntity(_FILTER_ENTITY_ALIAS, MBMessageImpl.class);
13123 }
13124 else {
13125 q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class);
13126 }
13127
13128 QueryPos qPos = QueryPos.getInstance(q);
13129
13130 qPos.add(groupId);
13131
13132 qPos.add(categoryId);
13133
13134 qPos.add(threadId);
13135
13136 qPos.add(answer);
13137
13138 return (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end);
13139 }
13140 catch (Exception e) {
13141 throw processException(e);
13142 }
13143 finally {
13144 closeSession(session);
13145 }
13146 }
13147
13148
13161 public MBMessage[] filterFindByG_C_T_A_PrevAndNext(long messageId,
13162 long groupId, long categoryId, long threadId, boolean answer,
13163 OrderByComparator orderByComparator)
13164 throws NoSuchMessageException, SystemException {
13165 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13166 return findByG_C_T_A_PrevAndNext(messageId, groupId, categoryId,
13167 threadId, answer, orderByComparator);
13168 }
13169
13170 MBMessage mbMessage = findByPrimaryKey(messageId);
13171
13172 Session session = null;
13173
13174 try {
13175 session = openSession();
13176
13177 MBMessage[] array = new MBMessageImpl[3];
13178
13179 array[0] = filterGetByG_C_T_A_PrevAndNext(session, mbMessage,
13180 groupId, categoryId, threadId, answer, orderByComparator,
13181 true);
13182
13183 array[1] = mbMessage;
13184
13185 array[2] = filterGetByG_C_T_A_PrevAndNext(session, mbMessage,
13186 groupId, categoryId, threadId, answer, orderByComparator,
13187 false);
13188
13189 return array;
13190 }
13191 catch (Exception e) {
13192 throw processException(e);
13193 }
13194 finally {
13195 closeSession(session);
13196 }
13197 }
13198
13199 protected MBMessage filterGetByG_C_T_A_PrevAndNext(Session session,
13200 MBMessage mbMessage, long groupId, long categoryId, long threadId,
13201 boolean answer, OrderByComparator orderByComparator, boolean previous) {
13202 StringBundler query = null;
13203
13204 if (orderByComparator != null) {
13205 query = new StringBundler(6 +
13206 (orderByComparator.getOrderByFields().length * 6));
13207 }
13208 else {
13209 query = new StringBundler(3);
13210 }
13211
13212 if (getDB().isSupportsInlineDistinct()) {
13213 query.append(_FILTER_SQL_SELECT_MBMESSAGE_WHERE);
13214 }
13215 else {
13216 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1);
13217 }
13218
13219 query.append(_FINDER_COLUMN_G_C_T_A_GROUPID_2);
13220
13221 query.append(_FINDER_COLUMN_G_C_T_A_CATEGORYID_2);
13222
13223 query.append(_FINDER_COLUMN_G_C_T_A_THREADID_2);
13224
13225 query.append(_FINDER_COLUMN_G_C_T_A_ANSWER_2);
13226
13227 if (!getDB().isSupportsInlineDistinct()) {
13228 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_2);
13229 }
13230
13231 if (orderByComparator != null) {
13232 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13233
13234 if (orderByConditionFields.length > 0) {
13235 query.append(WHERE_AND);
13236 }
13237
13238 for (int i = 0; i < orderByConditionFields.length; i++) {
13239 if (getDB().isSupportsInlineDistinct()) {
13240 query.append(_ORDER_BY_ENTITY_ALIAS);
13241 }
13242 else {
13243 query.append(_ORDER_BY_ENTITY_TABLE);
13244 }
13245
13246 query.append(orderByConditionFields[i]);
13247
13248 if ((i + 1) < orderByConditionFields.length) {
13249 if (orderByComparator.isAscending() ^ previous) {
13250 query.append(WHERE_GREATER_THAN_HAS_NEXT);
13251 }
13252 else {
13253 query.append(WHERE_LESSER_THAN_HAS_NEXT);
13254 }
13255 }
13256 else {
13257 if (orderByComparator.isAscending() ^ previous) {
13258 query.append(WHERE_GREATER_THAN);
13259 }
13260 else {
13261 query.append(WHERE_LESSER_THAN);
13262 }
13263 }
13264 }
13265
13266 query.append(ORDER_BY_CLAUSE);
13267
13268 String[] orderByFields = orderByComparator.getOrderByFields();
13269
13270 for (int i = 0; i < orderByFields.length; i++) {
13271 if (getDB().isSupportsInlineDistinct()) {
13272 query.append(_ORDER_BY_ENTITY_ALIAS);
13273 }
13274 else {
13275 query.append(_ORDER_BY_ENTITY_TABLE);
13276 }
13277
13278 query.append(orderByFields[i]);
13279
13280 if ((i + 1) < orderByFields.length) {
13281 if (orderByComparator.isAscending() ^ previous) {
13282 query.append(ORDER_BY_ASC_HAS_NEXT);
13283 }
13284 else {
13285 query.append(ORDER_BY_DESC_HAS_NEXT);
13286 }
13287 }
13288 else {
13289 if (orderByComparator.isAscending() ^ previous) {
13290 query.append(ORDER_BY_ASC);
13291 }
13292 else {
13293 query.append(ORDER_BY_DESC);
13294 }
13295 }
13296 }
13297 }
13298
13299 else {
13300 if (getDB().isSupportsInlineDistinct()) {
13301 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
13302 }
13303 else {
13304 query.append(MBMessageModelImpl.ORDER_BY_SQL);
13305 }
13306 }
13307
13308 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13309 MBMessage.class.getName(),
13310 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13311
13312 SQLQuery q = session.createSQLQuery(sql);
13313
13314 q.setFirstResult(0);
13315 q.setMaxResults(2);
13316
13317 if (getDB().isSupportsInlineDistinct()) {
13318 q.addEntity(_FILTER_ENTITY_ALIAS, MBMessageImpl.class);
13319 }
13320 else {
13321 q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class);
13322 }
13323
13324 QueryPos qPos = QueryPos.getInstance(q);
13325
13326 qPos.add(groupId);
13327
13328 qPos.add(categoryId);
13329
13330 qPos.add(threadId);
13331
13332 qPos.add(answer);
13333
13334 if (orderByComparator != null) {
13335 Object[] values = orderByComparator.getOrderByConditionValues(mbMessage);
13336
13337 for (Object value : values) {
13338 qPos.add(value);
13339 }
13340 }
13341
13342 List<MBMessage> list = q.list();
13343
13344 if (list.size() == 2) {
13345 return list.get(1);
13346 }
13347 else {
13348 return null;
13349 }
13350 }
13351
13352
13362 public List<MBMessage> findByG_C_T_S(long groupId, long categoryId,
13363 long threadId, int status) throws SystemException {
13364 return findByG_C_T_S(groupId, categoryId, threadId, status,
13365 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
13366 }
13367
13368
13384 public List<MBMessage> findByG_C_T_S(long groupId, long categoryId,
13385 long threadId, int status, int start, int end)
13386 throws SystemException {
13387 return findByG_C_T_S(groupId, categoryId, threadId, status, start, end,
13388 null);
13389 }
13390
13391
13408 public List<MBMessage> findByG_C_T_S(long groupId, long categoryId,
13409 long threadId, int status, int start, int end,
13410 OrderByComparator orderByComparator) throws SystemException {
13411 FinderPath finderPath = null;
13412 Object[] finderArgs = null;
13413
13414 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
13415 (orderByComparator == null)) {
13416 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T_S;
13417 finderArgs = new Object[] { groupId, categoryId, threadId, status };
13418 }
13419 else {
13420 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T_S;
13421 finderArgs = new Object[] {
13422 groupId, categoryId, threadId, status,
13423
13424 start, end, orderByComparator
13425 };
13426 }
13427
13428 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(finderPath,
13429 finderArgs, this);
13430
13431 if (list == null) {
13432 StringBundler query = null;
13433
13434 if (orderByComparator != null) {
13435 query = new StringBundler(6 +
13436 (orderByComparator.getOrderByFields().length * 3));
13437 }
13438 else {
13439 query = new StringBundler(6);
13440 }
13441
13442 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
13443
13444 query.append(_FINDER_COLUMN_G_C_T_S_GROUPID_2);
13445
13446 query.append(_FINDER_COLUMN_G_C_T_S_CATEGORYID_2);
13447
13448 query.append(_FINDER_COLUMN_G_C_T_S_THREADID_2);
13449
13450 query.append(_FINDER_COLUMN_G_C_T_S_STATUS_2);
13451
13452 if (orderByComparator != null) {
13453 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13454 orderByComparator);
13455 }
13456
13457 else {
13458 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
13459 }
13460
13461 String sql = query.toString();
13462
13463 Session session = null;
13464
13465 try {
13466 session = openSession();
13467
13468 Query q = session.createQuery(sql);
13469
13470 QueryPos qPos = QueryPos.getInstance(q);
13471
13472 qPos.add(groupId);
13473
13474 qPos.add(categoryId);
13475
13476 qPos.add(threadId);
13477
13478 qPos.add(status);
13479
13480 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
13481 end);
13482 }
13483 catch (Exception e) {
13484 throw processException(e);
13485 }
13486 finally {
13487 if (list == null) {
13488 FinderCacheUtil.removeResult(finderPath, finderArgs);
13489 }
13490 else {
13491 cacheResult(list);
13492
13493 FinderCacheUtil.putResult(finderPath, finderArgs, list);
13494 }
13495
13496 closeSession(session);
13497 }
13498 }
13499
13500 return list;
13501 }
13502
13503
13519 public MBMessage findByG_C_T_S_First(long groupId, long categoryId,
13520 long threadId, int status, OrderByComparator orderByComparator)
13521 throws NoSuchMessageException, SystemException {
13522 List<MBMessage> list = findByG_C_T_S(groupId, categoryId, threadId,
13523 status, 0, 1, orderByComparator);
13524
13525 if (list.isEmpty()) {
13526 StringBundler msg = new StringBundler(10);
13527
13528 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13529
13530 msg.append("groupId=");
13531 msg.append(groupId);
13532
13533 msg.append(", categoryId=");
13534 msg.append(categoryId);
13535
13536 msg.append(", threadId=");
13537 msg.append(threadId);
13538
13539 msg.append(", status=");
13540 msg.append(status);
13541
13542 msg.append(StringPool.CLOSE_CURLY_BRACE);
13543
13544 throw new NoSuchMessageException(msg.toString());
13545 }
13546 else {
13547 return list.get(0);
13548 }
13549 }
13550
13551
13567 public MBMessage findByG_C_T_S_Last(long groupId, long categoryId,
13568 long threadId, int status, OrderByComparator orderByComparator)
13569 throws NoSuchMessageException, SystemException {
13570 int count = countByG_C_T_S(groupId, categoryId, threadId, status);
13571
13572 List<MBMessage> list = findByG_C_T_S(groupId, categoryId, threadId,
13573 status, count - 1, count, orderByComparator);
13574
13575 if (list.isEmpty()) {
13576 StringBundler msg = new StringBundler(10);
13577
13578 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13579
13580 msg.append("groupId=");
13581 msg.append(groupId);
13582
13583 msg.append(", categoryId=");
13584 msg.append(categoryId);
13585
13586 msg.append(", threadId=");
13587 msg.append(threadId);
13588
13589 msg.append(", status=");
13590 msg.append(status);
13591
13592 msg.append(StringPool.CLOSE_CURLY_BRACE);
13593
13594 throw new NoSuchMessageException(msg.toString());
13595 }
13596 else {
13597 return list.get(0);
13598 }
13599 }
13600
13601
13618 public MBMessage[] findByG_C_T_S_PrevAndNext(long messageId, long groupId,
13619 long categoryId, long threadId, int status,
13620 OrderByComparator orderByComparator)
13621 throws NoSuchMessageException, SystemException {
13622 MBMessage mbMessage = findByPrimaryKey(messageId);
13623
13624 Session session = null;
13625
13626 try {
13627 session = openSession();
13628
13629 MBMessage[] array = new MBMessageImpl[3];
13630
13631 array[0] = getByG_C_T_S_PrevAndNext(session, mbMessage, groupId,
13632 categoryId, threadId, status, orderByComparator, true);
13633
13634 array[1] = mbMessage;
13635
13636 array[2] = getByG_C_T_S_PrevAndNext(session, mbMessage, groupId,
13637 categoryId, threadId, status, orderByComparator, false);
13638
13639 return array;
13640 }
13641 catch (Exception e) {
13642 throw processException(e);
13643 }
13644 finally {
13645 closeSession(session);
13646 }
13647 }
13648
13649 protected MBMessage getByG_C_T_S_PrevAndNext(Session session,
13650 MBMessage mbMessage, long groupId, long categoryId, long threadId,
13651 int status, OrderByComparator orderByComparator, boolean previous) {
13652 StringBundler query = null;
13653
13654 if (orderByComparator != null) {
13655 query = new StringBundler(6 +
13656 (orderByComparator.getOrderByFields().length * 6));
13657 }
13658 else {
13659 query = new StringBundler(3);
13660 }
13661
13662 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
13663
13664 query.append(_FINDER_COLUMN_G_C_T_S_GROUPID_2);
13665
13666 query.append(_FINDER_COLUMN_G_C_T_S_CATEGORYID_2);
13667
13668 query.append(_FINDER_COLUMN_G_C_T_S_THREADID_2);
13669
13670 query.append(_FINDER_COLUMN_G_C_T_S_STATUS_2);
13671
13672 if (orderByComparator != null) {
13673 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13674
13675 if (orderByConditionFields.length > 0) {
13676 query.append(WHERE_AND);
13677 }
13678
13679 for (int i = 0; i < orderByConditionFields.length; i++) {
13680 query.append(_ORDER_BY_ENTITY_ALIAS);
13681 query.append(orderByConditionFields[i]);
13682
13683 if ((i + 1) < orderByConditionFields.length) {
13684 if (orderByComparator.isAscending() ^ previous) {
13685 query.append(WHERE_GREATER_THAN_HAS_NEXT);
13686 }
13687 else {
13688 query.append(WHERE_LESSER_THAN_HAS_NEXT);
13689 }
13690 }
13691 else {
13692 if (orderByComparator.isAscending() ^ previous) {
13693 query.append(WHERE_GREATER_THAN);
13694 }
13695 else {
13696 query.append(WHERE_LESSER_THAN);
13697 }
13698 }
13699 }
13700
13701 query.append(ORDER_BY_CLAUSE);
13702
13703 String[] orderByFields = orderByComparator.getOrderByFields();
13704
13705 for (int i = 0; i < orderByFields.length; i++) {
13706 query.append(_ORDER_BY_ENTITY_ALIAS);
13707 query.append(orderByFields[i]);
13708
13709 if ((i + 1) < orderByFields.length) {
13710 if (orderByComparator.isAscending() ^ previous) {
13711 query.append(ORDER_BY_ASC_HAS_NEXT);
13712 }
13713 else {
13714 query.append(ORDER_BY_DESC_HAS_NEXT);
13715 }
13716 }
13717 else {
13718 if (orderByComparator.isAscending() ^ previous) {
13719 query.append(ORDER_BY_ASC);
13720 }
13721 else {
13722 query.append(ORDER_BY_DESC);
13723 }
13724 }
13725 }
13726 }
13727
13728 else {
13729 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
13730 }
13731
13732 String sql = query.toString();
13733
13734 Query q = session.createQuery(sql);
13735
13736 q.setFirstResult(0);
13737 q.setMaxResults(2);
13738
13739 QueryPos qPos = QueryPos.getInstance(q);
13740
13741 qPos.add(groupId);
13742
13743 qPos.add(categoryId);
13744
13745 qPos.add(threadId);
13746
13747 qPos.add(status);
13748
13749 if (orderByComparator != null) {
13750 Object[] values = orderByComparator.getOrderByConditionValues(mbMessage);
13751
13752 for (Object value : values) {
13753 qPos.add(value);
13754 }
13755 }
13756
13757 List<MBMessage> list = q.list();
13758
13759 if (list.size() == 2) {
13760 return list.get(1);
13761 }
13762 else {
13763 return null;
13764 }
13765 }
13766
13767
13777 public List<MBMessage> filterFindByG_C_T_S(long groupId, long categoryId,
13778 long threadId, int status) throws SystemException {
13779 return filterFindByG_C_T_S(groupId, categoryId, threadId, status,
13780 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
13781 }
13782
13783
13799 public List<MBMessage> filterFindByG_C_T_S(long groupId, long categoryId,
13800 long threadId, int status, int start, int end)
13801 throws SystemException {
13802 return filterFindByG_C_T_S(groupId, categoryId, threadId, status,
13803 start, end, null);
13804 }
13805
13806
13823 public List<MBMessage> filterFindByG_C_T_S(long groupId, long categoryId,
13824 long threadId, int status, int start, int end,
13825 OrderByComparator orderByComparator) throws SystemException {
13826 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13827 return findByG_C_T_S(groupId, categoryId, threadId, status, start,
13828 end, orderByComparator);
13829 }
13830
13831 StringBundler query = null;
13832
13833 if (orderByComparator != null) {
13834 query = new StringBundler(6 +
13835 (orderByComparator.getOrderByFields().length * 3));
13836 }
13837 else {
13838 query = new StringBundler(6);
13839 }
13840
13841 if (getDB().isSupportsInlineDistinct()) {
13842 query.append(_FILTER_SQL_SELECT_MBMESSAGE_WHERE);
13843 }
13844 else {
13845 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1);
13846 }
13847
13848 query.append(_FINDER_COLUMN_G_C_T_S_GROUPID_2);
13849
13850 query.append(_FINDER_COLUMN_G_C_T_S_CATEGORYID_2);
13851
13852 query.append(_FINDER_COLUMN_G_C_T_S_THREADID_2);
13853
13854 query.append(_FINDER_COLUMN_G_C_T_S_STATUS_2);
13855
13856 if (!getDB().isSupportsInlineDistinct()) {
13857 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_2);
13858 }
13859
13860 if (orderByComparator != null) {
13861 if (getDB().isSupportsInlineDistinct()) {
13862 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13863 orderByComparator);
13864 }
13865 else {
13866 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
13867 orderByComparator);
13868 }
13869 }
13870
13871 else {
13872 if (getDB().isSupportsInlineDistinct()) {
13873 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
13874 }
13875 else {
13876 query.append(MBMessageModelImpl.ORDER_BY_SQL);
13877 }
13878 }
13879
13880 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13881 MBMessage.class.getName(),
13882 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13883
13884 Session session = null;
13885
13886 try {
13887 session = openSession();
13888
13889 SQLQuery q = session.createSQLQuery(sql);
13890
13891 if (getDB().isSupportsInlineDistinct()) {
13892 q.addEntity(_FILTER_ENTITY_ALIAS, MBMessageImpl.class);
13893 }
13894 else {
13895 q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class);
13896 }
13897
13898 QueryPos qPos = QueryPos.getInstance(q);
13899
13900 qPos.add(groupId);
13901
13902 qPos.add(categoryId);
13903
13904 qPos.add(threadId);
13905
13906 qPos.add(status);
13907
13908 return (List<MBMessage>)QueryUtil.list(q, getDialect(), start, end);
13909 }
13910 catch (Exception e) {
13911 throw processException(e);
13912 }
13913 finally {
13914 closeSession(session);
13915 }
13916 }
13917
13918
13931 public MBMessage[] filterFindByG_C_T_S_PrevAndNext(long messageId,
13932 long groupId, long categoryId, long threadId, int status,
13933 OrderByComparator orderByComparator)
13934 throws NoSuchMessageException, SystemException {
13935 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13936 return findByG_C_T_S_PrevAndNext(messageId, groupId, categoryId,
13937 threadId, status, orderByComparator);
13938 }
13939
13940 MBMessage mbMessage = findByPrimaryKey(messageId);
13941
13942 Session session = null;
13943
13944 try {
13945 session = openSession();
13946
13947 MBMessage[] array = new MBMessageImpl[3];
13948
13949 array[0] = filterGetByG_C_T_S_PrevAndNext(session, mbMessage,
13950 groupId, categoryId, threadId, status, orderByComparator,
13951 true);
13952
13953 array[1] = mbMessage;
13954
13955 array[2] = filterGetByG_C_T_S_PrevAndNext(session, mbMessage,
13956 groupId, categoryId, threadId, status, orderByComparator,
13957 false);
13958
13959 return array;
13960 }
13961 catch (Exception e) {
13962 throw processException(e);
13963 }
13964 finally {
13965 closeSession(session);
13966 }
13967 }
13968
13969 protected MBMessage filterGetByG_C_T_S_PrevAndNext(Session session,
13970 MBMessage mbMessage, long groupId, long categoryId, long threadId,
13971 int status, OrderByComparator orderByComparator, boolean previous) {
13972 StringBundler query = null;
13973
13974 if (orderByComparator != null) {
13975 query = new StringBundler(6 +
13976 (orderByComparator.getOrderByFields().length * 6));
13977 }
13978 else {
13979 query = new StringBundler(3);
13980 }
13981
13982 if (getDB().isSupportsInlineDistinct()) {
13983 query.append(_FILTER_SQL_SELECT_MBMESSAGE_WHERE);
13984 }
13985 else {
13986 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1);
13987 }
13988
13989 query.append(_FINDER_COLUMN_G_C_T_S_GROUPID_2);
13990
13991 query.append(_FINDER_COLUMN_G_C_T_S_CATEGORYID_2);
13992
13993 query.append(_FINDER_COLUMN_G_C_T_S_THREADID_2);
13994
13995 query.append(_FINDER_COLUMN_G_C_T_S_STATUS_2);
13996
13997 if (!getDB().isSupportsInlineDistinct()) {
13998 query.append(_FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_2);
13999 }
14000
14001 if (orderByComparator != null) {
14002 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14003
14004 if (orderByConditionFields.length > 0) {
14005 query.append(WHERE_AND);
14006 }
14007
14008 for (int i = 0; i < orderByConditionFields.length; i++) {
14009 if (getDB().isSupportsInlineDistinct()) {
14010 query.append(_ORDER_BY_ENTITY_ALIAS);
14011 }
14012 else {
14013 query.append(_ORDER_BY_ENTITY_TABLE);
14014 }
14015
14016 query.append(orderByConditionFields[i]);
14017
14018 if ((i + 1) < orderByConditionFields.length) {
14019 if (orderByComparator.isAscending() ^ previous) {
14020 query.append(WHERE_GREATER_THAN_HAS_NEXT);
14021 }
14022 else {
14023 query.append(WHERE_LESSER_THAN_HAS_NEXT);
14024 }
14025 }
14026 else {
14027 if (orderByComparator.isAscending() ^ previous) {
14028 query.append(WHERE_GREATER_THAN);
14029 }
14030 else {
14031 query.append(WHERE_LESSER_THAN);
14032 }
14033 }
14034 }
14035
14036 query.append(ORDER_BY_CLAUSE);
14037
14038 String[] orderByFields = orderByComparator.getOrderByFields();
14039
14040 for (int i = 0; i < orderByFields.length; i++) {
14041 if (getDB().isSupportsInlineDistinct()) {
14042 query.append(_ORDER_BY_ENTITY_ALIAS);
14043 }
14044 else {
14045 query.append(_ORDER_BY_ENTITY_TABLE);
14046 }
14047
14048 query.append(orderByFields[i]);
14049
14050 if ((i + 1) < orderByFields.length) {
14051 if (orderByComparator.isAscending() ^ previous) {
14052 query.append(ORDER_BY_ASC_HAS_NEXT);
14053 }
14054 else {
14055 query.append(ORDER_BY_DESC_HAS_NEXT);
14056 }
14057 }
14058 else {
14059 if (orderByComparator.isAscending() ^ previous) {
14060 query.append(ORDER_BY_ASC);
14061 }
14062 else {
14063 query.append(ORDER_BY_DESC);
14064 }
14065 }
14066 }
14067 }
14068
14069 else {
14070 if (getDB().isSupportsInlineDistinct()) {
14071 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
14072 }
14073 else {
14074 query.append(MBMessageModelImpl.ORDER_BY_SQL);
14075 }
14076 }
14077
14078 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14079 MBMessage.class.getName(),
14080 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14081
14082 SQLQuery q = session.createSQLQuery(sql);
14083
14084 q.setFirstResult(0);
14085 q.setMaxResults(2);
14086
14087 if (getDB().isSupportsInlineDistinct()) {
14088 q.addEntity(_FILTER_ENTITY_ALIAS, MBMessageImpl.class);
14089 }
14090 else {
14091 q.addEntity(_FILTER_ENTITY_TABLE, MBMessageImpl.class);
14092 }
14093
14094 QueryPos qPos = QueryPos.getInstance(q);
14095
14096 qPos.add(groupId);
14097
14098 qPos.add(categoryId);
14099
14100 qPos.add(threadId);
14101
14102 qPos.add(status);
14103
14104 if (orderByComparator != null) {
14105 Object[] values = orderByComparator.getOrderByConditionValues(mbMessage);
14106
14107 for (Object value : values) {
14108 qPos.add(value);
14109 }
14110 }
14111
14112 List<MBMessage> list = q.list();
14113
14114 if (list.size() == 2) {
14115 return list.get(1);
14116 }
14117 else {
14118 return null;
14119 }
14120 }
14121
14122
14132 public List<MBMessage> findByU_C_C_S(long userId, long classNameId,
14133 long classPK, int status) throws SystemException {
14134 return findByU_C_C_S(userId, classNameId, classPK, status,
14135 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
14136 }
14137
14138
14154 public List<MBMessage> findByU_C_C_S(long userId, long classNameId,
14155 long classPK, int status, int start, int end) throws SystemException {
14156 return findByU_C_C_S(userId, classNameId, classPK, status, start, end,
14157 null);
14158 }
14159
14160
14177 public List<MBMessage> findByU_C_C_S(long userId, long classNameId,
14178 long classPK, int status, int start, int end,
14179 OrderByComparator orderByComparator) throws SystemException {
14180 FinderPath finderPath = null;
14181 Object[] finderArgs = null;
14182
14183 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
14184 (orderByComparator == null)) {
14185 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_C_S;
14186 finderArgs = new Object[] { userId, classNameId, classPK, status };
14187 }
14188 else {
14189 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C_C_S;
14190 finderArgs = new Object[] {
14191 userId, classNameId, classPK, status,
14192
14193 start, end, orderByComparator
14194 };
14195 }
14196
14197 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(finderPath,
14198 finderArgs, this);
14199
14200 if (list == null) {
14201 StringBundler query = null;
14202
14203 if (orderByComparator != null) {
14204 query = new StringBundler(6 +
14205 (orderByComparator.getOrderByFields().length * 3));
14206 }
14207 else {
14208 query = new StringBundler(6);
14209 }
14210
14211 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
14212
14213 query.append(_FINDER_COLUMN_U_C_C_S_USERID_2);
14214
14215 query.append(_FINDER_COLUMN_U_C_C_S_CLASSNAMEID_2);
14216
14217 query.append(_FINDER_COLUMN_U_C_C_S_CLASSPK_2);
14218
14219 query.append(_FINDER_COLUMN_U_C_C_S_STATUS_2);
14220
14221 if (orderByComparator != null) {
14222 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14223 orderByComparator);
14224 }
14225
14226 else {
14227 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
14228 }
14229
14230 String sql = query.toString();
14231
14232 Session session = null;
14233
14234 try {
14235 session = openSession();
14236
14237 Query q = session.createQuery(sql);
14238
14239 QueryPos qPos = QueryPos.getInstance(q);
14240
14241 qPos.add(userId);
14242
14243 qPos.add(classNameId);
14244
14245 qPos.add(classPK);
14246
14247 qPos.add(status);
14248
14249 list = (List<MBMessage>)QueryUtil.list(q, getDialect(), start,
14250 end);
14251 }
14252 catch (Exception e) {
14253 throw processException(e);
14254 }
14255 finally {
14256 if (list == null) {
14257 FinderCacheUtil.removeResult(finderPath, finderArgs);
14258 }
14259 else {
14260 cacheResult(list);
14261
14262 FinderCacheUtil.putResult(finderPath, finderArgs, list);
14263 }
14264
14265 closeSession(session);
14266 }
14267 }
14268
14269 return list;
14270 }
14271
14272
14288 public MBMessage findByU_C_C_S_First(long userId, long classNameId,
14289 long classPK, int status, OrderByComparator orderByComparator)
14290 throws NoSuchMessageException, SystemException {
14291 List<MBMessage> list = findByU_C_C_S(userId, classNameId, classPK,
14292 status, 0, 1, orderByComparator);
14293
14294 if (list.isEmpty()) {
14295 StringBundler msg = new StringBundler(10);
14296
14297 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14298
14299 msg.append("userId=");
14300 msg.append(userId);
14301
14302 msg.append(", classNameId=");
14303 msg.append(classNameId);
14304
14305 msg.append(", classPK=");
14306 msg.append(classPK);
14307
14308 msg.append(", status=");
14309 msg.append(status);
14310
14311 msg.append(StringPool.CLOSE_CURLY_BRACE);
14312
14313 throw new NoSuchMessageException(msg.toString());
14314 }
14315 else {
14316 return list.get(0);
14317 }
14318 }
14319
14320
14336 public MBMessage findByU_C_C_S_Last(long userId, long classNameId,
14337 long classPK, int status, OrderByComparator orderByComparator)
14338 throws NoSuchMessageException, SystemException {
14339 int count = countByU_C_C_S(userId, classNameId, classPK, status);
14340
14341 List<MBMessage> list = findByU_C_C_S(userId, classNameId, classPK,
14342 status, count - 1, count, orderByComparator);
14343
14344 if (list.isEmpty()) {
14345 StringBundler msg = new StringBundler(10);
14346
14347 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14348
14349 msg.append("userId=");
14350 msg.append(userId);
14351
14352 msg.append(", classNameId=");
14353 msg.append(classNameId);
14354
14355 msg.append(", classPK=");
14356 msg.append(classPK);
14357
14358 msg.append(", status=");
14359 msg.append(status);
14360
14361 msg.append(StringPool.CLOSE_CURLY_BRACE);
14362
14363 throw new NoSuchMessageException(msg.toString());
14364 }
14365 else {
14366 return list.get(0);
14367 }
14368 }
14369
14370
14387 public MBMessage[] findByU_C_C_S_PrevAndNext(long messageId, long userId,
14388 long classNameId, long classPK, int status,
14389 OrderByComparator orderByComparator)
14390 throws NoSuchMessageException, SystemException {
14391 MBMessage mbMessage = findByPrimaryKey(messageId);
14392
14393 Session session = null;
14394
14395 try {
14396 session = openSession();
14397
14398 MBMessage[] array = new MBMessageImpl[3];
14399
14400 array[0] = getByU_C_C_S_PrevAndNext(session, mbMessage, userId,
14401 classNameId, classPK, status, orderByComparator, true);
14402
14403 array[1] = mbMessage;
14404
14405 array[2] = getByU_C_C_S_PrevAndNext(session, mbMessage, userId,
14406 classNameId, classPK, status, orderByComparator, false);
14407
14408 return array;
14409 }
14410 catch (Exception e) {
14411 throw processException(e);
14412 }
14413 finally {
14414 closeSession(session);
14415 }
14416 }
14417
14418 protected MBMessage getByU_C_C_S_PrevAndNext(Session session,
14419 MBMessage mbMessage, long userId, long classNameId, long classPK,
14420 int status, OrderByComparator orderByComparator, boolean previous) {
14421 StringBundler query = null;
14422
14423 if (orderByComparator != null) {
14424 query = new StringBundler(6 +
14425 (orderByComparator.getOrderByFields().length * 6));
14426 }
14427 else {
14428 query = new StringBundler(3);
14429 }
14430
14431 query.append(_SQL_SELECT_MBMESSAGE_WHERE);
14432
14433 query.append(_FINDER_COLUMN_U_C_C_S_USERID_2);
14434
14435 query.append(_FINDER_COLUMN_U_C_C_S_CLASSNAMEID_2);
14436
14437 query.append(_FINDER_COLUMN_U_C_C_S_CLASSPK_2);
14438
14439 query.append(_FINDER_COLUMN_U_C_C_S_STATUS_2);
14440
14441 if (orderByComparator != null) {
14442 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14443
14444 if (orderByConditionFields.length > 0) {
14445 query.append(WHERE_AND);
14446 }
14447
14448 for (int i = 0; i < orderByConditionFields.length; i++) {
14449 query.append(_ORDER_BY_ENTITY_ALIAS);
14450 query.append(orderByConditionFields[i]);
14451
14452 if ((i + 1) < orderByConditionFields.length) {
14453 if (orderByComparator.isAscending() ^ previous) {
14454 query.append(WHERE_GREATER_THAN_HAS_NEXT);
14455 }
14456 else {
14457 query.append(WHERE_LESSER_THAN_HAS_NEXT);
14458 }
14459 }
14460 else {
14461 if (orderByComparator.isAscending() ^ previous) {
14462 query.append(WHERE_GREATER_THAN);
14463 }
14464 else {
14465 query.append(WHERE_LESSER_THAN);
14466 }
14467 }
14468 }
14469
14470 query.append(ORDER_BY_CLAUSE);
14471
14472 String[] orderByFields = orderByComparator.getOrderByFields();
14473
14474 for (int i = 0; i < orderByFields.length; i++) {
14475 query.append(_ORDER_BY_ENTITY_ALIAS);
14476 query.append(orderByFields[i]);
14477
14478 if ((i + 1) < orderByFields.length) {
14479 if (orderByComparator.isAscending() ^ previous) {
14480 query.append(ORDER_BY_ASC_HAS_NEXT);
14481 }
14482 else {
14483 query.append(ORDER_BY_DESC_HAS_NEXT);
14484 }
14485 }
14486 else {
14487 if (orderByComparator.isAscending() ^ previous) {
14488 query.append(ORDER_BY_ASC);
14489 }
14490 else {
14491 query.append(ORDER_BY_DESC);
14492 }
14493 }
14494 }
14495 }
14496
14497 else {
14498 query.append(MBMessageModelImpl.ORDER_BY_JPQL);
14499 }
14500
14501 String sql = query.toString();
14502
14503 Query q = session.createQuery(sql);
14504
14505 q.setFirstResult(0);
14506 q.setMaxResults(2);
14507
14508 QueryPos qPos = QueryPos.getInstance(q);
14509
14510 qPos.add(userId);
14511
14512 qPos.add(classNameId);
14513
14514 qPos.add(classPK);
14515
14516 qPos.add(status);
14517
14518 if (orderByComparator != null) {
14519 Object[] values = orderByComparator.getOrderByConditionValues(mbMessage);
14520
14521 for (Object value : values) {
14522 qPos.add(value);
14523 }
14524 }
14525
14526 List<MBMessage> list = q.list();
14527
14528 if (list.size() == 2) {
14529 return list.get(1);
14530 }
14531 else {
14532 return null;
14533 }
14534 }
14535
14536
14542 public List<MBMessage> findAll() throws SystemException {
14543 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
14544 }
14545
14546
14558 public List<MBMessage> findAll(int start, int end)
14559 throws SystemException {
14560 return findAll(start, end, null);
14561 }
14562
14563
14576 public List<MBMessage> findAll(int start, int end,
14577 OrderByComparator orderByComparator) throws SystemException {
14578 FinderPath finderPath = null;
14579 Object[] finderArgs = new Object[] { start, end, orderByComparator };
14580
14581 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
14582 (orderByComparator == null)) {
14583 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
14584 finderArgs = FINDER_ARGS_EMPTY;
14585 }
14586 else {
14587 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
14588 finderArgs = new Object[] { start, end, orderByComparator };
14589 }
14590
14591 List<MBMessage> list = (List<MBMessage>)FinderCacheUtil.getResult(finderPath,
14592 finderArgs, this);
14593
14594 if (list == null) {
14595 StringBundler query = null;
14596 String sql = null;
14597
14598 if (orderByComparator != null) {
14599 query = new StringBundler(2 +
14600 (orderByComparator.getOrderByFields().length * 3));
14601
14602 query.append(_SQL_SELECT_MBMESSAGE);
14603
14604 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14605 orderByComparator);
14606
14607 sql = query.toString();
14608 }
14609 else {
14610 sql = _SQL_SELECT_MBMESSAGE.concat(MBMessageModelImpl.ORDER_BY_JPQL);
14611 }
14612
14613 Session session = null;
14614
14615 try {
14616 session = openSession();
14617
14618 Query q = session.createQuery(sql);
14619
14620 if (orderByComparator == null) {
14621 list = (List<MBMessage>)QueryUtil.list(q, getDialect(),
14622 start, end, false);
14623
14624 Collections.sort(list);
14625 }
14626 else {
14627 list = (List<MBMessage>)QueryUtil.list(q, getDialect(),
14628 start, end);
14629 }
14630 }
14631 catch (Exception e) {
14632 throw processException(e);
14633 }
14634 finally {
14635 if (list == null) {
14636 FinderCacheUtil.removeResult(finderPath, finderArgs);
14637 }
14638 else {
14639 cacheResult(list);
14640
14641 FinderCacheUtil.putResult(finderPath, finderArgs, list);
14642 }
14643
14644 closeSession(session);
14645 }
14646 }
14647
14648 return list;
14649 }
14650
14651
14657 public void removeByUuid(String uuid) throws SystemException {
14658 for (MBMessage mbMessage : findByUuid(uuid)) {
14659 remove(mbMessage);
14660 }
14661 }
14662
14663
14670 public void removeByUUID_G(String uuid, long groupId)
14671 throws NoSuchMessageException, SystemException {
14672 MBMessage mbMessage = findByUUID_G(uuid, groupId);
14673
14674 remove(mbMessage);
14675 }
14676
14677
14683 public void removeByGroupId(long groupId) throws SystemException {
14684 for (MBMessage mbMessage : findByGroupId(groupId)) {
14685 remove(mbMessage);
14686 }
14687 }
14688
14689
14695 public void removeByCompanyId(long companyId) throws SystemException {
14696 for (MBMessage mbMessage : findByCompanyId(companyId)) {
14697 remove(mbMessage);
14698 }
14699 }
14700
14701
14707 public void removeByThreadId(long threadId) throws SystemException {
14708 for (MBMessage mbMessage : findByThreadId(threadId)) {
14709 remove(mbMessage);
14710 }
14711 }
14712
14713
14719 public void removeByThreadReplies(long threadId) throws SystemException {
14720 for (MBMessage mbMessage : findByThreadReplies(threadId)) {
14721 remove(mbMessage);
14722 }
14723 }
14724
14725
14731 public void removeByUserId(long userId) throws SystemException {
14732 for (MBMessage mbMessage : findByUserId(userId)) {
14733 remove(mbMessage);
14734 }
14735 }
14736
14737
14744 public void removeByG_U(long groupId, long userId)
14745 throws SystemException {
14746 for (MBMessage mbMessage : findByG_U(groupId, userId)) {
14747 remove(mbMessage);
14748 }
14749 }
14750
14751
14758 public void removeByG_C(long groupId, long categoryId)
14759 throws SystemException {
14760 for (MBMessage mbMessage : findByG_C(groupId, categoryId)) {
14761 remove(mbMessage);
14762 }
14763 }
14764
14765
14772 public void removeByG_S(long groupId, int status) throws SystemException {
14773 for (MBMessage mbMessage : findByG_S(groupId, status)) {
14774 remove(mbMessage);
14775 }
14776 }
14777
14778
14785 public void removeByC_S(long companyId, int status)
14786 throws SystemException {
14787 for (MBMessage mbMessage : findByC_S(companyId, status)) {
14788 remove(mbMessage);
14789 }
14790 }
14791
14792
14799 public void removeByU_C(long userId, long classNameId)
14800 throws SystemException {
14801 for (MBMessage mbMessage : findByU_C(userId, classNameId)) {
14802 remove(mbMessage);
14803 }
14804 }
14805
14806
14813 public void removeByC_C(long classNameId, long classPK)
14814 throws SystemException {
14815 for (MBMessage mbMessage : findByC_C(classNameId, classPK)) {
14816 remove(mbMessage);
14817 }
14818 }
14819
14820
14827 public void removeByT_P(long threadId, long parentMessageId)
14828 throws SystemException {
14829 for (MBMessage mbMessage : findByT_P(threadId, parentMessageId)) {
14830 remove(mbMessage);
14831 }
14832 }
14833
14834
14841 public void removeByT_A(long threadId, boolean answer)
14842 throws SystemException {
14843 for (MBMessage mbMessage : findByT_A(threadId, answer)) {
14844 remove(mbMessage);
14845 }
14846 }
14847
14848
14855 public void removeByT_S(long threadId, int status)
14856 throws SystemException {
14857 for (MBMessage mbMessage : findByT_S(threadId, status)) {
14858 remove(mbMessage);
14859 }
14860 }
14861
14862
14869 public void removeByTR_S(long threadId, int status)
14870 throws SystemException {
14871 for (MBMessage mbMessage : findByTR_S(threadId, status)) {
14872 remove(mbMessage);
14873 }
14874 }
14875
14876
14884 public void removeByG_U_S(long groupId, long userId, int status)
14885 throws SystemException {
14886 for (MBMessage mbMessage : findByG_U_S(groupId, userId, status)) {
14887 remove(mbMessage);
14888 }
14889 }
14890
14891
14899 public void removeByG_C_T(long groupId, long categoryId, long threadId)
14900 throws SystemException {
14901 for (MBMessage mbMessage : findByG_C_T(groupId, categoryId, threadId)) {
14902 remove(mbMessage);
14903 }
14904 }
14905
14906
14914 public void removeByG_C_S(long groupId, long categoryId, int status)
14915 throws SystemException {
14916 for (MBMessage mbMessage : findByG_C_S(groupId, categoryId, status)) {
14917 remove(mbMessage);
14918 }
14919 }
14920
14921
14929 public void removeByU_C_C(long userId, long classNameId, long classPK)
14930 throws SystemException {
14931 for (MBMessage mbMessage : findByU_C_C(userId, classNameId, classPK)) {
14932 remove(mbMessage);
14933 }
14934 }
14935
14936
14944 public void removeByU_C_S(long userId, long classNameId, int status)
14945 throws SystemException {
14946 for (MBMessage mbMessage : findByU_C_S(userId, classNameId, status)) {
14947 remove(mbMessage);
14948 }
14949 }
14950
14951
14959 public void removeByC_C_S(long classNameId, long classPK, int status)
14960 throws SystemException {
14961 for (MBMessage mbMessage : findByC_C_S(classNameId, classPK, status)) {
14962 remove(mbMessage);
14963 }
14964 }
14965
14966
14975 public void removeByG_C_T_A(long groupId, long categoryId, long threadId,
14976 boolean answer) throws SystemException {
14977 for (MBMessage mbMessage : findByG_C_T_A(groupId, categoryId, threadId,
14978 answer)) {
14979 remove(mbMessage);
14980 }
14981 }
14982
14983
14992 public void removeByG_C_T_S(long groupId, long categoryId, long threadId,
14993 int status) throws SystemException {
14994 for (MBMessage mbMessage : findByG_C_T_S(groupId, categoryId, threadId,
14995 status)) {
14996 remove(mbMessage);
14997 }
14998 }
14999
15000
15009 public void removeByU_C_C_S(long userId, long classNameId, long classPK,
15010 int status) throws SystemException {
15011 for (MBMessage mbMessage : findByU_C_C_S(userId, classNameId, classPK,
15012 status)) {
15013 remove(mbMessage);
15014 }
15015 }
15016
15017
15022 public void removeAll() throws SystemException {
15023 for (MBMessage mbMessage : findAll()) {
15024 remove(mbMessage);
15025 }
15026 }
15027
15028
15035 public int countByUuid(String uuid) throws SystemException {
15036 Object[] finderArgs = new Object[] { uuid };
15037
15038 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
15039 finderArgs, this);
15040
15041 if (count == null) {
15042 StringBundler query = new StringBundler(2);
15043
15044 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
15045
15046 if (uuid == null) {
15047 query.append(_FINDER_COLUMN_UUID_UUID_1);
15048 }
15049 else {
15050 if (uuid.equals(StringPool.BLANK)) {
15051 query.append(_FINDER_COLUMN_UUID_UUID_3);
15052 }
15053 else {
15054 query.append(_FINDER_COLUMN_UUID_UUID_2);
15055 }
15056 }
15057
15058 String sql = query.toString();
15059
15060 Session session = null;
15061
15062 try {
15063 session = openSession();
15064
15065 Query q = session.createQuery(sql);
15066
15067 QueryPos qPos = QueryPos.getInstance(q);
15068
15069 if (uuid != null) {
15070 qPos.add(uuid);
15071 }
15072
15073 count = (Long)q.uniqueResult();
15074 }
15075 catch (Exception e) {
15076 throw processException(e);
15077 }
15078 finally {
15079 if (count == null) {
15080 count = Long.valueOf(0);
15081 }
15082
15083 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
15084 finderArgs, count);
15085
15086 closeSession(session);
15087 }
15088 }
15089
15090 return count.intValue();
15091 }
15092
15093
15101 public int countByUUID_G(String uuid, long groupId)
15102 throws SystemException {
15103 Object[] finderArgs = new Object[] { uuid, groupId };
15104
15105 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
15106 finderArgs, this);
15107
15108 if (count == null) {
15109 StringBundler query = new StringBundler(3);
15110
15111 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
15112
15113 if (uuid == null) {
15114 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
15115 }
15116 else {
15117 if (uuid.equals(StringPool.BLANK)) {
15118 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
15119 }
15120 else {
15121 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
15122 }
15123 }
15124
15125 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
15126
15127 String sql = query.toString();
15128
15129 Session session = null;
15130
15131 try {
15132 session = openSession();
15133
15134 Query q = session.createQuery(sql);
15135
15136 QueryPos qPos = QueryPos.getInstance(q);
15137
15138 if (uuid != null) {
15139 qPos.add(uuid);
15140 }
15141
15142 qPos.add(groupId);
15143
15144 count = (Long)q.uniqueResult();
15145 }
15146 catch (Exception e) {
15147 throw processException(e);
15148 }
15149 finally {
15150 if (count == null) {
15151 count = Long.valueOf(0);
15152 }
15153
15154 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
15155 finderArgs, count);
15156
15157 closeSession(session);
15158 }
15159 }
15160
15161 return count.intValue();
15162 }
15163
15164
15171 public int countByGroupId(long groupId) throws SystemException {
15172 Object[] finderArgs = new Object[] { groupId };
15173
15174 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
15175 finderArgs, this);
15176
15177 if (count == null) {
15178 StringBundler query = new StringBundler(2);
15179
15180 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
15181
15182 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
15183
15184 String sql = query.toString();
15185
15186 Session session = null;
15187
15188 try {
15189 session = openSession();
15190
15191 Query q = session.createQuery(sql);
15192
15193 QueryPos qPos = QueryPos.getInstance(q);
15194
15195 qPos.add(groupId);
15196
15197 count = (Long)q.uniqueResult();
15198 }
15199 catch (Exception e) {
15200 throw processException(e);
15201 }
15202 finally {
15203 if (count == null) {
15204 count = Long.valueOf(0);
15205 }
15206
15207 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
15208 finderArgs, count);
15209
15210 closeSession(session);
15211 }
15212 }
15213
15214 return count.intValue();
15215 }
15216
15217
15224 public int filterCountByGroupId(long groupId) throws SystemException {
15225 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15226 return countByGroupId(groupId);
15227 }
15228
15229 StringBundler query = new StringBundler(2);
15230
15231 query.append(_FILTER_SQL_COUNT_MBMESSAGE_WHERE);
15232
15233 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
15234
15235 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15236 MBMessage.class.getName(),
15237 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15238
15239 Session session = null;
15240
15241 try {
15242 session = openSession();
15243
15244 SQLQuery q = session.createSQLQuery(sql);
15245
15246 q.addScalar(COUNT_COLUMN_NAME,
15247 com.liferay.portal.kernel.dao.orm.Type.LONG);
15248
15249 QueryPos qPos = QueryPos.getInstance(q);
15250
15251 qPos.add(groupId);
15252
15253 Long count = (Long)q.uniqueResult();
15254
15255 return count.intValue();
15256 }
15257 catch (Exception e) {
15258 throw processException(e);
15259 }
15260 finally {
15261 closeSession(session);
15262 }
15263 }
15264
15265
15272 public int countByCompanyId(long companyId) throws SystemException {
15273 Object[] finderArgs = new Object[] { companyId };
15274
15275 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
15276 finderArgs, this);
15277
15278 if (count == null) {
15279 StringBundler query = new StringBundler(2);
15280
15281 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
15282
15283 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
15284
15285 String sql = query.toString();
15286
15287 Session session = null;
15288
15289 try {
15290 session = openSession();
15291
15292 Query q = session.createQuery(sql);
15293
15294 QueryPos qPos = QueryPos.getInstance(q);
15295
15296 qPos.add(companyId);
15297
15298 count = (Long)q.uniqueResult();
15299 }
15300 catch (Exception e) {
15301 throw processException(e);
15302 }
15303 finally {
15304 if (count == null) {
15305 count = Long.valueOf(0);
15306 }
15307
15308 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
15309 finderArgs, count);
15310
15311 closeSession(session);
15312 }
15313 }
15314
15315 return count.intValue();
15316 }
15317
15318
15325 public int countByThreadId(long threadId) throws SystemException {
15326 Object[] finderArgs = new Object[] { threadId };
15327
15328 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_THREADID,
15329 finderArgs, this);
15330
15331 if (count == null) {
15332 StringBundler query = new StringBundler(2);
15333
15334 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
15335
15336 query.append(_FINDER_COLUMN_THREADID_THREADID_2);
15337
15338 String sql = query.toString();
15339
15340 Session session = null;
15341
15342 try {
15343 session = openSession();
15344
15345 Query q = session.createQuery(sql);
15346
15347 QueryPos qPos = QueryPos.getInstance(q);
15348
15349 qPos.add(threadId);
15350
15351 count = (Long)q.uniqueResult();
15352 }
15353 catch (Exception e) {
15354 throw processException(e);
15355 }
15356 finally {
15357 if (count == null) {
15358 count = Long.valueOf(0);
15359 }
15360
15361 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_THREADID,
15362 finderArgs, count);
15363
15364 closeSession(session);
15365 }
15366 }
15367
15368 return count.intValue();
15369 }
15370
15371
15378 public int countByThreadReplies(long threadId) throws SystemException {
15379 Object[] finderArgs = new Object[] { threadId };
15380
15381 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_THREADREPLIES,
15382 finderArgs, this);
15383
15384 if (count == null) {
15385 StringBundler query = new StringBundler(2);
15386
15387 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
15388
15389 query.append(_FINDER_COLUMN_THREADREPLIES_THREADID_2);
15390
15391 String sql = query.toString();
15392
15393 Session session = null;
15394
15395 try {
15396 session = openSession();
15397
15398 Query q = session.createQuery(sql);
15399
15400 QueryPos qPos = QueryPos.getInstance(q);
15401
15402 qPos.add(threadId);
15403
15404 count = (Long)q.uniqueResult();
15405 }
15406 catch (Exception e) {
15407 throw processException(e);
15408 }
15409 finally {
15410 if (count == null) {
15411 count = Long.valueOf(0);
15412 }
15413
15414 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_THREADREPLIES,
15415 finderArgs, count);
15416
15417 closeSession(session);
15418 }
15419 }
15420
15421 return count.intValue();
15422 }
15423
15424
15431 public int countByUserId(long userId) throws SystemException {
15432 Object[] finderArgs = new Object[] { userId };
15433
15434 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
15435 finderArgs, this);
15436
15437 if (count == null) {
15438 StringBundler query = new StringBundler(2);
15439
15440 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
15441
15442 query.append(_FINDER_COLUMN_USERID_USERID_2);
15443
15444 String sql = query.toString();
15445
15446 Session session = null;
15447
15448 try {
15449 session = openSession();
15450
15451 Query q = session.createQuery(sql);
15452
15453 QueryPos qPos = QueryPos.getInstance(q);
15454
15455 qPos.add(userId);
15456
15457 count = (Long)q.uniqueResult();
15458 }
15459 catch (Exception e) {
15460 throw processException(e);
15461 }
15462 finally {
15463 if (count == null) {
15464 count = Long.valueOf(0);
15465 }
15466
15467 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
15468 finderArgs, count);
15469
15470 closeSession(session);
15471 }
15472 }
15473
15474 return count.intValue();
15475 }
15476
15477
15485 public int countByG_U(long groupId, long userId) throws SystemException {
15486 Object[] finderArgs = new Object[] { groupId, userId };
15487
15488 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U,
15489 finderArgs, this);
15490
15491 if (count == null) {
15492 StringBundler query = new StringBundler(3);
15493
15494 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
15495
15496 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
15497
15498 query.append(_FINDER_COLUMN_G_U_USERID_2);
15499
15500 String sql = query.toString();
15501
15502 Session session = null;
15503
15504 try {
15505 session = openSession();
15506
15507 Query q = session.createQuery(sql);
15508
15509 QueryPos qPos = QueryPos.getInstance(q);
15510
15511 qPos.add(groupId);
15512
15513 qPos.add(userId);
15514
15515 count = (Long)q.uniqueResult();
15516 }
15517 catch (Exception e) {
15518 throw processException(e);
15519 }
15520 finally {
15521 if (count == null) {
15522 count = Long.valueOf(0);
15523 }
15524
15525 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U, finderArgs,
15526 count);
15527
15528 closeSession(session);
15529 }
15530 }
15531
15532 return count.intValue();
15533 }
15534
15535
15543 public int filterCountByG_U(long groupId, long userId)
15544 throws SystemException {
15545 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15546 return countByG_U(groupId, userId);
15547 }
15548
15549 StringBundler query = new StringBundler(3);
15550
15551 query.append(_FILTER_SQL_COUNT_MBMESSAGE_WHERE);
15552
15553 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
15554
15555 query.append(_FINDER_COLUMN_G_U_USERID_2);
15556
15557 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15558 MBMessage.class.getName(),
15559 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15560
15561 Session session = null;
15562
15563 try {
15564 session = openSession();
15565
15566 SQLQuery q = session.createSQLQuery(sql);
15567
15568 q.addScalar(COUNT_COLUMN_NAME,
15569 com.liferay.portal.kernel.dao.orm.Type.LONG);
15570
15571 QueryPos qPos = QueryPos.getInstance(q);
15572
15573 qPos.add(groupId);
15574
15575 qPos.add(userId);
15576
15577 Long count = (Long)q.uniqueResult();
15578
15579 return count.intValue();
15580 }
15581 catch (Exception e) {
15582 throw processException(e);
15583 }
15584 finally {
15585 closeSession(session);
15586 }
15587 }
15588
15589
15597 public int countByG_C(long groupId, long categoryId)
15598 throws SystemException {
15599 Object[] finderArgs = new Object[] { groupId, categoryId };
15600
15601 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C,
15602 finderArgs, this);
15603
15604 if (count == null) {
15605 StringBundler query = new StringBundler(3);
15606
15607 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
15608
15609 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
15610
15611 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
15612
15613 String sql = query.toString();
15614
15615 Session session = null;
15616
15617 try {
15618 session = openSession();
15619
15620 Query q = session.createQuery(sql);
15621
15622 QueryPos qPos = QueryPos.getInstance(q);
15623
15624 qPos.add(groupId);
15625
15626 qPos.add(categoryId);
15627
15628 count = (Long)q.uniqueResult();
15629 }
15630 catch (Exception e) {
15631 throw processException(e);
15632 }
15633 finally {
15634 if (count == null) {
15635 count = Long.valueOf(0);
15636 }
15637
15638 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C, finderArgs,
15639 count);
15640
15641 closeSession(session);
15642 }
15643 }
15644
15645 return count.intValue();
15646 }
15647
15648
15656 public int filterCountByG_C(long groupId, long categoryId)
15657 throws SystemException {
15658 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15659 return countByG_C(groupId, categoryId);
15660 }
15661
15662 StringBundler query = new StringBundler(3);
15663
15664 query.append(_FILTER_SQL_COUNT_MBMESSAGE_WHERE);
15665
15666 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
15667
15668 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
15669
15670 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15671 MBMessage.class.getName(),
15672 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15673
15674 Session session = null;
15675
15676 try {
15677 session = openSession();
15678
15679 SQLQuery q = session.createSQLQuery(sql);
15680
15681 q.addScalar(COUNT_COLUMN_NAME,
15682 com.liferay.portal.kernel.dao.orm.Type.LONG);
15683
15684 QueryPos qPos = QueryPos.getInstance(q);
15685
15686 qPos.add(groupId);
15687
15688 qPos.add(categoryId);
15689
15690 Long count = (Long)q.uniqueResult();
15691
15692 return count.intValue();
15693 }
15694 catch (Exception e) {
15695 throw processException(e);
15696 }
15697 finally {
15698 closeSession(session);
15699 }
15700 }
15701
15702
15710 public int countByG_S(long groupId, int status) throws SystemException {
15711 Object[] finderArgs = new Object[] { groupId, status };
15712
15713 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_S,
15714 finderArgs, this);
15715
15716 if (count == null) {
15717 StringBundler query = new StringBundler(3);
15718
15719 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
15720
15721 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
15722
15723 query.append(_FINDER_COLUMN_G_S_STATUS_2);
15724
15725 String sql = query.toString();
15726
15727 Session session = null;
15728
15729 try {
15730 session = openSession();
15731
15732 Query q = session.createQuery(sql);
15733
15734 QueryPos qPos = QueryPos.getInstance(q);
15735
15736 qPos.add(groupId);
15737
15738 qPos.add(status);
15739
15740 count = (Long)q.uniqueResult();
15741 }
15742 catch (Exception e) {
15743 throw processException(e);
15744 }
15745 finally {
15746 if (count == null) {
15747 count = Long.valueOf(0);
15748 }
15749
15750 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_S, finderArgs,
15751 count);
15752
15753 closeSession(session);
15754 }
15755 }
15756
15757 return count.intValue();
15758 }
15759
15760
15768 public int filterCountByG_S(long groupId, int status)
15769 throws SystemException {
15770 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15771 return countByG_S(groupId, status);
15772 }
15773
15774 StringBundler query = new StringBundler(3);
15775
15776 query.append(_FILTER_SQL_COUNT_MBMESSAGE_WHERE);
15777
15778 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
15779
15780 query.append(_FINDER_COLUMN_G_S_STATUS_2);
15781
15782 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15783 MBMessage.class.getName(),
15784 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15785
15786 Session session = null;
15787
15788 try {
15789 session = openSession();
15790
15791 SQLQuery q = session.createSQLQuery(sql);
15792
15793 q.addScalar(COUNT_COLUMN_NAME,
15794 com.liferay.portal.kernel.dao.orm.Type.LONG);
15795
15796 QueryPos qPos = QueryPos.getInstance(q);
15797
15798 qPos.add(groupId);
15799
15800 qPos.add(status);
15801
15802 Long count = (Long)q.uniqueResult();
15803
15804 return count.intValue();
15805 }
15806 catch (Exception e) {
15807 throw processException(e);
15808 }
15809 finally {
15810 closeSession(session);
15811 }
15812 }
15813
15814
15822 public int countByC_S(long companyId, int status) throws SystemException {
15823 Object[] finderArgs = new Object[] { companyId, status };
15824
15825 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_S,
15826 finderArgs, this);
15827
15828 if (count == null) {
15829 StringBundler query = new StringBundler(3);
15830
15831 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
15832
15833 query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
15834
15835 query.append(_FINDER_COLUMN_C_S_STATUS_2);
15836
15837 String sql = query.toString();
15838
15839 Session session = null;
15840
15841 try {
15842 session = openSession();
15843
15844 Query q = session.createQuery(sql);
15845
15846 QueryPos qPos = QueryPos.getInstance(q);
15847
15848 qPos.add(companyId);
15849
15850 qPos.add(status);
15851
15852 count = (Long)q.uniqueResult();
15853 }
15854 catch (Exception e) {
15855 throw processException(e);
15856 }
15857 finally {
15858 if (count == null) {
15859 count = Long.valueOf(0);
15860 }
15861
15862 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_S, finderArgs,
15863 count);
15864
15865 closeSession(session);
15866 }
15867 }
15868
15869 return count.intValue();
15870 }
15871
15872
15880 public int countByU_C(long userId, long classNameId)
15881 throws SystemException {
15882 Object[] finderArgs = new Object[] { userId, classNameId };
15883
15884 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_C,
15885 finderArgs, this);
15886
15887 if (count == null) {
15888 StringBundler query = new StringBundler(3);
15889
15890 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
15891
15892 query.append(_FINDER_COLUMN_U_C_USERID_2);
15893
15894 query.append(_FINDER_COLUMN_U_C_CLASSNAMEID_2);
15895
15896 String sql = query.toString();
15897
15898 Session session = null;
15899
15900 try {
15901 session = openSession();
15902
15903 Query q = session.createQuery(sql);
15904
15905 QueryPos qPos = QueryPos.getInstance(q);
15906
15907 qPos.add(userId);
15908
15909 qPos.add(classNameId);
15910
15911 count = (Long)q.uniqueResult();
15912 }
15913 catch (Exception e) {
15914 throw processException(e);
15915 }
15916 finally {
15917 if (count == null) {
15918 count = Long.valueOf(0);
15919 }
15920
15921 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_C, finderArgs,
15922 count);
15923
15924 closeSession(session);
15925 }
15926 }
15927
15928 return count.intValue();
15929 }
15930
15931
15939 public int countByU_C(long userId, long[] classNameIds)
15940 throws SystemException {
15941 Object[] finderArgs = new Object[] {
15942 userId, StringUtil.merge(classNameIds)
15943 };
15944
15945 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_C,
15946 finderArgs, this);
15947
15948 if (count == null) {
15949 StringBundler query = new StringBundler();
15950
15951 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
15952
15953 boolean conjunctionable = false;
15954
15955 if (conjunctionable) {
15956 query.append(WHERE_AND);
15957 }
15958
15959 query.append(_FINDER_COLUMN_U_C_USERID_5);
15960
15961 conjunctionable = true;
15962
15963 if ((classNameIds == null) || (classNameIds.length > 0)) {
15964 if (conjunctionable) {
15965 query.append(WHERE_AND);
15966 }
15967
15968 query.append(StringPool.OPEN_PARENTHESIS);
15969
15970 for (int i = 0; i < classNameIds.length; i++) {
15971 query.append(_FINDER_COLUMN_U_C_CLASSNAMEID_5);
15972
15973 if ((i + 1) < classNameIds.length) {
15974 query.append(WHERE_OR);
15975 }
15976 }
15977
15978 query.append(StringPool.CLOSE_PARENTHESIS);
15979
15980 conjunctionable = true;
15981 }
15982
15983 String sql = query.toString();
15984
15985 Session session = null;
15986
15987 try {
15988 session = openSession();
15989
15990 Query q = session.createQuery(sql);
15991
15992 QueryPos qPos = QueryPos.getInstance(q);
15993
15994 qPos.add(userId);
15995
15996 if (classNameIds != null) {
15997 qPos.add(classNameIds);
15998 }
15999
16000 count = (Long)q.uniqueResult();
16001 }
16002 catch (Exception e) {
16003 throw processException(e);
16004 }
16005 finally {
16006 if (count == null) {
16007 count = Long.valueOf(0);
16008 }
16009
16010 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_C, finderArgs,
16011 count);
16012
16013 closeSession(session);
16014 }
16015 }
16016
16017 return count.intValue();
16018 }
16019
16020
16028 public int countByC_C(long classNameId, long classPK)
16029 throws SystemException {
16030 Object[] finderArgs = new Object[] { classNameId, classPK };
16031
16032 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
16033 finderArgs, this);
16034
16035 if (count == null) {
16036 StringBundler query = new StringBundler(3);
16037
16038 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
16039
16040 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
16041
16042 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
16043
16044 String sql = query.toString();
16045
16046 Session session = null;
16047
16048 try {
16049 session = openSession();
16050
16051 Query q = session.createQuery(sql);
16052
16053 QueryPos qPos = QueryPos.getInstance(q);
16054
16055 qPos.add(classNameId);
16056
16057 qPos.add(classPK);
16058
16059 count = (Long)q.uniqueResult();
16060 }
16061 catch (Exception e) {
16062 throw processException(e);
16063 }
16064 finally {
16065 if (count == null) {
16066 count = Long.valueOf(0);
16067 }
16068
16069 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
16070 count);
16071
16072 closeSession(session);
16073 }
16074 }
16075
16076 return count.intValue();
16077 }
16078
16079
16087 public int countByT_P(long threadId, long parentMessageId)
16088 throws SystemException {
16089 Object[] finderArgs = new Object[] { threadId, parentMessageId };
16090
16091 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_T_P,
16092 finderArgs, this);
16093
16094 if (count == null) {
16095 StringBundler query = new StringBundler(3);
16096
16097 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
16098
16099 query.append(_FINDER_COLUMN_T_P_THREADID_2);
16100
16101 query.append(_FINDER_COLUMN_T_P_PARENTMESSAGEID_2);
16102
16103 String sql = query.toString();
16104
16105 Session session = null;
16106
16107 try {
16108 session = openSession();
16109
16110 Query q = session.createQuery(sql);
16111
16112 QueryPos qPos = QueryPos.getInstance(q);
16113
16114 qPos.add(threadId);
16115
16116 qPos.add(parentMessageId);
16117
16118 count = (Long)q.uniqueResult();
16119 }
16120 catch (Exception e) {
16121 throw processException(e);
16122 }
16123 finally {
16124 if (count == null) {
16125 count = Long.valueOf(0);
16126 }
16127
16128 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_T_P, finderArgs,
16129 count);
16130
16131 closeSession(session);
16132 }
16133 }
16134
16135 return count.intValue();
16136 }
16137
16138
16146 public int countByT_A(long threadId, boolean answer)
16147 throws SystemException {
16148 Object[] finderArgs = new Object[] { threadId, answer };
16149
16150 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_T_A,
16151 finderArgs, this);
16152
16153 if (count == null) {
16154 StringBundler query = new StringBundler(3);
16155
16156 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
16157
16158 query.append(_FINDER_COLUMN_T_A_THREADID_2);
16159
16160 query.append(_FINDER_COLUMN_T_A_ANSWER_2);
16161
16162 String sql = query.toString();
16163
16164 Session session = null;
16165
16166 try {
16167 session = openSession();
16168
16169 Query q = session.createQuery(sql);
16170
16171 QueryPos qPos = QueryPos.getInstance(q);
16172
16173 qPos.add(threadId);
16174
16175 qPos.add(answer);
16176
16177 count = (Long)q.uniqueResult();
16178 }
16179 catch (Exception e) {
16180 throw processException(e);
16181 }
16182 finally {
16183 if (count == null) {
16184 count = Long.valueOf(0);
16185 }
16186
16187 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_T_A, finderArgs,
16188 count);
16189
16190 closeSession(session);
16191 }
16192 }
16193
16194 return count.intValue();
16195 }
16196
16197
16205 public int countByT_S(long threadId, int status) throws SystemException {
16206 Object[] finderArgs = new Object[] { threadId, status };
16207
16208 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_T_S,
16209 finderArgs, this);
16210
16211 if (count == null) {
16212 StringBundler query = new StringBundler(3);
16213
16214 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
16215
16216 query.append(_FINDER_COLUMN_T_S_THREADID_2);
16217
16218 query.append(_FINDER_COLUMN_T_S_STATUS_2);
16219
16220 String sql = query.toString();
16221
16222 Session session = null;
16223
16224 try {
16225 session = openSession();
16226
16227 Query q = session.createQuery(sql);
16228
16229 QueryPos qPos = QueryPos.getInstance(q);
16230
16231 qPos.add(threadId);
16232
16233 qPos.add(status);
16234
16235 count = (Long)q.uniqueResult();
16236 }
16237 catch (Exception e) {
16238 throw processException(e);
16239 }
16240 finally {
16241 if (count == null) {
16242 count = Long.valueOf(0);
16243 }
16244
16245 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_T_S, finderArgs,
16246 count);
16247
16248 closeSession(session);
16249 }
16250 }
16251
16252 return count.intValue();
16253 }
16254
16255
16263 public int countByTR_S(long threadId, int status) throws SystemException {
16264 Object[] finderArgs = new Object[] { threadId, status };
16265
16266 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_TR_S,
16267 finderArgs, this);
16268
16269 if (count == null) {
16270 StringBundler query = new StringBundler(3);
16271
16272 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
16273
16274 query.append(_FINDER_COLUMN_TR_S_THREADID_2);
16275
16276 query.append(_FINDER_COLUMN_TR_S_STATUS_2);
16277
16278 String sql = query.toString();
16279
16280 Session session = null;
16281
16282 try {
16283 session = openSession();
16284
16285 Query q = session.createQuery(sql);
16286
16287 QueryPos qPos = QueryPos.getInstance(q);
16288
16289 qPos.add(threadId);
16290
16291 qPos.add(status);
16292
16293 count = (Long)q.uniqueResult();
16294 }
16295 catch (Exception e) {
16296 throw processException(e);
16297 }
16298 finally {
16299 if (count == null) {
16300 count = Long.valueOf(0);
16301 }
16302
16303 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_TR_S,
16304 finderArgs, count);
16305
16306 closeSession(session);
16307 }
16308 }
16309
16310 return count.intValue();
16311 }
16312
16313
16322 public int countByG_U_S(long groupId, long userId, int status)
16323 throws SystemException {
16324 Object[] finderArgs = new Object[] { groupId, userId, status };
16325
16326 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U_S,
16327 finderArgs, this);
16328
16329 if (count == null) {
16330 StringBundler query = new StringBundler(4);
16331
16332 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
16333
16334 query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
16335
16336 query.append(_FINDER_COLUMN_G_U_S_USERID_2);
16337
16338 query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
16339
16340 String sql = query.toString();
16341
16342 Session session = null;
16343
16344 try {
16345 session = openSession();
16346
16347 Query q = session.createQuery(sql);
16348
16349 QueryPos qPos = QueryPos.getInstance(q);
16350
16351 qPos.add(groupId);
16352
16353 qPos.add(userId);
16354
16355 qPos.add(status);
16356
16357 count = (Long)q.uniqueResult();
16358 }
16359 catch (Exception e) {
16360 throw processException(e);
16361 }
16362 finally {
16363 if (count == null) {
16364 count = Long.valueOf(0);
16365 }
16366
16367 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U_S,
16368 finderArgs, count);
16369
16370 closeSession(session);
16371 }
16372 }
16373
16374 return count.intValue();
16375 }
16376
16377
16386 public int filterCountByG_U_S(long groupId, long userId, int status)
16387 throws SystemException {
16388 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16389 return countByG_U_S(groupId, userId, status);
16390 }
16391
16392 StringBundler query = new StringBundler(4);
16393
16394 query.append(_FILTER_SQL_COUNT_MBMESSAGE_WHERE);
16395
16396 query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
16397
16398 query.append(_FINDER_COLUMN_G_U_S_USERID_2);
16399
16400 query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
16401
16402 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16403 MBMessage.class.getName(),
16404 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16405
16406 Session session = null;
16407
16408 try {
16409 session = openSession();
16410
16411 SQLQuery q = session.createSQLQuery(sql);
16412
16413 q.addScalar(COUNT_COLUMN_NAME,
16414 com.liferay.portal.kernel.dao.orm.Type.LONG);
16415
16416 QueryPos qPos = QueryPos.getInstance(q);
16417
16418 qPos.add(groupId);
16419
16420 qPos.add(userId);
16421
16422 qPos.add(status);
16423
16424 Long count = (Long)q.uniqueResult();
16425
16426 return count.intValue();
16427 }
16428 catch (Exception e) {
16429 throw processException(e);
16430 }
16431 finally {
16432 closeSession(session);
16433 }
16434 }
16435
16436
16445 public int countByG_C_T(long groupId, long categoryId, long threadId)
16446 throws SystemException {
16447 Object[] finderArgs = new Object[] { groupId, categoryId, threadId };
16448
16449 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_T,
16450 finderArgs, this);
16451
16452 if (count == null) {
16453 StringBundler query = new StringBundler(4);
16454
16455 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
16456
16457 query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
16458
16459 query.append(_FINDER_COLUMN_G_C_T_CATEGORYID_2);
16460
16461 query.append(_FINDER_COLUMN_G_C_T_THREADID_2);
16462
16463 String sql = query.toString();
16464
16465 Session session = null;
16466
16467 try {
16468 session = openSession();
16469
16470 Query q = session.createQuery(sql);
16471
16472 QueryPos qPos = QueryPos.getInstance(q);
16473
16474 qPos.add(groupId);
16475
16476 qPos.add(categoryId);
16477
16478 qPos.add(threadId);
16479
16480 count = (Long)q.uniqueResult();
16481 }
16482 catch (Exception e) {
16483 throw processException(e);
16484 }
16485 finally {
16486 if (count == null) {
16487 count = Long.valueOf(0);
16488 }
16489
16490 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_T,
16491 finderArgs, count);
16492
16493 closeSession(session);
16494 }
16495 }
16496
16497 return count.intValue();
16498 }
16499
16500
16509 public int filterCountByG_C_T(long groupId, long categoryId, long threadId)
16510 throws SystemException {
16511 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16512 return countByG_C_T(groupId, categoryId, threadId);
16513 }
16514
16515 StringBundler query = new StringBundler(4);
16516
16517 query.append(_FILTER_SQL_COUNT_MBMESSAGE_WHERE);
16518
16519 query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
16520
16521 query.append(_FINDER_COLUMN_G_C_T_CATEGORYID_2);
16522
16523 query.append(_FINDER_COLUMN_G_C_T_THREADID_2);
16524
16525 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16526 MBMessage.class.getName(),
16527 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16528
16529 Session session = null;
16530
16531 try {
16532 session = openSession();
16533
16534 SQLQuery q = session.createSQLQuery(sql);
16535
16536 q.addScalar(COUNT_COLUMN_NAME,
16537 com.liferay.portal.kernel.dao.orm.Type.LONG);
16538
16539 QueryPos qPos = QueryPos.getInstance(q);
16540
16541 qPos.add(groupId);
16542
16543 qPos.add(categoryId);
16544
16545 qPos.add(threadId);
16546
16547 Long count = (Long)q.uniqueResult();
16548
16549 return count.intValue();
16550 }
16551 catch (Exception e) {
16552 throw processException(e);
16553 }
16554 finally {
16555 closeSession(session);
16556 }
16557 }
16558
16559
16568 public int countByG_C_S(long groupId, long categoryId, int status)
16569 throws SystemException {
16570 Object[] finderArgs = new Object[] { groupId, categoryId, status };
16571
16572 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_S,
16573 finderArgs, this);
16574
16575 if (count == null) {
16576 StringBundler query = new StringBundler(4);
16577
16578 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
16579
16580 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
16581
16582 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
16583
16584 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
16585
16586 String sql = query.toString();
16587
16588 Session session = null;
16589
16590 try {
16591 session = openSession();
16592
16593 Query q = session.createQuery(sql);
16594
16595 QueryPos qPos = QueryPos.getInstance(q);
16596
16597 qPos.add(groupId);
16598
16599 qPos.add(categoryId);
16600
16601 qPos.add(status);
16602
16603 count = (Long)q.uniqueResult();
16604 }
16605 catch (Exception e) {
16606 throw processException(e);
16607 }
16608 finally {
16609 if (count == null) {
16610 count = Long.valueOf(0);
16611 }
16612
16613 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S,
16614 finderArgs, count);
16615
16616 closeSession(session);
16617 }
16618 }
16619
16620 return count.intValue();
16621 }
16622
16623
16632 public int filterCountByG_C_S(long groupId, long categoryId, int status)
16633 throws SystemException {
16634 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16635 return countByG_C_S(groupId, categoryId, status);
16636 }
16637
16638 StringBundler query = new StringBundler(4);
16639
16640 query.append(_FILTER_SQL_COUNT_MBMESSAGE_WHERE);
16641
16642 query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
16643
16644 query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_2);
16645
16646 query.append(_FINDER_COLUMN_G_C_S_STATUS_2);
16647
16648 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16649 MBMessage.class.getName(),
16650 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16651
16652 Session session = null;
16653
16654 try {
16655 session = openSession();
16656
16657 SQLQuery q = session.createSQLQuery(sql);
16658
16659 q.addScalar(COUNT_COLUMN_NAME,
16660 com.liferay.portal.kernel.dao.orm.Type.LONG);
16661
16662 QueryPos qPos = QueryPos.getInstance(q);
16663
16664 qPos.add(groupId);
16665
16666 qPos.add(categoryId);
16667
16668 qPos.add(status);
16669
16670 Long count = (Long)q.uniqueResult();
16671
16672 return count.intValue();
16673 }
16674 catch (Exception e) {
16675 throw processException(e);
16676 }
16677 finally {
16678 closeSession(session);
16679 }
16680 }
16681
16682
16691 public int countByU_C_C(long userId, long classNameId, long classPK)
16692 throws SystemException {
16693 Object[] finderArgs = new Object[] { userId, classNameId, classPK };
16694
16695 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_C_C,
16696 finderArgs, this);
16697
16698 if (count == null) {
16699 StringBundler query = new StringBundler(4);
16700
16701 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
16702
16703 query.append(_FINDER_COLUMN_U_C_C_USERID_2);
16704
16705 query.append(_FINDER_COLUMN_U_C_C_CLASSNAMEID_2);
16706
16707 query.append(_FINDER_COLUMN_U_C_C_CLASSPK_2);
16708
16709 String sql = query.toString();
16710
16711 Session session = null;
16712
16713 try {
16714 session = openSession();
16715
16716 Query q = session.createQuery(sql);
16717
16718 QueryPos qPos = QueryPos.getInstance(q);
16719
16720 qPos.add(userId);
16721
16722 qPos.add(classNameId);
16723
16724 qPos.add(classPK);
16725
16726 count = (Long)q.uniqueResult();
16727 }
16728 catch (Exception e) {
16729 throw processException(e);
16730 }
16731 finally {
16732 if (count == null) {
16733 count = Long.valueOf(0);
16734 }
16735
16736 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_C_C,
16737 finderArgs, count);
16738
16739 closeSession(session);
16740 }
16741 }
16742
16743 return count.intValue();
16744 }
16745
16746
16755 public int countByU_C_S(long userId, long classNameId, int status)
16756 throws SystemException {
16757 Object[] finderArgs = new Object[] { userId, classNameId, status };
16758
16759 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_C_S,
16760 finderArgs, this);
16761
16762 if (count == null) {
16763 StringBundler query = new StringBundler(4);
16764
16765 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
16766
16767 query.append(_FINDER_COLUMN_U_C_S_USERID_2);
16768
16769 query.append(_FINDER_COLUMN_U_C_S_CLASSNAMEID_2);
16770
16771 query.append(_FINDER_COLUMN_U_C_S_STATUS_2);
16772
16773 String sql = query.toString();
16774
16775 Session session = null;
16776
16777 try {
16778 session = openSession();
16779
16780 Query q = session.createQuery(sql);
16781
16782 QueryPos qPos = QueryPos.getInstance(q);
16783
16784 qPos.add(userId);
16785
16786 qPos.add(classNameId);
16787
16788 qPos.add(status);
16789
16790 count = (Long)q.uniqueResult();
16791 }
16792 catch (Exception e) {
16793 throw processException(e);
16794 }
16795 finally {
16796 if (count == null) {
16797 count = Long.valueOf(0);
16798 }
16799
16800 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_C_S,
16801 finderArgs, count);
16802
16803 closeSession(session);
16804 }
16805 }
16806
16807 return count.intValue();
16808 }
16809
16810
16819 public int countByU_C_S(long userId, long[] classNameIds, int status)
16820 throws SystemException {
16821 Object[] finderArgs = new Object[] {
16822 userId, StringUtil.merge(classNameIds), status
16823 };
16824
16825 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_C_S,
16826 finderArgs, this);
16827
16828 if (count == null) {
16829 StringBundler query = new StringBundler();
16830
16831 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
16832
16833 boolean conjunctionable = false;
16834
16835 if (conjunctionable) {
16836 query.append(WHERE_AND);
16837 }
16838
16839 query.append(_FINDER_COLUMN_U_C_S_USERID_5);
16840
16841 conjunctionable = true;
16842
16843 if ((classNameIds == null) || (classNameIds.length > 0)) {
16844 if (conjunctionable) {
16845 query.append(WHERE_AND);
16846 }
16847
16848 query.append(StringPool.OPEN_PARENTHESIS);
16849
16850 for (int i = 0; i < classNameIds.length; i++) {
16851 query.append(_FINDER_COLUMN_U_C_S_CLASSNAMEID_5);
16852
16853 if ((i + 1) < classNameIds.length) {
16854 query.append(WHERE_OR);
16855 }
16856 }
16857
16858 query.append(StringPool.CLOSE_PARENTHESIS);
16859
16860 conjunctionable = true;
16861 }
16862
16863 if (conjunctionable) {
16864 query.append(WHERE_AND);
16865 }
16866
16867 query.append(_FINDER_COLUMN_U_C_S_STATUS_5);
16868
16869 conjunctionable = true;
16870
16871 String sql = query.toString();
16872
16873 Session session = null;
16874
16875 try {
16876 session = openSession();
16877
16878 Query q = session.createQuery(sql);
16879
16880 QueryPos qPos = QueryPos.getInstance(q);
16881
16882 qPos.add(userId);
16883
16884 if (classNameIds != null) {
16885 qPos.add(classNameIds);
16886 }
16887
16888 qPos.add(status);
16889
16890 count = (Long)q.uniqueResult();
16891 }
16892 catch (Exception e) {
16893 throw processException(e);
16894 }
16895 finally {
16896 if (count == null) {
16897 count = Long.valueOf(0);
16898 }
16899
16900 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_C_S,
16901 finderArgs, count);
16902
16903 closeSession(session);
16904 }
16905 }
16906
16907 return count.intValue();
16908 }
16909
16910
16919 public int countByC_C_S(long classNameId, long classPK, int status)
16920 throws SystemException {
16921 Object[] finderArgs = new Object[] { classNameId, classPK, status };
16922
16923 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_S,
16924 finderArgs, this);
16925
16926 if (count == null) {
16927 StringBundler query = new StringBundler(4);
16928
16929 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
16930
16931 query.append(_FINDER_COLUMN_C_C_S_CLASSNAMEID_2);
16932
16933 query.append(_FINDER_COLUMN_C_C_S_CLASSPK_2);
16934
16935 query.append(_FINDER_COLUMN_C_C_S_STATUS_2);
16936
16937 String sql = query.toString();
16938
16939 Session session = null;
16940
16941 try {
16942 session = openSession();
16943
16944 Query q = session.createQuery(sql);
16945
16946 QueryPos qPos = QueryPos.getInstance(q);
16947
16948 qPos.add(classNameId);
16949
16950 qPos.add(classPK);
16951
16952 qPos.add(status);
16953
16954 count = (Long)q.uniqueResult();
16955 }
16956 catch (Exception e) {
16957 throw processException(e);
16958 }
16959 finally {
16960 if (count == null) {
16961 count = Long.valueOf(0);
16962 }
16963
16964 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_S,
16965 finderArgs, count);
16966
16967 closeSession(session);
16968 }
16969 }
16970
16971 return count.intValue();
16972 }
16973
16974
16984 public int countByG_C_T_A(long groupId, long categoryId, long threadId,
16985 boolean answer) throws SystemException {
16986 Object[] finderArgs = new Object[] { groupId, categoryId, threadId, answer };
16987
16988 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_T_A,
16989 finderArgs, this);
16990
16991 if (count == null) {
16992 StringBundler query = new StringBundler(5);
16993
16994 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
16995
16996 query.append(_FINDER_COLUMN_G_C_T_A_GROUPID_2);
16997
16998 query.append(_FINDER_COLUMN_G_C_T_A_CATEGORYID_2);
16999
17000 query.append(_FINDER_COLUMN_G_C_T_A_THREADID_2);
17001
17002 query.append(_FINDER_COLUMN_G_C_T_A_ANSWER_2);
17003
17004 String sql = query.toString();
17005
17006 Session session = null;
17007
17008 try {
17009 session = openSession();
17010
17011 Query q = session.createQuery(sql);
17012
17013 QueryPos qPos = QueryPos.getInstance(q);
17014
17015 qPos.add(groupId);
17016
17017 qPos.add(categoryId);
17018
17019 qPos.add(threadId);
17020
17021 qPos.add(answer);
17022
17023 count = (Long)q.uniqueResult();
17024 }
17025 catch (Exception e) {
17026 throw processException(e);
17027 }
17028 finally {
17029 if (count == null) {
17030 count = Long.valueOf(0);
17031 }
17032
17033 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_T_A,
17034 finderArgs, count);
17035
17036 closeSession(session);
17037 }
17038 }
17039
17040 return count.intValue();
17041 }
17042
17043
17053 public int filterCountByG_C_T_A(long groupId, long categoryId,
17054 long threadId, boolean answer) throws SystemException {
17055 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17056 return countByG_C_T_A(groupId, categoryId, threadId, answer);
17057 }
17058
17059 StringBundler query = new StringBundler(5);
17060
17061 query.append(_FILTER_SQL_COUNT_MBMESSAGE_WHERE);
17062
17063 query.append(_FINDER_COLUMN_G_C_T_A_GROUPID_2);
17064
17065 query.append(_FINDER_COLUMN_G_C_T_A_CATEGORYID_2);
17066
17067 query.append(_FINDER_COLUMN_G_C_T_A_THREADID_2);
17068
17069 query.append(_FINDER_COLUMN_G_C_T_A_ANSWER_2);
17070
17071 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17072 MBMessage.class.getName(),
17073 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17074
17075 Session session = null;
17076
17077 try {
17078 session = openSession();
17079
17080 SQLQuery q = session.createSQLQuery(sql);
17081
17082 q.addScalar(COUNT_COLUMN_NAME,
17083 com.liferay.portal.kernel.dao.orm.Type.LONG);
17084
17085 QueryPos qPos = QueryPos.getInstance(q);
17086
17087 qPos.add(groupId);
17088
17089 qPos.add(categoryId);
17090
17091 qPos.add(threadId);
17092
17093 qPos.add(answer);
17094
17095 Long count = (Long)q.uniqueResult();
17096
17097 return count.intValue();
17098 }
17099 catch (Exception e) {
17100 throw processException(e);
17101 }
17102 finally {
17103 closeSession(session);
17104 }
17105 }
17106
17107
17117 public int countByG_C_T_S(long groupId, long categoryId, long threadId,
17118 int status) throws SystemException {
17119 Object[] finderArgs = new Object[] { groupId, categoryId, threadId, status };
17120
17121 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_T_S,
17122 finderArgs, this);
17123
17124 if (count == null) {
17125 StringBundler query = new StringBundler(5);
17126
17127 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
17128
17129 query.append(_FINDER_COLUMN_G_C_T_S_GROUPID_2);
17130
17131 query.append(_FINDER_COLUMN_G_C_T_S_CATEGORYID_2);
17132
17133 query.append(_FINDER_COLUMN_G_C_T_S_THREADID_2);
17134
17135 query.append(_FINDER_COLUMN_G_C_T_S_STATUS_2);
17136
17137 String sql = query.toString();
17138
17139 Session session = null;
17140
17141 try {
17142 session = openSession();
17143
17144 Query q = session.createQuery(sql);
17145
17146 QueryPos qPos = QueryPos.getInstance(q);
17147
17148 qPos.add(groupId);
17149
17150 qPos.add(categoryId);
17151
17152 qPos.add(threadId);
17153
17154 qPos.add(status);
17155
17156 count = (Long)q.uniqueResult();
17157 }
17158 catch (Exception e) {
17159 throw processException(e);
17160 }
17161 finally {
17162 if (count == null) {
17163 count = Long.valueOf(0);
17164 }
17165
17166 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_T_S,
17167 finderArgs, count);
17168
17169 closeSession(session);
17170 }
17171 }
17172
17173 return count.intValue();
17174 }
17175
17176
17186 public int filterCountByG_C_T_S(long groupId, long categoryId,
17187 long threadId, int status) throws SystemException {
17188 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17189 return countByG_C_T_S(groupId, categoryId, threadId, status);
17190 }
17191
17192 StringBundler query = new StringBundler(5);
17193
17194 query.append(_FILTER_SQL_COUNT_MBMESSAGE_WHERE);
17195
17196 query.append(_FINDER_COLUMN_G_C_T_S_GROUPID_2);
17197
17198 query.append(_FINDER_COLUMN_G_C_T_S_CATEGORYID_2);
17199
17200 query.append(_FINDER_COLUMN_G_C_T_S_THREADID_2);
17201
17202 query.append(_FINDER_COLUMN_G_C_T_S_STATUS_2);
17203
17204 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17205 MBMessage.class.getName(),
17206 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17207
17208 Session session = null;
17209
17210 try {
17211 session = openSession();
17212
17213 SQLQuery q = session.createSQLQuery(sql);
17214
17215 q.addScalar(COUNT_COLUMN_NAME,
17216 com.liferay.portal.kernel.dao.orm.Type.LONG);
17217
17218 QueryPos qPos = QueryPos.getInstance(q);
17219
17220 qPos.add(groupId);
17221
17222 qPos.add(categoryId);
17223
17224 qPos.add(threadId);
17225
17226 qPos.add(status);
17227
17228 Long count = (Long)q.uniqueResult();
17229
17230 return count.intValue();
17231 }
17232 catch (Exception e) {
17233 throw processException(e);
17234 }
17235 finally {
17236 closeSession(session);
17237 }
17238 }
17239
17240
17250 public int countByU_C_C_S(long userId, long classNameId, long classPK,
17251 int status) throws SystemException {
17252 Object[] finderArgs = new Object[] { userId, classNameId, classPK, status };
17253
17254 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_C_C_S,
17255 finderArgs, this);
17256
17257 if (count == null) {
17258 StringBundler query = new StringBundler(5);
17259
17260 query.append(_SQL_COUNT_MBMESSAGE_WHERE);
17261
17262 query.append(_FINDER_COLUMN_U_C_C_S_USERID_2);
17263
17264 query.append(_FINDER_COLUMN_U_C_C_S_CLASSNAMEID_2);
17265
17266 query.append(_FINDER_COLUMN_U_C_C_S_CLASSPK_2);
17267
17268 query.append(_FINDER_COLUMN_U_C_C_S_STATUS_2);
17269
17270 String sql = query.toString();
17271
17272 Session session = null;
17273
17274 try {
17275 session = openSession();
17276
17277 Query q = session.createQuery(sql);
17278
17279 QueryPos qPos = QueryPos.getInstance(q);
17280
17281 qPos.add(userId);
17282
17283 qPos.add(classNameId);
17284
17285 qPos.add(classPK);
17286
17287 qPos.add(status);
17288
17289 count = (Long)q.uniqueResult();
17290 }
17291 catch (Exception e) {
17292 throw processException(e);
17293 }
17294 finally {
17295 if (count == null) {
17296 count = Long.valueOf(0);
17297 }
17298
17299 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_C_C_S,
17300 finderArgs, count);
17301
17302 closeSession(session);
17303 }
17304 }
17305
17306 return count.intValue();
17307 }
17308
17309
17315 public int countAll() throws SystemException {
17316 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
17317 FINDER_ARGS_EMPTY, this);
17318
17319 if (count == null) {
17320 Session session = null;
17321
17322 try {
17323 session = openSession();
17324
17325 Query q = session.createQuery(_SQL_COUNT_MBMESSAGE);
17326
17327 count = (Long)q.uniqueResult();
17328 }
17329 catch (Exception e) {
17330 throw processException(e);
17331 }
17332 finally {
17333 if (count == null) {
17334 count = Long.valueOf(0);
17335 }
17336
17337 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
17338 FINDER_ARGS_EMPTY, count);
17339
17340 closeSession(session);
17341 }
17342 }
17343
17344 return count.intValue();
17345 }
17346
17347
17350 public void afterPropertiesSet() {
17351 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
17352 com.liferay.portal.util.PropsUtil.get(
17353 "value.object.listener.com.liferay.portlet.messageboards.model.MBMessage")));
17354
17355 if (listenerClassNames.length > 0) {
17356 try {
17357 List<ModelListener<MBMessage>> listenersList = new ArrayList<ModelListener<MBMessage>>();
17358
17359 for (String listenerClassName : listenerClassNames) {
17360 listenersList.add((ModelListener<MBMessage>)InstanceFactory.newInstance(
17361 listenerClassName));
17362 }
17363
17364 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
17365 }
17366 catch (Exception e) {
17367 _log.error(e);
17368 }
17369 }
17370 }
17371
17372 public void destroy() {
17373 EntityCacheUtil.removeCache(MBMessageImpl.class.getName());
17374 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
17375 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
17376 }
17377
17378 @BeanReference(type = MBBanPersistence.class)
17379 protected MBBanPersistence mbBanPersistence;
17380 @BeanReference(type = MBCategoryPersistence.class)
17381 protected MBCategoryPersistence mbCategoryPersistence;
17382 @BeanReference(type = MBDiscussionPersistence.class)
17383 protected MBDiscussionPersistence mbDiscussionPersistence;
17384 @BeanReference(type = MBMailingListPersistence.class)
17385 protected MBMailingListPersistence mbMailingListPersistence;
17386 @BeanReference(type = MBMessagePersistence.class)
17387 protected MBMessagePersistence mbMessagePersistence;
17388 @BeanReference(type = MBStatsUserPersistence.class)
17389 protected MBStatsUserPersistence mbStatsUserPersistence;
17390 @BeanReference(type = MBThreadPersistence.class)
17391 protected MBThreadPersistence mbThreadPersistence;
17392 @BeanReference(type = MBThreadFlagPersistence.class)
17393 protected MBThreadFlagPersistence mbThreadFlagPersistence;
17394 @BeanReference(type = CompanyPersistence.class)
17395 protected CompanyPersistence companyPersistence;
17396 @BeanReference(type = GroupPersistence.class)
17397 protected GroupPersistence groupPersistence;
17398 @BeanReference(type = LockPersistence.class)
17399 protected LockPersistence lockPersistence;
17400 @BeanReference(type = PortletPreferencesPersistence.class)
17401 protected PortletPreferencesPersistence portletPreferencesPersistence;
17402 @BeanReference(type = ResourcePersistence.class)
17403 protected ResourcePersistence resourcePersistence;
17404 @BeanReference(type = SubscriptionPersistence.class)
17405 protected SubscriptionPersistence subscriptionPersistence;
17406 @BeanReference(type = UserPersistence.class)
17407 protected UserPersistence userPersistence;
17408 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
17409 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
17410 @BeanReference(type = AssetEntryPersistence.class)
17411 protected AssetEntryPersistence assetEntryPersistence;
17412 @BeanReference(type = AssetLinkPersistence.class)
17413 protected AssetLinkPersistence assetLinkPersistence;
17414 @BeanReference(type = AssetTagPersistence.class)
17415 protected AssetTagPersistence assetTagPersistence;
17416 @BeanReference(type = BlogsEntryPersistence.class)
17417 protected BlogsEntryPersistence blogsEntryPersistence;
17418 @BeanReference(type = ExpandoValuePersistence.class)
17419 protected ExpandoValuePersistence expandoValuePersistence;
17420 @BeanReference(type = RatingsStatsPersistence.class)
17421 protected RatingsStatsPersistence ratingsStatsPersistence;
17422 @BeanReference(type = SocialActivityPersistence.class)
17423 protected SocialActivityPersistence socialActivityPersistence;
17424 @BeanReference(type = WikiPagePersistence.class)
17425 protected WikiPagePersistence wikiPagePersistence;
17426 private static final String _SQL_SELECT_MBMESSAGE = "SELECT mbMessage FROM MBMessage mbMessage";
17427 private static final String _SQL_SELECT_MBMESSAGE_WHERE = "SELECT mbMessage FROM MBMessage mbMessage WHERE ";
17428 private static final String _SQL_COUNT_MBMESSAGE = "SELECT COUNT(mbMessage) FROM MBMessage mbMessage";
17429 private static final String _SQL_COUNT_MBMESSAGE_WHERE = "SELECT COUNT(mbMessage) FROM MBMessage mbMessage WHERE ";
17430 private static final String _FINDER_COLUMN_UUID_UUID_1 = "mbMessage.uuid IS NULL";
17431 private static final String _FINDER_COLUMN_UUID_UUID_2 = "mbMessage.uuid = ?";
17432 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(mbMessage.uuid IS NULL OR mbMessage.uuid = ?)";
17433 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "mbMessage.uuid IS NULL AND ";
17434 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "mbMessage.uuid = ? AND ";
17435 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(mbMessage.uuid IS NULL OR mbMessage.uuid = ?) AND ";
17436 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "mbMessage.groupId = ?";
17437 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "mbMessage.groupId = ?";
17438 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "mbMessage.companyId = ?";
17439 private static final String _FINDER_COLUMN_THREADID_THREADID_2 = "mbMessage.threadId = ?";
17440 private static final String _FINDER_COLUMN_THREADREPLIES_THREADID_2 = "mbMessage.threadId = ? AND mbMessage.parentMessageId != 0";
17441 private static final String _FINDER_COLUMN_USERID_USERID_2 = "mbMessage.userId = ?";
17442 private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "mbMessage.groupId = ? AND ";
17443 private static final String _FINDER_COLUMN_G_U_USERID_2 = "mbMessage.userId = ? AND (mbMessage.categoryId != -1) AND (mbMessage.anonymous = [$FALSE$])";
17444 private static final String _FINDER_COLUMN_G_C_GROUPID_2 = "mbMessage.groupId = ? AND ";
17445 private static final String _FINDER_COLUMN_G_C_CATEGORYID_2 = "mbMessage.categoryId = ?";
17446 private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "mbMessage.groupId = ? AND ";
17447 private static final String _FINDER_COLUMN_G_S_STATUS_2 = "mbMessage.status = ? AND mbMessage.categoryId != -1";
17448 private static final String _FINDER_COLUMN_C_S_COMPANYID_2 = "mbMessage.companyId = ? AND ";
17449 private static final String _FINDER_COLUMN_C_S_STATUS_2 = "mbMessage.status = ?";
17450 private static final String _FINDER_COLUMN_U_C_USERID_2 = "mbMessage.userId = ? AND ";
17451 private static final String _FINDER_COLUMN_U_C_USERID_5 = "(" +
17452 _removeConjunction(_FINDER_COLUMN_U_C_USERID_2) + ")";
17453 private static final String _FINDER_COLUMN_U_C_CLASSNAMEID_2 = "mbMessage.classNameId = ?";
17454 private static final String _FINDER_COLUMN_U_C_CLASSNAMEID_5 = "(" +
17455 _removeConjunction(_FINDER_COLUMN_U_C_CLASSNAMEID_2) + ")";
17456 private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "mbMessage.classNameId = ? AND ";
17457 private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "mbMessage.classPK = ?";
17458 private static final String _FINDER_COLUMN_T_P_THREADID_2 = "mbMessage.threadId = ? AND ";
17459 private static final String _FINDER_COLUMN_T_P_PARENTMESSAGEID_2 = "mbMessage.parentMessageId = ?";
17460 private static final String _FINDER_COLUMN_T_A_THREADID_2 = "mbMessage.threadId = ? AND ";
17461 private static final String _FINDER_COLUMN_T_A_ANSWER_2 = "mbMessage.answer = ?";
17462 private static final String _FINDER_COLUMN_T_S_THREADID_2 = "mbMessage.threadId = ? AND ";
17463 private static final String _FINDER_COLUMN_T_S_STATUS_2 = "mbMessage.status = ?";
17464 private static final String _FINDER_COLUMN_TR_S_THREADID_2 = "mbMessage.threadId = ? AND ";
17465 private static final String _FINDER_COLUMN_TR_S_STATUS_2 = "mbMessage.status = ? AND mbMessage.parentMessageId != 0";
17466 private static final String _FINDER_COLUMN_G_U_S_GROUPID_2 = "mbMessage.groupId = ? AND ";
17467 private static final String _FINDER_COLUMN_G_U_S_USERID_2 = "mbMessage.userId = ? AND ";
17468 private static final String _FINDER_COLUMN_G_U_S_STATUS_2 = "mbMessage.status = ?";
17469 private static final String _FINDER_COLUMN_G_C_T_GROUPID_2 = "mbMessage.groupId = ? AND ";
17470 private static final String _FINDER_COLUMN_G_C_T_CATEGORYID_2 = "mbMessage.categoryId = ? AND ";
17471 private static final String _FINDER_COLUMN_G_C_T_THREADID_2 = "mbMessage.threadId = ?";
17472 private static final String _FINDER_COLUMN_G_C_S_GROUPID_2 = "mbMessage.groupId = ? AND ";
17473 private static final String _FINDER_COLUMN_G_C_S_CATEGORYID_2 = "mbMessage.categoryId = ? AND ";
17474 private static final String _FINDER_COLUMN_G_C_S_STATUS_2 = "mbMessage.status = ?";
17475 private static final String _FINDER_COLUMN_U_C_C_USERID_2 = "mbMessage.userId = ? AND ";
17476 private static final String _FINDER_COLUMN_U_C_C_CLASSNAMEID_2 = "mbMessage.classNameId = ? AND ";
17477 private static final String _FINDER_COLUMN_U_C_C_CLASSPK_2 = "mbMessage.classPK = ?";
17478 private static final String _FINDER_COLUMN_U_C_S_USERID_2 = "mbMessage.userId = ? AND ";
17479 private static final String _FINDER_COLUMN_U_C_S_USERID_5 = "(" +
17480 _removeConjunction(_FINDER_COLUMN_U_C_S_USERID_2) + ")";
17481 private static final String _FINDER_COLUMN_U_C_S_CLASSNAMEID_2 = "mbMessage.classNameId = ? AND ";
17482 private static final String _FINDER_COLUMN_U_C_S_CLASSNAMEID_5 = "(" +
17483 _removeConjunction(_FINDER_COLUMN_U_C_S_CLASSNAMEID_2) + ")";
17484 private static final String _FINDER_COLUMN_U_C_S_STATUS_2 = "mbMessage.status = ?";
17485 private static final String _FINDER_COLUMN_U_C_S_STATUS_5 = "(" +
17486 _removeConjunction(_FINDER_COLUMN_U_C_S_STATUS_2) + ")";
17487 private static final String _FINDER_COLUMN_C_C_S_CLASSNAMEID_2 = "mbMessage.classNameId = ? AND ";
17488 private static final String _FINDER_COLUMN_C_C_S_CLASSPK_2 = "mbMessage.classPK = ? AND ";
17489 private static final String _FINDER_COLUMN_C_C_S_STATUS_2 = "mbMessage.status = ?";
17490 private static final String _FINDER_COLUMN_G_C_T_A_GROUPID_2 = "mbMessage.groupId = ? AND ";
17491 private static final String _FINDER_COLUMN_G_C_T_A_CATEGORYID_2 = "mbMessage.categoryId = ? AND ";
17492 private static final String _FINDER_COLUMN_G_C_T_A_THREADID_2 = "mbMessage.threadId = ? AND ";
17493 private static final String _FINDER_COLUMN_G_C_T_A_ANSWER_2 = "mbMessage.answer = ?";
17494 private static final String _FINDER_COLUMN_G_C_T_S_GROUPID_2 = "mbMessage.groupId = ? AND ";
17495 private static final String _FINDER_COLUMN_G_C_T_S_CATEGORYID_2 = "mbMessage.categoryId = ? AND ";
17496 private static final String _FINDER_COLUMN_G_C_T_S_THREADID_2 = "mbMessage.threadId = ? AND ";
17497 private static final String _FINDER_COLUMN_G_C_T_S_STATUS_2 = "mbMessage.status = ?";
17498 private static final String _FINDER_COLUMN_U_C_C_S_USERID_2 = "mbMessage.userId = ? AND ";
17499 private static final String _FINDER_COLUMN_U_C_C_S_CLASSNAMEID_2 = "mbMessage.classNameId = ? AND ";
17500 private static final String _FINDER_COLUMN_U_C_C_S_CLASSPK_2 = "mbMessage.classPK = ? AND ";
17501 private static final String _FINDER_COLUMN_U_C_C_S_STATUS_2 = "mbMessage.status = ?";
17502
17503 private static String _removeConjunction(String sql) {
17504 int pos = sql.indexOf(" AND ");
17505
17506 if (pos != -1) {
17507 sql = sql.substring(0, pos);
17508 }
17509
17510 return sql;
17511 }
17512
17513 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "mbMessage.rootMessageId";
17514 private static final String _FILTER_SQL_SELECT_MBMESSAGE_WHERE = "SELECT DISTINCT {mbMessage.*} FROM MBMessage mbMessage WHERE ";
17515 private static final String _FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_1 =
17516 "SELECT {MBMessage.*} FROM (SELECT DISTINCT mbMessage.messageId FROM MBMessage mbMessage WHERE ";
17517 private static final String _FILTER_SQL_SELECT_MBMESSAGE_NO_INLINE_DISTINCT_WHERE_2 =
17518 ") TEMP_TABLE INNER JOIN MBMessage ON TEMP_TABLE.messageId = MBMessage.messageId";
17519 private static final String _FILTER_SQL_COUNT_MBMESSAGE_WHERE = "SELECT COUNT(DISTINCT mbMessage.messageId) AS COUNT_VALUE FROM MBMessage mbMessage WHERE ";
17520 private static final String _FILTER_ENTITY_ALIAS = "mbMessage";
17521 private static final String _FILTER_ENTITY_TABLE = "MBMessage";
17522 private static final String _ORDER_BY_ENTITY_ALIAS = "mbMessage.";
17523 private static final String _ORDER_BY_ENTITY_TABLE = "MBMessage.";
17524 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MBMessage exists with the primary key ";
17525 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MBMessage exists with the key {";
17526 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
17527 private static Log _log = LogFactoryUtil.getLog(MBMessagePersistenceImpl.class);
17528 private static MBMessage _nullMBMessage = new MBMessageImpl() {
17529 @Override
17530 public Object clone() {
17531 return this;
17532 }
17533
17534 @Override
17535 public CacheModel<MBMessage> toCacheModel() {
17536 return _nullMBMessageCacheModel;
17537 }
17538 };
17539
17540 private static CacheModel<MBMessage> _nullMBMessageCacheModel = new CacheModel<MBMessage>() {
17541 public MBMessage toEntityModel() {
17542 return _nullMBMessage;
17543 }
17544 };
17545 }