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