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