1
22
23 package com.liferay.portlet.journal.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.GetterUtil;
39 import com.liferay.portal.kernel.util.OrderByComparator;
40 import com.liferay.portal.kernel.util.StringPool;
41 import com.liferay.portal.kernel.util.StringUtil;
42 import com.liferay.portal.kernel.util.Validator;
43 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
44 import com.liferay.portal.model.ModelListener;
45 import com.liferay.portal.service.persistence.BatchSessionUtil;
46 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
47
48 import com.liferay.portlet.journal.NoSuchFeedException;
49 import com.liferay.portlet.journal.model.JournalFeed;
50 import com.liferay.portlet.journal.model.impl.JournalFeedImpl;
51 import com.liferay.portlet.journal.model.impl.JournalFeedModelImpl;
52
53 import java.util.ArrayList;
54 import java.util.Collections;
55 import java.util.List;
56
57
70 public class JournalFeedPersistenceImpl extends BasePersistenceImpl
71 implements JournalFeedPersistence {
72 public static final String FINDER_CLASS_NAME_ENTITY = JournalFeedImpl.class.getName();
73 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
74 ".List";
75 public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
76 JournalFeedModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
77 "findByUuid", new String[] { String.class.getName() });
78 public static final FinderPath FINDER_PATH_FIND_BY_OBC_UUID = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
79 JournalFeedModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
80 "findByUuid",
81 new String[] {
82 String.class.getName(),
83
84 "java.lang.Integer", "java.lang.Integer",
85 "com.liferay.portal.kernel.util.OrderByComparator"
86 });
87 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
88 JournalFeedModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
89 "countByUuid", new String[] { String.class.getName() });
90 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
91 JournalFeedModelImpl.FINDER_CACHE_ENABLED,
92 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
93 new String[] { String.class.getName(), Long.class.getName() });
94 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
95 JournalFeedModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
96 "countByUUID_G",
97 new String[] { String.class.getName(), Long.class.getName() });
98 public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
99 JournalFeedModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
100 "findByGroupId", new String[] { Long.class.getName() });
101 public static final FinderPath FINDER_PATH_FIND_BY_OBC_GROUPID = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
102 JournalFeedModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
103 "findByGroupId",
104 new String[] {
105 Long.class.getName(),
106
107 "java.lang.Integer", "java.lang.Integer",
108 "com.liferay.portal.kernel.util.OrderByComparator"
109 });
110 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
111 JournalFeedModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
112 "countByGroupId", new String[] { Long.class.getName() });
113 public static final FinderPath FINDER_PATH_FETCH_BY_G_F = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
114 JournalFeedModelImpl.FINDER_CACHE_ENABLED,
115 FINDER_CLASS_NAME_ENTITY, "fetchByG_F",
116 new String[] { Long.class.getName(), String.class.getName() });
117 public static final FinderPath FINDER_PATH_COUNT_BY_G_F = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
118 JournalFeedModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
119 "countByG_F",
120 new String[] { Long.class.getName(), String.class.getName() });
121 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
122 JournalFeedModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
123 "findAll", new String[0]);
124 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
125 JournalFeedModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
126 "countAll", new String[0]);
127
128 public void cacheResult(JournalFeed journalFeed) {
129 EntityCacheUtil.putResult(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
130 JournalFeedImpl.class, journalFeed.getPrimaryKey(), journalFeed);
131
132 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
133 new Object[] {
134 journalFeed.getUuid(), new Long(journalFeed.getGroupId())
135 }, journalFeed);
136
137 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F,
138 new Object[] {
139 new Long(journalFeed.getGroupId()),
140
141 journalFeed.getFeedId()
142 }, journalFeed);
143 }
144
145 public void cacheResult(List<JournalFeed> journalFeeds) {
146 for (JournalFeed journalFeed : journalFeeds) {
147 if (EntityCacheUtil.getResult(
148 JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
149 JournalFeedImpl.class, journalFeed.getPrimaryKey(), this) == null) {
150 cacheResult(journalFeed);
151 }
152 }
153 }
154
155 public void clearCache() {
156 CacheRegistry.clear(JournalFeedImpl.class.getName());
157 EntityCacheUtil.clearCache(JournalFeedImpl.class.getName());
158 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
159 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
160 }
161
162 public JournalFeed create(long id) {
163 JournalFeed journalFeed = new JournalFeedImpl();
164
165 journalFeed.setNew(true);
166 journalFeed.setPrimaryKey(id);
167
168 String uuid = PortalUUIDUtil.generate();
169
170 journalFeed.setUuid(uuid);
171
172 return journalFeed;
173 }
174
175 public JournalFeed remove(long id)
176 throws NoSuchFeedException, SystemException {
177 Session session = null;
178
179 try {
180 session = openSession();
181
182 JournalFeed journalFeed = (JournalFeed)session.get(JournalFeedImpl.class,
183 new Long(id));
184
185 if (journalFeed == null) {
186 if (_log.isWarnEnabled()) {
187 _log.warn("No JournalFeed exists with the primary key " +
188 id);
189 }
190
191 throw new NoSuchFeedException(
192 "No JournalFeed exists with the primary key " + id);
193 }
194
195 return remove(journalFeed);
196 }
197 catch (NoSuchFeedException nsee) {
198 throw nsee;
199 }
200 catch (Exception e) {
201 throw processException(e);
202 }
203 finally {
204 closeSession(session);
205 }
206 }
207
208 public JournalFeed remove(JournalFeed journalFeed)
209 throws SystemException {
210 for (ModelListener<JournalFeed> listener : listeners) {
211 listener.onBeforeRemove(journalFeed);
212 }
213
214 journalFeed = removeImpl(journalFeed);
215
216 for (ModelListener<JournalFeed> listener : listeners) {
217 listener.onAfterRemove(journalFeed);
218 }
219
220 return journalFeed;
221 }
222
223 protected JournalFeed removeImpl(JournalFeed journalFeed)
224 throws SystemException {
225 journalFeed = toUnwrappedModel(journalFeed);
226
227 Session session = null;
228
229 try {
230 session = openSession();
231
232 if (journalFeed.isCachedModel() || BatchSessionUtil.isEnabled()) {
233 Object staleObject = session.get(JournalFeedImpl.class,
234 journalFeed.getPrimaryKeyObj());
235
236 if (staleObject != null) {
237 session.evict(staleObject);
238 }
239 }
240
241 session.delete(journalFeed);
242
243 session.flush();
244 }
245 catch (Exception e) {
246 throw processException(e);
247 }
248 finally {
249 closeSession(session);
250 }
251
252 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
253
254 JournalFeedModelImpl journalFeedModelImpl = (JournalFeedModelImpl)journalFeed;
255
256 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
257 new Object[] {
258 journalFeedModelImpl.getOriginalUuid(),
259 new Long(journalFeedModelImpl.getOriginalGroupId())
260 });
261
262 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F,
263 new Object[] {
264 new Long(journalFeedModelImpl.getOriginalGroupId()),
265
266 journalFeedModelImpl.getOriginalFeedId()
267 });
268
269 EntityCacheUtil.removeResult(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
270 JournalFeedImpl.class, journalFeed.getPrimaryKey());
271
272 return journalFeed;
273 }
274
275
278 public JournalFeed update(JournalFeed journalFeed)
279 throws SystemException {
280 if (_log.isWarnEnabled()) {
281 _log.warn(
282 "Using the deprecated update(JournalFeed journalFeed) method. Use update(JournalFeed journalFeed, boolean merge) instead.");
283 }
284
285 return update(journalFeed, false);
286 }
287
288
300 public JournalFeed update(JournalFeed journalFeed, boolean merge)
301 throws SystemException {
302 boolean isNew = journalFeed.isNew();
303
304 for (ModelListener<JournalFeed> listener : listeners) {
305 if (isNew) {
306 listener.onBeforeCreate(journalFeed);
307 }
308 else {
309 listener.onBeforeUpdate(journalFeed);
310 }
311 }
312
313 journalFeed = updateImpl(journalFeed, merge);
314
315 for (ModelListener<JournalFeed> listener : listeners) {
316 if (isNew) {
317 listener.onAfterCreate(journalFeed);
318 }
319 else {
320 listener.onAfterUpdate(journalFeed);
321 }
322 }
323
324 return journalFeed;
325 }
326
327 public JournalFeed updateImpl(
328 com.liferay.portlet.journal.model.JournalFeed journalFeed, boolean merge)
329 throws SystemException {
330 journalFeed = toUnwrappedModel(journalFeed);
331
332 boolean isNew = journalFeed.isNew();
333
334 JournalFeedModelImpl journalFeedModelImpl = (JournalFeedModelImpl)journalFeed;
335
336 if (Validator.isNull(journalFeed.getUuid())) {
337 String uuid = PortalUUIDUtil.generate();
338
339 journalFeed.setUuid(uuid);
340 }
341
342 Session session = null;
343
344 try {
345 session = openSession();
346
347 BatchSessionUtil.update(session, journalFeed, merge);
348
349 journalFeed.setNew(false);
350 }
351 catch (Exception e) {
352 throw processException(e);
353 }
354 finally {
355 closeSession(session);
356 }
357
358 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
359
360 EntityCacheUtil.putResult(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
361 JournalFeedImpl.class, journalFeed.getPrimaryKey(), journalFeed);
362
363 if (!isNew &&
364 (!Validator.equals(journalFeed.getUuid(),
365 journalFeedModelImpl.getOriginalUuid()) ||
366 (journalFeed.getGroupId() != journalFeedModelImpl.getOriginalGroupId()))) {
367 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
368 new Object[] {
369 journalFeedModelImpl.getOriginalUuid(),
370 new Long(journalFeedModelImpl.getOriginalGroupId())
371 });
372 }
373
374 if (isNew ||
375 (!Validator.equals(journalFeed.getUuid(),
376 journalFeedModelImpl.getOriginalUuid()) ||
377 (journalFeed.getGroupId() != journalFeedModelImpl.getOriginalGroupId()))) {
378 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
379 new Object[] {
380 journalFeed.getUuid(), new Long(journalFeed.getGroupId())
381 }, journalFeed);
382 }
383
384 if (!isNew &&
385 ((journalFeed.getGroupId() != journalFeedModelImpl.getOriginalGroupId()) ||
386 !Validator.equals(journalFeed.getFeedId(),
387 journalFeedModelImpl.getOriginalFeedId()))) {
388 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F,
389 new Object[] {
390 new Long(journalFeedModelImpl.getOriginalGroupId()),
391
392 journalFeedModelImpl.getOriginalFeedId()
393 });
394 }
395
396 if (isNew ||
397 ((journalFeed.getGroupId() != journalFeedModelImpl.getOriginalGroupId()) ||
398 !Validator.equals(journalFeed.getFeedId(),
399 journalFeedModelImpl.getOriginalFeedId()))) {
400 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F,
401 new Object[] {
402 new Long(journalFeed.getGroupId()),
403
404 journalFeed.getFeedId()
405 }, journalFeed);
406 }
407
408 return journalFeed;
409 }
410
411 protected JournalFeed toUnwrappedModel(JournalFeed journalFeed) {
412 if (journalFeed instanceof JournalFeedImpl) {
413 return journalFeed;
414 }
415
416 JournalFeedImpl journalFeedImpl = new JournalFeedImpl();
417
418 journalFeedImpl.setNew(journalFeed.isNew());
419 journalFeedImpl.setPrimaryKey(journalFeed.getPrimaryKey());
420
421 journalFeedImpl.setUuid(journalFeed.getUuid());
422 journalFeedImpl.setId(journalFeed.getId());
423 journalFeedImpl.setGroupId(journalFeed.getGroupId());
424 journalFeedImpl.setCompanyId(journalFeed.getCompanyId());
425 journalFeedImpl.setUserId(journalFeed.getUserId());
426 journalFeedImpl.setUserName(journalFeed.getUserName());
427 journalFeedImpl.setCreateDate(journalFeed.getCreateDate());
428 journalFeedImpl.setModifiedDate(journalFeed.getModifiedDate());
429 journalFeedImpl.setFeedId(journalFeed.getFeedId());
430 journalFeedImpl.setName(journalFeed.getName());
431 journalFeedImpl.setDescription(journalFeed.getDescription());
432 journalFeedImpl.setType(journalFeed.getType());
433 journalFeedImpl.setStructureId(journalFeed.getStructureId());
434 journalFeedImpl.setTemplateId(journalFeed.getTemplateId());
435 journalFeedImpl.setRendererTemplateId(journalFeed.getRendererTemplateId());
436 journalFeedImpl.setDelta(journalFeed.getDelta());
437 journalFeedImpl.setOrderByCol(journalFeed.getOrderByCol());
438 journalFeedImpl.setOrderByType(journalFeed.getOrderByType());
439 journalFeedImpl.setTargetLayoutFriendlyUrl(journalFeed.getTargetLayoutFriendlyUrl());
440 journalFeedImpl.setTargetPortletId(journalFeed.getTargetPortletId());
441 journalFeedImpl.setContentField(journalFeed.getContentField());
442 journalFeedImpl.setFeedType(journalFeed.getFeedType());
443 journalFeedImpl.setFeedVersion(journalFeed.getFeedVersion());
444
445 return journalFeedImpl;
446 }
447
448 public JournalFeed findByPrimaryKey(long id)
449 throws NoSuchFeedException, SystemException {
450 JournalFeed journalFeed = fetchByPrimaryKey(id);
451
452 if (journalFeed == null) {
453 if (_log.isWarnEnabled()) {
454 _log.warn("No JournalFeed exists with the primary key " + id);
455 }
456
457 throw new NoSuchFeedException(
458 "No JournalFeed exists with the primary key " + id);
459 }
460
461 return journalFeed;
462 }
463
464 public JournalFeed fetchByPrimaryKey(long id) throws SystemException {
465 JournalFeed journalFeed = (JournalFeed)EntityCacheUtil.getResult(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
466 JournalFeedImpl.class, id, this);
467
468 if (journalFeed == null) {
469 Session session = null;
470
471 try {
472 session = openSession();
473
474 journalFeed = (JournalFeed)session.get(JournalFeedImpl.class,
475 new Long(id));
476 }
477 catch (Exception e) {
478 throw processException(e);
479 }
480 finally {
481 if (journalFeed != null) {
482 cacheResult(journalFeed);
483 }
484
485 closeSession(session);
486 }
487 }
488
489 return journalFeed;
490 }
491
492 public List<JournalFeed> findByUuid(String uuid) throws SystemException {
493 Object[] finderArgs = new Object[] { uuid };
494
495 List<JournalFeed> list = (List<JournalFeed>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
496 finderArgs, this);
497
498 if (list == null) {
499 Session session = null;
500
501 try {
502 session = openSession();
503
504 StringBuilder query = new StringBuilder();
505
506 query.append(
507 "SELECT journalFeed FROM JournalFeed journalFeed WHERE ");
508
509 if (uuid == null) {
510 query.append("journalFeed.uuid IS NULL");
511 }
512 else {
513 query.append("journalFeed.uuid = ?");
514 }
515
516 query.append(" ");
517
518 query.append("ORDER BY ");
519
520 query.append("journalFeed.feedId ASC");
521
522 Query q = session.createQuery(query.toString());
523
524 QueryPos qPos = QueryPos.getInstance(q);
525
526 if (uuid != null) {
527 qPos.add(uuid);
528 }
529
530 list = q.list();
531 }
532 catch (Exception e) {
533 throw processException(e);
534 }
535 finally {
536 if (list == null) {
537 list = new ArrayList<JournalFeed>();
538 }
539
540 cacheResult(list);
541
542 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
543 list);
544
545 closeSession(session);
546 }
547 }
548
549 return list;
550 }
551
552 public List<JournalFeed> findByUuid(String uuid, int start, int end)
553 throws SystemException {
554 return findByUuid(uuid, start, end, null);
555 }
556
557 public List<JournalFeed> findByUuid(String uuid, int start, int end,
558 OrderByComparator obc) throws SystemException {
559 Object[] finderArgs = new Object[] {
560 uuid,
561
562 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
563 };
564
565 List<JournalFeed> list = (List<JournalFeed>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_UUID,
566 finderArgs, this);
567
568 if (list == null) {
569 Session session = null;
570
571 try {
572 session = openSession();
573
574 StringBuilder query = new StringBuilder();
575
576 query.append(
577 "SELECT journalFeed FROM JournalFeed journalFeed WHERE ");
578
579 if (uuid == null) {
580 query.append("journalFeed.uuid IS NULL");
581 }
582 else {
583 query.append("journalFeed.uuid = ?");
584 }
585
586 query.append(" ");
587
588 if (obc != null) {
589 query.append("ORDER BY ");
590
591 String[] orderByFields = obc.getOrderByFields();
592
593 for (int i = 0; i < orderByFields.length; i++) {
594 query.append("journalFeed.");
595 query.append(orderByFields[i]);
596
597 if (obc.isAscending()) {
598 query.append(" ASC");
599 }
600 else {
601 query.append(" DESC");
602 }
603
604 if ((i + 1) < orderByFields.length) {
605 query.append(", ");
606 }
607 }
608 }
609
610 else {
611 query.append("ORDER BY ");
612
613 query.append("journalFeed.feedId ASC");
614 }
615
616 Query q = session.createQuery(query.toString());
617
618 QueryPos qPos = QueryPos.getInstance(q);
619
620 if (uuid != null) {
621 qPos.add(uuid);
622 }
623
624 list = (List<JournalFeed>)QueryUtil.list(q, getDialect(),
625 start, end);
626 }
627 catch (Exception e) {
628 throw processException(e);
629 }
630 finally {
631 if (list == null) {
632 list = new ArrayList<JournalFeed>();
633 }
634
635 cacheResult(list);
636
637 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_UUID,
638 finderArgs, list);
639
640 closeSession(session);
641 }
642 }
643
644 return list;
645 }
646
647 public JournalFeed findByUuid_First(String uuid, OrderByComparator obc)
648 throws NoSuchFeedException, SystemException {
649 List<JournalFeed> list = findByUuid(uuid, 0, 1, obc);
650
651 if (list.isEmpty()) {
652 StringBuilder msg = new StringBuilder();
653
654 msg.append("No JournalFeed exists with the key {");
655
656 msg.append("uuid=" + uuid);
657
658 msg.append(StringPool.CLOSE_CURLY_BRACE);
659
660 throw new NoSuchFeedException(msg.toString());
661 }
662 else {
663 return list.get(0);
664 }
665 }
666
667 public JournalFeed findByUuid_Last(String uuid, OrderByComparator obc)
668 throws NoSuchFeedException, SystemException {
669 int count = countByUuid(uuid);
670
671 List<JournalFeed> list = findByUuid(uuid, count - 1, count, obc);
672
673 if (list.isEmpty()) {
674 StringBuilder msg = new StringBuilder();
675
676 msg.append("No JournalFeed exists with the key {");
677
678 msg.append("uuid=" + uuid);
679
680 msg.append(StringPool.CLOSE_CURLY_BRACE);
681
682 throw new NoSuchFeedException(msg.toString());
683 }
684 else {
685 return list.get(0);
686 }
687 }
688
689 public JournalFeed[] findByUuid_PrevAndNext(long id, String uuid,
690 OrderByComparator obc) throws NoSuchFeedException, SystemException {
691 JournalFeed journalFeed = findByPrimaryKey(id);
692
693 int count = countByUuid(uuid);
694
695 Session session = null;
696
697 try {
698 session = openSession();
699
700 StringBuilder query = new StringBuilder();
701
702 query.append(
703 "SELECT journalFeed FROM JournalFeed journalFeed WHERE ");
704
705 if (uuid == null) {
706 query.append("journalFeed.uuid IS NULL");
707 }
708 else {
709 query.append("journalFeed.uuid = ?");
710 }
711
712 query.append(" ");
713
714 if (obc != null) {
715 query.append("ORDER BY ");
716
717 String[] orderByFields = obc.getOrderByFields();
718
719 for (int i = 0; i < orderByFields.length; i++) {
720 query.append("journalFeed.");
721 query.append(orderByFields[i]);
722
723 if (obc.isAscending()) {
724 query.append(" ASC");
725 }
726 else {
727 query.append(" DESC");
728 }
729
730 if ((i + 1) < orderByFields.length) {
731 query.append(", ");
732 }
733 }
734 }
735
736 else {
737 query.append("ORDER BY ");
738
739 query.append("journalFeed.feedId ASC");
740 }
741
742 Query q = session.createQuery(query.toString());
743
744 QueryPos qPos = QueryPos.getInstance(q);
745
746 if (uuid != null) {
747 qPos.add(uuid);
748 }
749
750 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
751 journalFeed);
752
753 JournalFeed[] array = new JournalFeedImpl[3];
754
755 array[0] = (JournalFeed)objArray[0];
756 array[1] = (JournalFeed)objArray[1];
757 array[2] = (JournalFeed)objArray[2];
758
759 return array;
760 }
761 catch (Exception e) {
762 throw processException(e);
763 }
764 finally {
765 closeSession(session);
766 }
767 }
768
769 public JournalFeed findByUUID_G(String uuid, long groupId)
770 throws NoSuchFeedException, SystemException {
771 JournalFeed journalFeed = fetchByUUID_G(uuid, groupId);
772
773 if (journalFeed == null) {
774 StringBuilder msg = new StringBuilder();
775
776 msg.append("No JournalFeed exists with the key {");
777
778 msg.append("uuid=" + uuid);
779
780 msg.append(", ");
781 msg.append("groupId=" + groupId);
782
783 msg.append(StringPool.CLOSE_CURLY_BRACE);
784
785 if (_log.isWarnEnabled()) {
786 _log.warn(msg.toString());
787 }
788
789 throw new NoSuchFeedException(msg.toString());
790 }
791
792 return journalFeed;
793 }
794
795 public JournalFeed fetchByUUID_G(String uuid, long groupId)
796 throws SystemException {
797 return fetchByUUID_G(uuid, groupId, true);
798 }
799
800 public JournalFeed fetchByUUID_G(String uuid, long groupId,
801 boolean retrieveFromCache) throws SystemException {
802 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
803
804 Object result = null;
805
806 if (retrieveFromCache) {
807 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
808 finderArgs, this);
809 }
810
811 if (result == null) {
812 Session session = null;
813
814 try {
815 session = openSession();
816
817 StringBuilder query = new StringBuilder();
818
819 query.append(
820 "SELECT journalFeed FROM JournalFeed journalFeed WHERE ");
821
822 if (uuid == null) {
823 query.append("journalFeed.uuid IS NULL");
824 }
825 else {
826 query.append("journalFeed.uuid = ?");
827 }
828
829 query.append(" AND ");
830
831 query.append("journalFeed.groupId = ?");
832
833 query.append(" ");
834
835 query.append("ORDER BY ");
836
837 query.append("journalFeed.feedId ASC");
838
839 Query q = session.createQuery(query.toString());
840
841 QueryPos qPos = QueryPos.getInstance(q);
842
843 if (uuid != null) {
844 qPos.add(uuid);
845 }
846
847 qPos.add(groupId);
848
849 List<JournalFeed> list = q.list();
850
851 result = list;
852
853 JournalFeed journalFeed = null;
854
855 if (list.isEmpty()) {
856 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
857 finderArgs, list);
858 }
859 else {
860 journalFeed = list.get(0);
861
862 cacheResult(journalFeed);
863
864 if ((journalFeed.getUuid() == null) ||
865 !journalFeed.getUuid().equals(uuid) ||
866 (journalFeed.getGroupId() != groupId)) {
867 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
868 finderArgs, journalFeed);
869 }
870 }
871
872 return journalFeed;
873 }
874 catch (Exception e) {
875 throw processException(e);
876 }
877 finally {
878 if (result == null) {
879 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
880 finderArgs, new ArrayList<JournalFeed>());
881 }
882
883 closeSession(session);
884 }
885 }
886 else {
887 if (result instanceof List<?>) {
888 return null;
889 }
890 else {
891 return (JournalFeed)result;
892 }
893 }
894 }
895
896 public List<JournalFeed> findByGroupId(long groupId)
897 throws SystemException {
898 Object[] finderArgs = new Object[] { new Long(groupId) };
899
900 List<JournalFeed> list = (List<JournalFeed>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
901 finderArgs, this);
902
903 if (list == null) {
904 Session session = null;
905
906 try {
907 session = openSession();
908
909 StringBuilder query = new StringBuilder();
910
911 query.append(
912 "SELECT journalFeed FROM JournalFeed journalFeed WHERE ");
913
914 query.append("journalFeed.groupId = ?");
915
916 query.append(" ");
917
918 query.append("ORDER BY ");
919
920 query.append("journalFeed.feedId ASC");
921
922 Query q = session.createQuery(query.toString());
923
924 QueryPos qPos = QueryPos.getInstance(q);
925
926 qPos.add(groupId);
927
928 list = q.list();
929 }
930 catch (Exception e) {
931 throw processException(e);
932 }
933 finally {
934 if (list == null) {
935 list = new ArrayList<JournalFeed>();
936 }
937
938 cacheResult(list);
939
940 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
941 finderArgs, list);
942
943 closeSession(session);
944 }
945 }
946
947 return list;
948 }
949
950 public List<JournalFeed> findByGroupId(long groupId, int start, int end)
951 throws SystemException {
952 return findByGroupId(groupId, start, end, null);
953 }
954
955 public List<JournalFeed> findByGroupId(long groupId, int start, int end,
956 OrderByComparator obc) throws SystemException {
957 Object[] finderArgs = new Object[] {
958 new Long(groupId),
959
960 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
961 };
962
963 List<JournalFeed> list = (List<JournalFeed>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
964 finderArgs, this);
965
966 if (list == null) {
967 Session session = null;
968
969 try {
970 session = openSession();
971
972 StringBuilder query = new StringBuilder();
973
974 query.append(
975 "SELECT journalFeed FROM JournalFeed journalFeed WHERE ");
976
977 query.append("journalFeed.groupId = ?");
978
979 query.append(" ");
980
981 if (obc != null) {
982 query.append("ORDER BY ");
983
984 String[] orderByFields = obc.getOrderByFields();
985
986 for (int i = 0; i < orderByFields.length; i++) {
987 query.append("journalFeed.");
988 query.append(orderByFields[i]);
989
990 if (obc.isAscending()) {
991 query.append(" ASC");
992 }
993 else {
994 query.append(" DESC");
995 }
996
997 if ((i + 1) < orderByFields.length) {
998 query.append(", ");
999 }
1000 }
1001 }
1002
1003 else {
1004 query.append("ORDER BY ");
1005
1006 query.append("journalFeed.feedId ASC");
1007 }
1008
1009 Query q = session.createQuery(query.toString());
1010
1011 QueryPos qPos = QueryPos.getInstance(q);
1012
1013 qPos.add(groupId);
1014
1015 list = (List<JournalFeed>)QueryUtil.list(q, getDialect(),
1016 start, end);
1017 }
1018 catch (Exception e) {
1019 throw processException(e);
1020 }
1021 finally {
1022 if (list == null) {
1023 list = new ArrayList<JournalFeed>();
1024 }
1025
1026 cacheResult(list);
1027
1028 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
1029 finderArgs, list);
1030
1031 closeSession(session);
1032 }
1033 }
1034
1035 return list;
1036 }
1037
1038 public JournalFeed findByGroupId_First(long groupId, OrderByComparator obc)
1039 throws NoSuchFeedException, SystemException {
1040 List<JournalFeed> list = findByGroupId(groupId, 0, 1, obc);
1041
1042 if (list.isEmpty()) {
1043 StringBuilder msg = new StringBuilder();
1044
1045 msg.append("No JournalFeed exists with the key {");
1046
1047 msg.append("groupId=" + groupId);
1048
1049 msg.append(StringPool.CLOSE_CURLY_BRACE);
1050
1051 throw new NoSuchFeedException(msg.toString());
1052 }
1053 else {
1054 return list.get(0);
1055 }
1056 }
1057
1058 public JournalFeed findByGroupId_Last(long groupId, OrderByComparator obc)
1059 throws NoSuchFeedException, SystemException {
1060 int count = countByGroupId(groupId);
1061
1062 List<JournalFeed> list = findByGroupId(groupId, count - 1, count, obc);
1063
1064 if (list.isEmpty()) {
1065 StringBuilder msg = new StringBuilder();
1066
1067 msg.append("No JournalFeed exists with the key {");
1068
1069 msg.append("groupId=" + groupId);
1070
1071 msg.append(StringPool.CLOSE_CURLY_BRACE);
1072
1073 throw new NoSuchFeedException(msg.toString());
1074 }
1075 else {
1076 return list.get(0);
1077 }
1078 }
1079
1080 public JournalFeed[] findByGroupId_PrevAndNext(long id, long groupId,
1081 OrderByComparator obc) throws NoSuchFeedException, SystemException {
1082 JournalFeed journalFeed = findByPrimaryKey(id);
1083
1084 int count = countByGroupId(groupId);
1085
1086 Session session = null;
1087
1088 try {
1089 session = openSession();
1090
1091 StringBuilder query = new StringBuilder();
1092
1093 query.append(
1094 "SELECT journalFeed FROM JournalFeed journalFeed WHERE ");
1095
1096 query.append("journalFeed.groupId = ?");
1097
1098 query.append(" ");
1099
1100 if (obc != null) {
1101 query.append("ORDER BY ");
1102
1103 String[] orderByFields = obc.getOrderByFields();
1104
1105 for (int i = 0; i < orderByFields.length; i++) {
1106 query.append("journalFeed.");
1107 query.append(orderByFields[i]);
1108
1109 if (obc.isAscending()) {
1110 query.append(" ASC");
1111 }
1112 else {
1113 query.append(" DESC");
1114 }
1115
1116 if ((i + 1) < orderByFields.length) {
1117 query.append(", ");
1118 }
1119 }
1120 }
1121
1122 else {
1123 query.append("ORDER BY ");
1124
1125 query.append("journalFeed.feedId ASC");
1126 }
1127
1128 Query q = session.createQuery(query.toString());
1129
1130 QueryPos qPos = QueryPos.getInstance(q);
1131
1132 qPos.add(groupId);
1133
1134 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1135 journalFeed);
1136
1137 JournalFeed[] array = new JournalFeedImpl[3];
1138
1139 array[0] = (JournalFeed)objArray[0];
1140 array[1] = (JournalFeed)objArray[1];
1141 array[2] = (JournalFeed)objArray[2];
1142
1143 return array;
1144 }
1145 catch (Exception e) {
1146 throw processException(e);
1147 }
1148 finally {
1149 closeSession(session);
1150 }
1151 }
1152
1153 public JournalFeed findByG_F(long groupId, String feedId)
1154 throws NoSuchFeedException, SystemException {
1155 JournalFeed journalFeed = fetchByG_F(groupId, feedId);
1156
1157 if (journalFeed == null) {
1158 StringBuilder msg = new StringBuilder();
1159
1160 msg.append("No JournalFeed exists with the key {");
1161
1162 msg.append("groupId=" + groupId);
1163
1164 msg.append(", ");
1165 msg.append("feedId=" + feedId);
1166
1167 msg.append(StringPool.CLOSE_CURLY_BRACE);
1168
1169 if (_log.isWarnEnabled()) {
1170 _log.warn(msg.toString());
1171 }
1172
1173 throw new NoSuchFeedException(msg.toString());
1174 }
1175
1176 return journalFeed;
1177 }
1178
1179 public JournalFeed fetchByG_F(long groupId, String feedId)
1180 throws SystemException {
1181 return fetchByG_F(groupId, feedId, true);
1182 }
1183
1184 public JournalFeed fetchByG_F(long groupId, String feedId,
1185 boolean retrieveFromCache) throws SystemException {
1186 Object[] finderArgs = new Object[] { new Long(groupId), feedId };
1187
1188 Object result = null;
1189
1190 if (retrieveFromCache) {
1191 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_F,
1192 finderArgs, this);
1193 }
1194
1195 if (result == null) {
1196 Session session = null;
1197
1198 try {
1199 session = openSession();
1200
1201 StringBuilder query = new StringBuilder();
1202
1203 query.append(
1204 "SELECT journalFeed FROM JournalFeed journalFeed WHERE ");
1205
1206 query.append("journalFeed.groupId = ?");
1207
1208 query.append(" AND ");
1209
1210 if (feedId == null) {
1211 query.append("journalFeed.feedId IS NULL");
1212 }
1213 else {
1214 query.append("journalFeed.feedId = ?");
1215 }
1216
1217 query.append(" ");
1218
1219 query.append("ORDER BY ");
1220
1221 query.append("journalFeed.feedId ASC");
1222
1223 Query q = session.createQuery(query.toString());
1224
1225 QueryPos qPos = QueryPos.getInstance(q);
1226
1227 qPos.add(groupId);
1228
1229 if (feedId != null) {
1230 qPos.add(feedId);
1231 }
1232
1233 List<JournalFeed> list = q.list();
1234
1235 result = list;
1236
1237 JournalFeed journalFeed = null;
1238
1239 if (list.isEmpty()) {
1240 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F,
1241 finderArgs, list);
1242 }
1243 else {
1244 journalFeed = list.get(0);
1245
1246 cacheResult(journalFeed);
1247
1248 if ((journalFeed.getGroupId() != groupId) ||
1249 (journalFeed.getFeedId() == null) ||
1250 !journalFeed.getFeedId().equals(feedId)) {
1251 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F,
1252 finderArgs, journalFeed);
1253 }
1254 }
1255
1256 return journalFeed;
1257 }
1258 catch (Exception e) {
1259 throw processException(e);
1260 }
1261 finally {
1262 if (result == null) {
1263 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F,
1264 finderArgs, new ArrayList<JournalFeed>());
1265 }
1266
1267 closeSession(session);
1268 }
1269 }
1270 else {
1271 if (result instanceof List<?>) {
1272 return null;
1273 }
1274 else {
1275 return (JournalFeed)result;
1276 }
1277 }
1278 }
1279
1280 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
1281 throws SystemException {
1282 Session session = null;
1283
1284 try {
1285 session = openSession();
1286
1287 dynamicQuery.compile(session);
1288
1289 return dynamicQuery.list();
1290 }
1291 catch (Exception e) {
1292 throw processException(e);
1293 }
1294 finally {
1295 closeSession(session);
1296 }
1297 }
1298
1299 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
1300 int start, int end) throws SystemException {
1301 Session session = null;
1302
1303 try {
1304 session = openSession();
1305
1306 dynamicQuery.setLimit(start, end);
1307
1308 dynamicQuery.compile(session);
1309
1310 return dynamicQuery.list();
1311 }
1312 catch (Exception e) {
1313 throw processException(e);
1314 }
1315 finally {
1316 closeSession(session);
1317 }
1318 }
1319
1320 public List<JournalFeed> findAll() throws SystemException {
1321 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1322 }
1323
1324 public List<JournalFeed> findAll(int start, int end)
1325 throws SystemException {
1326 return findAll(start, end, null);
1327 }
1328
1329 public List<JournalFeed> findAll(int start, int end, OrderByComparator obc)
1330 throws SystemException {
1331 Object[] finderArgs = new Object[] {
1332 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1333 };
1334
1335 List<JournalFeed> list = (List<JournalFeed>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1336 finderArgs, this);
1337
1338 if (list == null) {
1339 Session session = null;
1340
1341 try {
1342 session = openSession();
1343
1344 StringBuilder query = new StringBuilder();
1345
1346 query.append("SELECT journalFeed FROM JournalFeed journalFeed ");
1347
1348 if (obc != null) {
1349 query.append("ORDER BY ");
1350
1351 String[] orderByFields = obc.getOrderByFields();
1352
1353 for (int i = 0; i < orderByFields.length; i++) {
1354 query.append("journalFeed.");
1355 query.append(orderByFields[i]);
1356
1357 if (obc.isAscending()) {
1358 query.append(" ASC");
1359 }
1360 else {
1361 query.append(" DESC");
1362 }
1363
1364 if ((i + 1) < orderByFields.length) {
1365 query.append(", ");
1366 }
1367 }
1368 }
1369
1370 else {
1371 query.append("ORDER BY ");
1372
1373 query.append("journalFeed.feedId ASC");
1374 }
1375
1376 Query q = session.createQuery(query.toString());
1377
1378 if (obc == null) {
1379 list = (List<JournalFeed>)QueryUtil.list(q, getDialect(),
1380 start, end, false);
1381
1382 Collections.sort(list);
1383 }
1384 else {
1385 list = (List<JournalFeed>)QueryUtil.list(q, getDialect(),
1386 start, end);
1387 }
1388 }
1389 catch (Exception e) {
1390 throw processException(e);
1391 }
1392 finally {
1393 if (list == null) {
1394 list = new ArrayList<JournalFeed>();
1395 }
1396
1397 cacheResult(list);
1398
1399 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1400
1401 closeSession(session);
1402 }
1403 }
1404
1405 return list;
1406 }
1407
1408 public void removeByUuid(String uuid) throws SystemException {
1409 for (JournalFeed journalFeed : findByUuid(uuid)) {
1410 remove(journalFeed);
1411 }
1412 }
1413
1414 public void removeByUUID_G(String uuid, long groupId)
1415 throws NoSuchFeedException, SystemException {
1416 JournalFeed journalFeed = findByUUID_G(uuid, groupId);
1417
1418 remove(journalFeed);
1419 }
1420
1421 public void removeByGroupId(long groupId) throws SystemException {
1422 for (JournalFeed journalFeed : findByGroupId(groupId)) {
1423 remove(journalFeed);
1424 }
1425 }
1426
1427 public void removeByG_F(long groupId, String feedId)
1428 throws NoSuchFeedException, SystemException {
1429 JournalFeed journalFeed = findByG_F(groupId, feedId);
1430
1431 remove(journalFeed);
1432 }
1433
1434 public void removeAll() throws SystemException {
1435 for (JournalFeed journalFeed : findAll()) {
1436 remove(journalFeed);
1437 }
1438 }
1439
1440 public int countByUuid(String uuid) throws SystemException {
1441 Object[] finderArgs = new Object[] { uuid };
1442
1443 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
1444 finderArgs, this);
1445
1446 if (count == null) {
1447 Session session = null;
1448
1449 try {
1450 session = openSession();
1451
1452 StringBuilder query = new StringBuilder();
1453
1454 query.append("SELECT COUNT(journalFeed) ");
1455 query.append("FROM JournalFeed journalFeed WHERE ");
1456
1457 if (uuid == null) {
1458 query.append("journalFeed.uuid IS NULL");
1459 }
1460 else {
1461 query.append("journalFeed.uuid = ?");
1462 }
1463
1464 query.append(" ");
1465
1466 Query q = session.createQuery(query.toString());
1467
1468 QueryPos qPos = QueryPos.getInstance(q);
1469
1470 if (uuid != null) {
1471 qPos.add(uuid);
1472 }
1473
1474 count = (Long)q.uniqueResult();
1475 }
1476 catch (Exception e) {
1477 throw processException(e);
1478 }
1479 finally {
1480 if (count == null) {
1481 count = Long.valueOf(0);
1482 }
1483
1484 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
1485 finderArgs, count);
1486
1487 closeSession(session);
1488 }
1489 }
1490
1491 return count.intValue();
1492 }
1493
1494 public int countByUUID_G(String uuid, long groupId)
1495 throws SystemException {
1496 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
1497
1498 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
1499 finderArgs, this);
1500
1501 if (count == null) {
1502 Session session = null;
1503
1504 try {
1505 session = openSession();
1506
1507 StringBuilder query = new StringBuilder();
1508
1509 query.append("SELECT COUNT(journalFeed) ");
1510 query.append("FROM JournalFeed journalFeed WHERE ");
1511
1512 if (uuid == null) {
1513 query.append("journalFeed.uuid IS NULL");
1514 }
1515 else {
1516 query.append("journalFeed.uuid = ?");
1517 }
1518
1519 query.append(" AND ");
1520
1521 query.append("journalFeed.groupId = ?");
1522
1523 query.append(" ");
1524
1525 Query q = session.createQuery(query.toString());
1526
1527 QueryPos qPos = QueryPos.getInstance(q);
1528
1529 if (uuid != null) {
1530 qPos.add(uuid);
1531 }
1532
1533 qPos.add(groupId);
1534
1535 count = (Long)q.uniqueResult();
1536 }
1537 catch (Exception e) {
1538 throw processException(e);
1539 }
1540 finally {
1541 if (count == null) {
1542 count = Long.valueOf(0);
1543 }
1544
1545 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
1546 finderArgs, count);
1547
1548 closeSession(session);
1549 }
1550 }
1551
1552 return count.intValue();
1553 }
1554
1555 public int countByGroupId(long groupId) throws SystemException {
1556 Object[] finderArgs = new Object[] { new Long(groupId) };
1557
1558 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1559 finderArgs, this);
1560
1561 if (count == null) {
1562 Session session = null;
1563
1564 try {
1565 session = openSession();
1566
1567 StringBuilder query = new StringBuilder();
1568
1569 query.append("SELECT COUNT(journalFeed) ");
1570 query.append("FROM JournalFeed journalFeed WHERE ");
1571
1572 query.append("journalFeed.groupId = ?");
1573
1574 query.append(" ");
1575
1576 Query q = session.createQuery(query.toString());
1577
1578 QueryPos qPos = QueryPos.getInstance(q);
1579
1580 qPos.add(groupId);
1581
1582 count = (Long)q.uniqueResult();
1583 }
1584 catch (Exception e) {
1585 throw processException(e);
1586 }
1587 finally {
1588 if (count == null) {
1589 count = Long.valueOf(0);
1590 }
1591
1592 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1593 finderArgs, count);
1594
1595 closeSession(session);
1596 }
1597 }
1598
1599 return count.intValue();
1600 }
1601
1602 public int countByG_F(long groupId, String feedId)
1603 throws SystemException {
1604 Object[] finderArgs = new Object[] { new Long(groupId), feedId };
1605
1606 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F,
1607 finderArgs, this);
1608
1609 if (count == null) {
1610 Session session = null;
1611
1612 try {
1613 session = openSession();
1614
1615 StringBuilder query = new StringBuilder();
1616
1617 query.append("SELECT COUNT(journalFeed) ");
1618 query.append("FROM JournalFeed journalFeed WHERE ");
1619
1620 query.append("journalFeed.groupId = ?");
1621
1622 query.append(" AND ");
1623
1624 if (feedId == null) {
1625 query.append("journalFeed.feedId IS NULL");
1626 }
1627 else {
1628 query.append("journalFeed.feedId = ?");
1629 }
1630
1631 query.append(" ");
1632
1633 Query q = session.createQuery(query.toString());
1634
1635 QueryPos qPos = QueryPos.getInstance(q);
1636
1637 qPos.add(groupId);
1638
1639 if (feedId != null) {
1640 qPos.add(feedId);
1641 }
1642
1643 count = (Long)q.uniqueResult();
1644 }
1645 catch (Exception e) {
1646 throw processException(e);
1647 }
1648 finally {
1649 if (count == null) {
1650 count = Long.valueOf(0);
1651 }
1652
1653 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F, finderArgs,
1654 count);
1655
1656 closeSession(session);
1657 }
1658 }
1659
1660 return count.intValue();
1661 }
1662
1663 public int countAll() throws SystemException {
1664 Object[] finderArgs = new Object[0];
1665
1666 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1667 finderArgs, this);
1668
1669 if (count == null) {
1670 Session session = null;
1671
1672 try {
1673 session = openSession();
1674
1675 Query q = session.createQuery(
1676 "SELECT COUNT(journalFeed) FROM JournalFeed journalFeed");
1677
1678 count = (Long)q.uniqueResult();
1679 }
1680 catch (Exception e) {
1681 throw processException(e);
1682 }
1683 finally {
1684 if (count == null) {
1685 count = Long.valueOf(0);
1686 }
1687
1688 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1689 count);
1690
1691 closeSession(session);
1692 }
1693 }
1694
1695 return count.intValue();
1696 }
1697
1698 public void afterPropertiesSet() {
1699 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1700 com.liferay.portal.util.PropsUtil.get(
1701 "value.object.listener.com.liferay.portlet.journal.model.JournalFeed")));
1702
1703 if (listenerClassNames.length > 0) {
1704 try {
1705 List<ModelListener<JournalFeed>> listenersList = new ArrayList<ModelListener<JournalFeed>>();
1706
1707 for (String listenerClassName : listenerClassNames) {
1708 listenersList.add((ModelListener<JournalFeed>)Class.forName(
1709 listenerClassName).newInstance());
1710 }
1711
1712 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1713 }
1714 catch (Exception e) {
1715 _log.error(e);
1716 }
1717 }
1718 }
1719
1720 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalArticlePersistence.impl")
1721 protected com.liferay.portlet.journal.service.persistence.JournalArticlePersistence journalArticlePersistence;
1722 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalArticleImagePersistence.impl")
1723 protected com.liferay.portlet.journal.service.persistence.JournalArticleImagePersistence journalArticleImagePersistence;
1724 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalArticleResourcePersistence.impl")
1725 protected com.liferay.portlet.journal.service.persistence.JournalArticleResourcePersistence journalArticleResourcePersistence;
1726 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalContentSearchPersistence.impl")
1727 protected com.liferay.portlet.journal.service.persistence.JournalContentSearchPersistence journalContentSearchPersistence;
1728 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalFeedPersistence.impl")
1729 protected com.liferay.portlet.journal.service.persistence.JournalFeedPersistence journalFeedPersistence;
1730 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalStructurePersistence.impl")
1731 protected com.liferay.portlet.journal.service.persistence.JournalStructurePersistence journalStructurePersistence;
1732 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalTemplatePersistence.impl")
1733 protected com.liferay.portlet.journal.service.persistence.JournalTemplatePersistence journalTemplatePersistence;
1734 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
1735 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
1736 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
1737 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
1738 @BeanReference(name = "com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence.impl")
1739 protected com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence expandoValuePersistence;
1740 private static Log _log = LogFactoryUtil.getLog(JournalFeedPersistenceImpl.class);
1741}