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