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