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