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