001
014
015 package com.liferay.portlet.journal.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.bean.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderPath;
023 import com.liferay.portal.kernel.dao.orm.Query;
024 import com.liferay.portal.kernel.dao.orm.QueryPos;
025 import com.liferay.portal.kernel.dao.orm.QueryUtil;
026 import com.liferay.portal.kernel.dao.orm.SQLQuery;
027 import com.liferay.portal.kernel.dao.orm.Session;
028 import com.liferay.portal.kernel.exception.SystemException;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
031 import com.liferay.portal.kernel.util.GetterUtil;
032 import com.liferay.portal.kernel.util.InstanceFactory;
033 import com.liferay.portal.kernel.util.OrderByComparator;
034 import com.liferay.portal.kernel.util.StringBundler;
035 import com.liferay.portal.kernel.util.StringPool;
036 import com.liferay.portal.kernel.util.StringUtil;
037 import com.liferay.portal.kernel.util.Validator;
038 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
039 import com.liferay.portal.model.CacheModel;
040 import com.liferay.portal.model.ModelListener;
041 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
042 import com.liferay.portal.service.persistence.UserPersistence;
043 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
044
045 import com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence;
046 import com.liferay.portlet.journal.NoSuchFeedException;
047 import com.liferay.portlet.journal.model.JournalFeed;
048 import com.liferay.portlet.journal.model.impl.JournalFeedImpl;
049 import com.liferay.portlet.journal.model.impl.JournalFeedModelImpl;
050
051 import java.io.Serializable;
052
053 import java.util.ArrayList;
054 import java.util.Collections;
055 import java.util.List;
056
057
069 public class JournalFeedPersistenceImpl extends BasePersistenceImpl<JournalFeed>
070 implements JournalFeedPersistence {
071
076 public static final String FINDER_CLASS_NAME_ENTITY = JournalFeedImpl.class.getName();
077 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
078 ".List1";
079 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
080 ".List2";
081 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
082 JournalFeedModelImpl.FINDER_CACHE_ENABLED, JournalFeedImpl.class,
083 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
084 new String[] {
085 String.class.getName(),
086
087 "java.lang.Integer", "java.lang.Integer",
088 "com.liferay.portal.kernel.util.OrderByComparator"
089 });
090 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
091 JournalFeedModelImpl.FINDER_CACHE_ENABLED, JournalFeedImpl.class,
092 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
093 new String[] { String.class.getName() },
094 JournalFeedModelImpl.UUID_COLUMN_BITMASK);
095 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
096 JournalFeedModelImpl.FINDER_CACHE_ENABLED, Long.class,
097 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
098 new String[] { String.class.getName() });
099 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
100 JournalFeedModelImpl.FINDER_CACHE_ENABLED, JournalFeedImpl.class,
101 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
102 new String[] { String.class.getName(), Long.class.getName() },
103 JournalFeedModelImpl.UUID_COLUMN_BITMASK |
104 JournalFeedModelImpl.GROUPID_COLUMN_BITMASK);
105 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
106 JournalFeedModelImpl.FINDER_CACHE_ENABLED, Long.class,
107 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
108 new String[] { String.class.getName(), Long.class.getName() });
109 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
110 JournalFeedModelImpl.FINDER_CACHE_ENABLED, JournalFeedImpl.class,
111 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
112 new String[] {
113 String.class.getName(), Long.class.getName(),
114
115 "java.lang.Integer", "java.lang.Integer",
116 "com.liferay.portal.kernel.util.OrderByComparator"
117 });
118 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
119 new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
120 JournalFeedModelImpl.FINDER_CACHE_ENABLED, JournalFeedImpl.class,
121 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
122 new String[] { String.class.getName(), Long.class.getName() },
123 JournalFeedModelImpl.UUID_COLUMN_BITMASK |
124 JournalFeedModelImpl.COMPANYID_COLUMN_BITMASK);
125 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
126 JournalFeedModelImpl.FINDER_CACHE_ENABLED, Long.class,
127 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
128 new String[] { String.class.getName(), Long.class.getName() });
129 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
130 JournalFeedModelImpl.FINDER_CACHE_ENABLED, JournalFeedImpl.class,
131 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
132 new String[] {
133 Long.class.getName(),
134
135 "java.lang.Integer", "java.lang.Integer",
136 "com.liferay.portal.kernel.util.OrderByComparator"
137 });
138 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
139 new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
140 JournalFeedModelImpl.FINDER_CACHE_ENABLED, JournalFeedImpl.class,
141 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
142 new String[] { Long.class.getName() },
143 JournalFeedModelImpl.GROUPID_COLUMN_BITMASK);
144 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
145 JournalFeedModelImpl.FINDER_CACHE_ENABLED, Long.class,
146 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
147 new String[] { Long.class.getName() });
148 public static final FinderPath FINDER_PATH_FETCH_BY_G_F = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
149 JournalFeedModelImpl.FINDER_CACHE_ENABLED, JournalFeedImpl.class,
150 FINDER_CLASS_NAME_ENTITY, "fetchByG_F",
151 new String[] { Long.class.getName(), String.class.getName() },
152 JournalFeedModelImpl.GROUPID_COLUMN_BITMASK |
153 JournalFeedModelImpl.FEEDID_COLUMN_BITMASK);
154 public static final FinderPath FINDER_PATH_COUNT_BY_G_F = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
155 JournalFeedModelImpl.FINDER_CACHE_ENABLED, Long.class,
156 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F",
157 new String[] { Long.class.getName(), String.class.getName() });
158 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
159 JournalFeedModelImpl.FINDER_CACHE_ENABLED, JournalFeedImpl.class,
160 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
161 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
162 JournalFeedModelImpl.FINDER_CACHE_ENABLED, JournalFeedImpl.class,
163 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
164 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
165 JournalFeedModelImpl.FINDER_CACHE_ENABLED, Long.class,
166 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
167
168
173 public void cacheResult(JournalFeed journalFeed) {
174 EntityCacheUtil.putResult(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
175 JournalFeedImpl.class, journalFeed.getPrimaryKey(), journalFeed);
176
177 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
178 new Object[] {
179 journalFeed.getUuid(), Long.valueOf(journalFeed.getGroupId())
180 }, journalFeed);
181
182 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F,
183 new Object[] {
184 Long.valueOf(journalFeed.getGroupId()),
185
186 journalFeed.getFeedId()
187 }, journalFeed);
188
189 journalFeed.resetOriginalValues();
190 }
191
192
197 public void cacheResult(List<JournalFeed> journalFeeds) {
198 for (JournalFeed journalFeed : journalFeeds) {
199 if (EntityCacheUtil.getResult(
200 JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
201 JournalFeedImpl.class, journalFeed.getPrimaryKey()) == null) {
202 cacheResult(journalFeed);
203 }
204 else {
205 journalFeed.resetOriginalValues();
206 }
207 }
208 }
209
210
217 @Override
218 public void clearCache() {
219 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
220 CacheRegistryUtil.clear(JournalFeedImpl.class.getName());
221 }
222
223 EntityCacheUtil.clearCache(JournalFeedImpl.class.getName());
224
225 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
226 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
227 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
228 }
229
230
237 @Override
238 public void clearCache(JournalFeed journalFeed) {
239 EntityCacheUtil.removeResult(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
240 JournalFeedImpl.class, journalFeed.getPrimaryKey());
241
242 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
243 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
244
245 clearUniqueFindersCache(journalFeed);
246 }
247
248 @Override
249 public void clearCache(List<JournalFeed> journalFeeds) {
250 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
251 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
252
253 for (JournalFeed journalFeed : journalFeeds) {
254 EntityCacheUtil.removeResult(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
255 JournalFeedImpl.class, journalFeed.getPrimaryKey());
256
257 clearUniqueFindersCache(journalFeed);
258 }
259 }
260
261 protected void clearUniqueFindersCache(JournalFeed journalFeed) {
262 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
263 new Object[] {
264 journalFeed.getUuid(), Long.valueOf(journalFeed.getGroupId())
265 });
266
267 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F,
268 new Object[] {
269 Long.valueOf(journalFeed.getGroupId()),
270
271 journalFeed.getFeedId()
272 });
273 }
274
275
281 public JournalFeed create(long id) {
282 JournalFeed journalFeed = new JournalFeedImpl();
283
284 journalFeed.setNew(true);
285 journalFeed.setPrimaryKey(id);
286
287 String uuid = PortalUUIDUtil.generate();
288
289 journalFeed.setUuid(uuid);
290
291 return journalFeed;
292 }
293
294
302 public JournalFeed remove(long id)
303 throws NoSuchFeedException, SystemException {
304 return remove(Long.valueOf(id));
305 }
306
307
315 @Override
316 public JournalFeed remove(Serializable primaryKey)
317 throws NoSuchFeedException, SystemException {
318 Session session = null;
319
320 try {
321 session = openSession();
322
323 JournalFeed journalFeed = (JournalFeed)session.get(JournalFeedImpl.class,
324 primaryKey);
325
326 if (journalFeed == null) {
327 if (_log.isWarnEnabled()) {
328 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
329 }
330
331 throw new NoSuchFeedException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
332 primaryKey);
333 }
334
335 return remove(journalFeed);
336 }
337 catch (NoSuchFeedException nsee) {
338 throw nsee;
339 }
340 catch (Exception e) {
341 throw processException(e);
342 }
343 finally {
344 closeSession(session);
345 }
346 }
347
348 @Override
349 protected JournalFeed removeImpl(JournalFeed journalFeed)
350 throws SystemException {
351 journalFeed = toUnwrappedModel(journalFeed);
352
353 Session session = null;
354
355 try {
356 session = openSession();
357
358 if (journalFeed.isCachedModel()) {
359 journalFeed = (JournalFeed)session.get(JournalFeedImpl.class,
360 journalFeed.getPrimaryKeyObj());
361 }
362
363 session.delete(journalFeed);
364 }
365 catch (Exception e) {
366 throw processException(e);
367 }
368 finally {
369 closeSession(session);
370 }
371
372 clearCache(journalFeed);
373
374 return journalFeed;
375 }
376
377 @Override
378 public JournalFeed updateImpl(
379 com.liferay.portlet.journal.model.JournalFeed journalFeed)
380 throws SystemException {
381 journalFeed = toUnwrappedModel(journalFeed);
382
383 boolean isNew = journalFeed.isNew();
384
385 JournalFeedModelImpl journalFeedModelImpl = (JournalFeedModelImpl)journalFeed;
386
387 if (Validator.isNull(journalFeed.getUuid())) {
388 String uuid = PortalUUIDUtil.generate();
389
390 journalFeed.setUuid(uuid);
391 }
392
393 Session session = null;
394
395 try {
396 session = openSession();
397
398 if (journalFeed.isNew()) {
399 session.save(journalFeed);
400
401 journalFeed.setNew(false);
402 }
403 else {
404 session.merge(journalFeed);
405 }
406 }
407 catch (Exception e) {
408 throw processException(e);
409 }
410 finally {
411 closeSession(session);
412 }
413
414 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
415
416 if (isNew || !JournalFeedModelImpl.COLUMN_BITMASK_ENABLED) {
417 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
418 }
419
420 else {
421 if ((journalFeedModelImpl.getColumnBitmask() &
422 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
423 Object[] args = new Object[] {
424 journalFeedModelImpl.getOriginalUuid()
425 };
426
427 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
428 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
429 args);
430
431 args = new Object[] { journalFeedModelImpl.getUuid() };
432
433 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
434 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
435 args);
436 }
437
438 if ((journalFeedModelImpl.getColumnBitmask() &
439 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
440 Object[] args = new Object[] {
441 journalFeedModelImpl.getOriginalUuid(),
442 Long.valueOf(journalFeedModelImpl.getOriginalCompanyId())
443 };
444
445 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
446 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
447 args);
448
449 args = new Object[] {
450 journalFeedModelImpl.getUuid(),
451 Long.valueOf(journalFeedModelImpl.getCompanyId())
452 };
453
454 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
455 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
456 args);
457 }
458
459 if ((journalFeedModelImpl.getColumnBitmask() &
460 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
461 Object[] args = new Object[] {
462 Long.valueOf(journalFeedModelImpl.getOriginalGroupId())
463 };
464
465 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
466 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
467 args);
468
469 args = new Object[] {
470 Long.valueOf(journalFeedModelImpl.getGroupId())
471 };
472
473 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
474 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
475 args);
476 }
477 }
478
479 EntityCacheUtil.putResult(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
480 JournalFeedImpl.class, journalFeed.getPrimaryKey(), journalFeed);
481
482 if (isNew) {
483 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
484 new Object[] {
485 journalFeed.getUuid(),
486 Long.valueOf(journalFeed.getGroupId())
487 }, journalFeed);
488
489 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F,
490 new Object[] {
491 Long.valueOf(journalFeed.getGroupId()),
492
493 journalFeed.getFeedId()
494 }, journalFeed);
495 }
496 else {
497 if ((journalFeedModelImpl.getColumnBitmask() &
498 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
499 Object[] args = new Object[] {
500 journalFeedModelImpl.getOriginalUuid(),
501 Long.valueOf(journalFeedModelImpl.getOriginalGroupId())
502 };
503
504 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
505
506 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
507
508 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
509 new Object[] {
510 journalFeed.getUuid(),
511 Long.valueOf(journalFeed.getGroupId())
512 }, journalFeed);
513 }
514
515 if ((journalFeedModelImpl.getColumnBitmask() &
516 FINDER_PATH_FETCH_BY_G_F.getColumnBitmask()) != 0) {
517 Object[] args = new Object[] {
518 Long.valueOf(journalFeedModelImpl.getOriginalGroupId()),
519
520 journalFeedModelImpl.getOriginalFeedId()
521 };
522
523 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
524
525 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F, args);
526
527 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F,
528 new Object[] {
529 Long.valueOf(journalFeed.getGroupId()),
530
531 journalFeed.getFeedId()
532 }, journalFeed);
533 }
534 }
535
536 return journalFeed;
537 }
538
539 protected JournalFeed toUnwrappedModel(JournalFeed journalFeed) {
540 if (journalFeed instanceof JournalFeedImpl) {
541 return journalFeed;
542 }
543
544 JournalFeedImpl journalFeedImpl = new JournalFeedImpl();
545
546 journalFeedImpl.setNew(journalFeed.isNew());
547 journalFeedImpl.setPrimaryKey(journalFeed.getPrimaryKey());
548
549 journalFeedImpl.setUuid(journalFeed.getUuid());
550 journalFeedImpl.setId(journalFeed.getId());
551 journalFeedImpl.setGroupId(journalFeed.getGroupId());
552 journalFeedImpl.setCompanyId(journalFeed.getCompanyId());
553 journalFeedImpl.setUserId(journalFeed.getUserId());
554 journalFeedImpl.setUserName(journalFeed.getUserName());
555 journalFeedImpl.setCreateDate(journalFeed.getCreateDate());
556 journalFeedImpl.setModifiedDate(journalFeed.getModifiedDate());
557 journalFeedImpl.setFeedId(journalFeed.getFeedId());
558 journalFeedImpl.setName(journalFeed.getName());
559 journalFeedImpl.setDescription(journalFeed.getDescription());
560 journalFeedImpl.setType(journalFeed.getType());
561 journalFeedImpl.setStructureId(journalFeed.getStructureId());
562 journalFeedImpl.setTemplateId(journalFeed.getTemplateId());
563 journalFeedImpl.setRendererTemplateId(journalFeed.getRendererTemplateId());
564 journalFeedImpl.setDelta(journalFeed.getDelta());
565 journalFeedImpl.setOrderByCol(journalFeed.getOrderByCol());
566 journalFeedImpl.setOrderByType(journalFeed.getOrderByType());
567 journalFeedImpl.setTargetLayoutFriendlyUrl(journalFeed.getTargetLayoutFriendlyUrl());
568 journalFeedImpl.setTargetPortletId(journalFeed.getTargetPortletId());
569 journalFeedImpl.setContentField(journalFeed.getContentField());
570 journalFeedImpl.setFeedType(journalFeed.getFeedType());
571 journalFeedImpl.setFeedVersion(journalFeed.getFeedVersion());
572
573 return journalFeedImpl;
574 }
575
576
584 @Override
585 public JournalFeed findByPrimaryKey(Serializable primaryKey)
586 throws NoSuchModelException, SystemException {
587 return findByPrimaryKey(((Long)primaryKey).longValue());
588 }
589
590
598 public JournalFeed findByPrimaryKey(long id)
599 throws NoSuchFeedException, SystemException {
600 JournalFeed journalFeed = fetchByPrimaryKey(id);
601
602 if (journalFeed == null) {
603 if (_log.isWarnEnabled()) {
604 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + id);
605 }
606
607 throw new NoSuchFeedException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
608 id);
609 }
610
611 return journalFeed;
612 }
613
614
621 @Override
622 public JournalFeed fetchByPrimaryKey(Serializable primaryKey)
623 throws SystemException {
624 return fetchByPrimaryKey(((Long)primaryKey).longValue());
625 }
626
627
634 public JournalFeed fetchByPrimaryKey(long id) throws SystemException {
635 JournalFeed journalFeed = (JournalFeed)EntityCacheUtil.getResult(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
636 JournalFeedImpl.class, id);
637
638 if (journalFeed == _nullJournalFeed) {
639 return null;
640 }
641
642 if (journalFeed == null) {
643 Session session = null;
644
645 boolean hasException = false;
646
647 try {
648 session = openSession();
649
650 journalFeed = (JournalFeed)session.get(JournalFeedImpl.class,
651 Long.valueOf(id));
652 }
653 catch (Exception e) {
654 hasException = true;
655
656 throw processException(e);
657 }
658 finally {
659 if (journalFeed != null) {
660 cacheResult(journalFeed);
661 }
662 else if (!hasException) {
663 EntityCacheUtil.putResult(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
664 JournalFeedImpl.class, id, _nullJournalFeed);
665 }
666
667 closeSession(session);
668 }
669 }
670
671 return journalFeed;
672 }
673
674
681 public List<JournalFeed> findByUuid(String uuid) throws SystemException {
682 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
683 }
684
685
698 public List<JournalFeed> findByUuid(String uuid, int start, int end)
699 throws SystemException {
700 return findByUuid(uuid, start, end, null);
701 }
702
703
717 public List<JournalFeed> findByUuid(String uuid, int start, int end,
718 OrderByComparator orderByComparator) throws SystemException {
719 FinderPath finderPath = null;
720 Object[] finderArgs = null;
721
722 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
723 (orderByComparator == null)) {
724 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
725 finderArgs = new Object[] { uuid };
726 }
727 else {
728 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
729 finderArgs = new Object[] { uuid, start, end, orderByComparator };
730 }
731
732 List<JournalFeed> list = (List<JournalFeed>)FinderCacheUtil.getResult(finderPath,
733 finderArgs, this);
734
735 if ((list != null) && !list.isEmpty()) {
736 for (JournalFeed journalFeed : list) {
737 if (!Validator.equals(uuid, journalFeed.getUuid())) {
738 list = null;
739
740 break;
741 }
742 }
743 }
744
745 if (list == null) {
746 StringBundler query = null;
747
748 if (orderByComparator != null) {
749 query = new StringBundler(3 +
750 (orderByComparator.getOrderByFields().length * 3));
751 }
752 else {
753 query = new StringBundler(3);
754 }
755
756 query.append(_SQL_SELECT_JOURNALFEED_WHERE);
757
758 if (uuid == null) {
759 query.append(_FINDER_COLUMN_UUID_UUID_1);
760 }
761 else {
762 if (uuid.equals(StringPool.BLANK)) {
763 query.append(_FINDER_COLUMN_UUID_UUID_3);
764 }
765 else {
766 query.append(_FINDER_COLUMN_UUID_UUID_2);
767 }
768 }
769
770 if (orderByComparator != null) {
771 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
772 orderByComparator);
773 }
774
775 else {
776 query.append(JournalFeedModelImpl.ORDER_BY_JPQL);
777 }
778
779 String sql = query.toString();
780
781 Session session = null;
782
783 try {
784 session = openSession();
785
786 Query q = session.createQuery(sql);
787
788 QueryPos qPos = QueryPos.getInstance(q);
789
790 if (uuid != null) {
791 qPos.add(uuid);
792 }
793
794 list = (List<JournalFeed>)QueryUtil.list(q, getDialect(),
795 start, end);
796 }
797 catch (Exception e) {
798 throw processException(e);
799 }
800 finally {
801 if (list == null) {
802 FinderCacheUtil.removeResult(finderPath, finderArgs);
803 }
804 else {
805 cacheResult(list);
806
807 FinderCacheUtil.putResult(finderPath, finderArgs, list);
808 }
809
810 closeSession(session);
811 }
812 }
813
814 return list;
815 }
816
817
826 public JournalFeed findByUuid_First(String uuid,
827 OrderByComparator orderByComparator)
828 throws NoSuchFeedException, SystemException {
829 JournalFeed journalFeed = fetchByUuid_First(uuid, orderByComparator);
830
831 if (journalFeed != null) {
832 return journalFeed;
833 }
834
835 StringBundler msg = new StringBundler(4);
836
837 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
838
839 msg.append("uuid=");
840 msg.append(uuid);
841
842 msg.append(StringPool.CLOSE_CURLY_BRACE);
843
844 throw new NoSuchFeedException(msg.toString());
845 }
846
847
855 public JournalFeed fetchByUuid_First(String uuid,
856 OrderByComparator orderByComparator) throws SystemException {
857 List<JournalFeed> list = findByUuid(uuid, 0, 1, orderByComparator);
858
859 if (!list.isEmpty()) {
860 return list.get(0);
861 }
862
863 return null;
864 }
865
866
875 public JournalFeed findByUuid_Last(String uuid,
876 OrderByComparator orderByComparator)
877 throws NoSuchFeedException, SystemException {
878 JournalFeed journalFeed = fetchByUuid_Last(uuid, orderByComparator);
879
880 if (journalFeed != null) {
881 return journalFeed;
882 }
883
884 StringBundler msg = new StringBundler(4);
885
886 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
887
888 msg.append("uuid=");
889 msg.append(uuid);
890
891 msg.append(StringPool.CLOSE_CURLY_BRACE);
892
893 throw new NoSuchFeedException(msg.toString());
894 }
895
896
904 public JournalFeed fetchByUuid_Last(String uuid,
905 OrderByComparator orderByComparator) throws SystemException {
906 int count = countByUuid(uuid);
907
908 List<JournalFeed> list = findByUuid(uuid, count - 1, count,
909 orderByComparator);
910
911 if (!list.isEmpty()) {
912 return list.get(0);
913 }
914
915 return null;
916 }
917
918
928 public JournalFeed[] findByUuid_PrevAndNext(long id, String uuid,
929 OrderByComparator orderByComparator)
930 throws NoSuchFeedException, SystemException {
931 JournalFeed journalFeed = findByPrimaryKey(id);
932
933 Session session = null;
934
935 try {
936 session = openSession();
937
938 JournalFeed[] array = new JournalFeedImpl[3];
939
940 array[0] = getByUuid_PrevAndNext(session, journalFeed, uuid,
941 orderByComparator, true);
942
943 array[1] = journalFeed;
944
945 array[2] = getByUuid_PrevAndNext(session, journalFeed, uuid,
946 orderByComparator, false);
947
948 return array;
949 }
950 catch (Exception e) {
951 throw processException(e);
952 }
953 finally {
954 closeSession(session);
955 }
956 }
957
958 protected JournalFeed getByUuid_PrevAndNext(Session session,
959 JournalFeed journalFeed, String uuid,
960 OrderByComparator orderByComparator, boolean previous) {
961 StringBundler query = null;
962
963 if (orderByComparator != null) {
964 query = new StringBundler(6 +
965 (orderByComparator.getOrderByFields().length * 6));
966 }
967 else {
968 query = new StringBundler(3);
969 }
970
971 query.append(_SQL_SELECT_JOURNALFEED_WHERE);
972
973 if (uuid == null) {
974 query.append(_FINDER_COLUMN_UUID_UUID_1);
975 }
976 else {
977 if (uuid.equals(StringPool.BLANK)) {
978 query.append(_FINDER_COLUMN_UUID_UUID_3);
979 }
980 else {
981 query.append(_FINDER_COLUMN_UUID_UUID_2);
982 }
983 }
984
985 if (orderByComparator != null) {
986 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
987
988 if (orderByConditionFields.length > 0) {
989 query.append(WHERE_AND);
990 }
991
992 for (int i = 0; i < orderByConditionFields.length; i++) {
993 query.append(_ORDER_BY_ENTITY_ALIAS);
994 query.append(orderByConditionFields[i]);
995
996 if ((i + 1) < orderByConditionFields.length) {
997 if (orderByComparator.isAscending() ^ previous) {
998 query.append(WHERE_GREATER_THAN_HAS_NEXT);
999 }
1000 else {
1001 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1002 }
1003 }
1004 else {
1005 if (orderByComparator.isAscending() ^ previous) {
1006 query.append(WHERE_GREATER_THAN);
1007 }
1008 else {
1009 query.append(WHERE_LESSER_THAN);
1010 }
1011 }
1012 }
1013
1014 query.append(ORDER_BY_CLAUSE);
1015
1016 String[] orderByFields = orderByComparator.getOrderByFields();
1017
1018 for (int i = 0; i < orderByFields.length; i++) {
1019 query.append(_ORDER_BY_ENTITY_ALIAS);
1020 query.append(orderByFields[i]);
1021
1022 if ((i + 1) < orderByFields.length) {
1023 if (orderByComparator.isAscending() ^ previous) {
1024 query.append(ORDER_BY_ASC_HAS_NEXT);
1025 }
1026 else {
1027 query.append(ORDER_BY_DESC_HAS_NEXT);
1028 }
1029 }
1030 else {
1031 if (orderByComparator.isAscending() ^ previous) {
1032 query.append(ORDER_BY_ASC);
1033 }
1034 else {
1035 query.append(ORDER_BY_DESC);
1036 }
1037 }
1038 }
1039 }
1040
1041 else {
1042 query.append(JournalFeedModelImpl.ORDER_BY_JPQL);
1043 }
1044
1045 String sql = query.toString();
1046
1047 Query q = session.createQuery(sql);
1048
1049 q.setFirstResult(0);
1050 q.setMaxResults(2);
1051
1052 QueryPos qPos = QueryPos.getInstance(q);
1053
1054 if (uuid != null) {
1055 qPos.add(uuid);
1056 }
1057
1058 if (orderByComparator != null) {
1059 Object[] values = orderByComparator.getOrderByConditionValues(journalFeed);
1060
1061 for (Object value : values) {
1062 qPos.add(value);
1063 }
1064 }
1065
1066 List<JournalFeed> list = q.list();
1067
1068 if (list.size() == 2) {
1069 return list.get(1);
1070 }
1071 else {
1072 return null;
1073 }
1074 }
1075
1076
1085 public JournalFeed findByUUID_G(String uuid, long groupId)
1086 throws NoSuchFeedException, SystemException {
1087 JournalFeed journalFeed = fetchByUUID_G(uuid, groupId);
1088
1089 if (journalFeed == null) {
1090 StringBundler msg = new StringBundler(6);
1091
1092 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1093
1094 msg.append("uuid=");
1095 msg.append(uuid);
1096
1097 msg.append(", groupId=");
1098 msg.append(groupId);
1099
1100 msg.append(StringPool.CLOSE_CURLY_BRACE);
1101
1102 if (_log.isWarnEnabled()) {
1103 _log.warn(msg.toString());
1104 }
1105
1106 throw new NoSuchFeedException(msg.toString());
1107 }
1108
1109 return journalFeed;
1110 }
1111
1112
1120 public JournalFeed fetchByUUID_G(String uuid, long groupId)
1121 throws SystemException {
1122 return fetchByUUID_G(uuid, groupId, true);
1123 }
1124
1125
1134 public JournalFeed fetchByUUID_G(String uuid, long groupId,
1135 boolean retrieveFromCache) throws SystemException {
1136 Object[] finderArgs = new Object[] { uuid, groupId };
1137
1138 Object result = null;
1139
1140 if (retrieveFromCache) {
1141 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1142 finderArgs, this);
1143 }
1144
1145 if (result instanceof JournalFeed) {
1146 JournalFeed journalFeed = (JournalFeed)result;
1147
1148 if (!Validator.equals(uuid, journalFeed.getUuid()) ||
1149 (groupId != journalFeed.getGroupId())) {
1150 result = null;
1151 }
1152 }
1153
1154 if (result == null) {
1155 StringBundler query = new StringBundler(4);
1156
1157 query.append(_SQL_SELECT_JOURNALFEED_WHERE);
1158
1159 if (uuid == null) {
1160 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1161 }
1162 else {
1163 if (uuid.equals(StringPool.BLANK)) {
1164 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1165 }
1166 else {
1167 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1168 }
1169 }
1170
1171 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1172
1173 query.append(JournalFeedModelImpl.ORDER_BY_JPQL);
1174
1175 String sql = query.toString();
1176
1177 Session session = null;
1178
1179 try {
1180 session = openSession();
1181
1182 Query q = session.createQuery(sql);
1183
1184 QueryPos qPos = QueryPos.getInstance(q);
1185
1186 if (uuid != null) {
1187 qPos.add(uuid);
1188 }
1189
1190 qPos.add(groupId);
1191
1192 List<JournalFeed> list = q.list();
1193
1194 result = list;
1195
1196 JournalFeed journalFeed = null;
1197
1198 if (list.isEmpty()) {
1199 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1200 finderArgs, list);
1201 }
1202 else {
1203 journalFeed = list.get(0);
1204
1205 cacheResult(journalFeed);
1206
1207 if ((journalFeed.getUuid() == null) ||
1208 !journalFeed.getUuid().equals(uuid) ||
1209 (journalFeed.getGroupId() != groupId)) {
1210 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1211 finderArgs, journalFeed);
1212 }
1213 }
1214
1215 return journalFeed;
1216 }
1217 catch (Exception e) {
1218 throw processException(e);
1219 }
1220 finally {
1221 if (result == null) {
1222 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1223 finderArgs);
1224 }
1225
1226 closeSession(session);
1227 }
1228 }
1229 else {
1230 if (result instanceof List<?>) {
1231 return null;
1232 }
1233 else {
1234 return (JournalFeed)result;
1235 }
1236 }
1237 }
1238
1239
1247 public List<JournalFeed> findByUuid_C(String uuid, long companyId)
1248 throws SystemException {
1249 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1250 QueryUtil.ALL_POS, null);
1251 }
1252
1253
1267 public List<JournalFeed> findByUuid_C(String uuid, long companyId,
1268 int start, int end) throws SystemException {
1269 return findByUuid_C(uuid, companyId, start, end, null);
1270 }
1271
1272
1287 public List<JournalFeed> findByUuid_C(String uuid, long companyId,
1288 int start, int end, OrderByComparator orderByComparator)
1289 throws SystemException {
1290 FinderPath finderPath = null;
1291 Object[] finderArgs = null;
1292
1293 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1294 (orderByComparator == null)) {
1295 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1296 finderArgs = new Object[] { uuid, companyId };
1297 }
1298 else {
1299 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1300 finderArgs = new Object[] {
1301 uuid, companyId,
1302
1303 start, end, orderByComparator
1304 };
1305 }
1306
1307 List<JournalFeed> list = (List<JournalFeed>)FinderCacheUtil.getResult(finderPath,
1308 finderArgs, this);
1309
1310 if ((list != null) && !list.isEmpty()) {
1311 for (JournalFeed journalFeed : list) {
1312 if (!Validator.equals(uuid, journalFeed.getUuid()) ||
1313 (companyId != journalFeed.getCompanyId())) {
1314 list = null;
1315
1316 break;
1317 }
1318 }
1319 }
1320
1321 if (list == null) {
1322 StringBundler query = null;
1323
1324 if (orderByComparator != null) {
1325 query = new StringBundler(4 +
1326 (orderByComparator.getOrderByFields().length * 3));
1327 }
1328 else {
1329 query = new StringBundler(4);
1330 }
1331
1332 query.append(_SQL_SELECT_JOURNALFEED_WHERE);
1333
1334 if (uuid == null) {
1335 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1336 }
1337 else {
1338 if (uuid.equals(StringPool.BLANK)) {
1339 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1340 }
1341 else {
1342 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1343 }
1344 }
1345
1346 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1347
1348 if (orderByComparator != null) {
1349 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1350 orderByComparator);
1351 }
1352
1353 else {
1354 query.append(JournalFeedModelImpl.ORDER_BY_JPQL);
1355 }
1356
1357 String sql = query.toString();
1358
1359 Session session = null;
1360
1361 try {
1362 session = openSession();
1363
1364 Query q = session.createQuery(sql);
1365
1366 QueryPos qPos = QueryPos.getInstance(q);
1367
1368 if (uuid != null) {
1369 qPos.add(uuid);
1370 }
1371
1372 qPos.add(companyId);
1373
1374 list = (List<JournalFeed>)QueryUtil.list(q, getDialect(),
1375 start, end);
1376 }
1377 catch (Exception e) {
1378 throw processException(e);
1379 }
1380 finally {
1381 if (list == null) {
1382 FinderCacheUtil.removeResult(finderPath, finderArgs);
1383 }
1384 else {
1385 cacheResult(list);
1386
1387 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1388 }
1389
1390 closeSession(session);
1391 }
1392 }
1393
1394 return list;
1395 }
1396
1397
1407 public JournalFeed findByUuid_C_First(String uuid, long companyId,
1408 OrderByComparator orderByComparator)
1409 throws NoSuchFeedException, SystemException {
1410 JournalFeed journalFeed = fetchByUuid_C_First(uuid, companyId,
1411 orderByComparator);
1412
1413 if (journalFeed != null) {
1414 return journalFeed;
1415 }
1416
1417 StringBundler msg = new StringBundler(6);
1418
1419 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1420
1421 msg.append("uuid=");
1422 msg.append(uuid);
1423
1424 msg.append(", companyId=");
1425 msg.append(companyId);
1426
1427 msg.append(StringPool.CLOSE_CURLY_BRACE);
1428
1429 throw new NoSuchFeedException(msg.toString());
1430 }
1431
1432
1441 public JournalFeed fetchByUuid_C_First(String uuid, long companyId,
1442 OrderByComparator orderByComparator) throws SystemException {
1443 List<JournalFeed> list = findByUuid_C(uuid, companyId, 0, 1,
1444 orderByComparator);
1445
1446 if (!list.isEmpty()) {
1447 return list.get(0);
1448 }
1449
1450 return null;
1451 }
1452
1453
1463 public JournalFeed findByUuid_C_Last(String uuid, long companyId,
1464 OrderByComparator orderByComparator)
1465 throws NoSuchFeedException, SystemException {
1466 JournalFeed journalFeed = fetchByUuid_C_Last(uuid, companyId,
1467 orderByComparator);
1468
1469 if (journalFeed != null) {
1470 return journalFeed;
1471 }
1472
1473 StringBundler msg = new StringBundler(6);
1474
1475 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1476
1477 msg.append("uuid=");
1478 msg.append(uuid);
1479
1480 msg.append(", companyId=");
1481 msg.append(companyId);
1482
1483 msg.append(StringPool.CLOSE_CURLY_BRACE);
1484
1485 throw new NoSuchFeedException(msg.toString());
1486 }
1487
1488
1497 public JournalFeed fetchByUuid_C_Last(String uuid, long companyId,
1498 OrderByComparator orderByComparator) throws SystemException {
1499 int count = countByUuid_C(uuid, companyId);
1500
1501 List<JournalFeed> list = findByUuid_C(uuid, companyId, count - 1,
1502 count, orderByComparator);
1503
1504 if (!list.isEmpty()) {
1505 return list.get(0);
1506 }
1507
1508 return null;
1509 }
1510
1511
1522 public JournalFeed[] findByUuid_C_PrevAndNext(long id, String uuid,
1523 long companyId, OrderByComparator orderByComparator)
1524 throws NoSuchFeedException, SystemException {
1525 JournalFeed journalFeed = findByPrimaryKey(id);
1526
1527 Session session = null;
1528
1529 try {
1530 session = openSession();
1531
1532 JournalFeed[] array = new JournalFeedImpl[3];
1533
1534 array[0] = getByUuid_C_PrevAndNext(session, journalFeed, uuid,
1535 companyId, orderByComparator, true);
1536
1537 array[1] = journalFeed;
1538
1539 array[2] = getByUuid_C_PrevAndNext(session, journalFeed, uuid,
1540 companyId, orderByComparator, false);
1541
1542 return array;
1543 }
1544 catch (Exception e) {
1545 throw processException(e);
1546 }
1547 finally {
1548 closeSession(session);
1549 }
1550 }
1551
1552 protected JournalFeed getByUuid_C_PrevAndNext(Session session,
1553 JournalFeed journalFeed, String uuid, long companyId,
1554 OrderByComparator orderByComparator, boolean previous) {
1555 StringBundler query = null;
1556
1557 if (orderByComparator != null) {
1558 query = new StringBundler(6 +
1559 (orderByComparator.getOrderByFields().length * 6));
1560 }
1561 else {
1562 query = new StringBundler(3);
1563 }
1564
1565 query.append(_SQL_SELECT_JOURNALFEED_WHERE);
1566
1567 if (uuid == null) {
1568 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1569 }
1570 else {
1571 if (uuid.equals(StringPool.BLANK)) {
1572 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1573 }
1574 else {
1575 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1576 }
1577 }
1578
1579 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1580
1581 if (orderByComparator != null) {
1582 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1583
1584 if (orderByConditionFields.length > 0) {
1585 query.append(WHERE_AND);
1586 }
1587
1588 for (int i = 0; i < orderByConditionFields.length; i++) {
1589 query.append(_ORDER_BY_ENTITY_ALIAS);
1590 query.append(orderByConditionFields[i]);
1591
1592 if ((i + 1) < orderByConditionFields.length) {
1593 if (orderByComparator.isAscending() ^ previous) {
1594 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1595 }
1596 else {
1597 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1598 }
1599 }
1600 else {
1601 if (orderByComparator.isAscending() ^ previous) {
1602 query.append(WHERE_GREATER_THAN);
1603 }
1604 else {
1605 query.append(WHERE_LESSER_THAN);
1606 }
1607 }
1608 }
1609
1610 query.append(ORDER_BY_CLAUSE);
1611
1612 String[] orderByFields = orderByComparator.getOrderByFields();
1613
1614 for (int i = 0; i < orderByFields.length; i++) {
1615 query.append(_ORDER_BY_ENTITY_ALIAS);
1616 query.append(orderByFields[i]);
1617
1618 if ((i + 1) < orderByFields.length) {
1619 if (orderByComparator.isAscending() ^ previous) {
1620 query.append(ORDER_BY_ASC_HAS_NEXT);
1621 }
1622 else {
1623 query.append(ORDER_BY_DESC_HAS_NEXT);
1624 }
1625 }
1626 else {
1627 if (orderByComparator.isAscending() ^ previous) {
1628 query.append(ORDER_BY_ASC);
1629 }
1630 else {
1631 query.append(ORDER_BY_DESC);
1632 }
1633 }
1634 }
1635 }
1636
1637 else {
1638 query.append(JournalFeedModelImpl.ORDER_BY_JPQL);
1639 }
1640
1641 String sql = query.toString();
1642
1643 Query q = session.createQuery(sql);
1644
1645 q.setFirstResult(0);
1646 q.setMaxResults(2);
1647
1648 QueryPos qPos = QueryPos.getInstance(q);
1649
1650 if (uuid != null) {
1651 qPos.add(uuid);
1652 }
1653
1654 qPos.add(companyId);
1655
1656 if (orderByComparator != null) {
1657 Object[] values = orderByComparator.getOrderByConditionValues(journalFeed);
1658
1659 for (Object value : values) {
1660 qPos.add(value);
1661 }
1662 }
1663
1664 List<JournalFeed> list = q.list();
1665
1666 if (list.size() == 2) {
1667 return list.get(1);
1668 }
1669 else {
1670 return null;
1671 }
1672 }
1673
1674
1681 public List<JournalFeed> findByGroupId(long groupId)
1682 throws SystemException {
1683 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1684 }
1685
1686
1699 public List<JournalFeed> findByGroupId(long groupId, int start, int end)
1700 throws SystemException {
1701 return findByGroupId(groupId, start, end, null);
1702 }
1703
1704
1718 public List<JournalFeed> findByGroupId(long groupId, int start, int end,
1719 OrderByComparator orderByComparator) throws SystemException {
1720 FinderPath finderPath = null;
1721 Object[] finderArgs = null;
1722
1723 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1724 (orderByComparator == null)) {
1725 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1726 finderArgs = new Object[] { groupId };
1727 }
1728 else {
1729 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1730 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1731 }
1732
1733 List<JournalFeed> list = (List<JournalFeed>)FinderCacheUtil.getResult(finderPath,
1734 finderArgs, this);
1735
1736 if ((list != null) && !list.isEmpty()) {
1737 for (JournalFeed journalFeed : list) {
1738 if ((groupId != journalFeed.getGroupId())) {
1739 list = null;
1740
1741 break;
1742 }
1743 }
1744 }
1745
1746 if (list == null) {
1747 StringBundler query = null;
1748
1749 if (orderByComparator != null) {
1750 query = new StringBundler(3 +
1751 (orderByComparator.getOrderByFields().length * 3));
1752 }
1753 else {
1754 query = new StringBundler(3);
1755 }
1756
1757 query.append(_SQL_SELECT_JOURNALFEED_WHERE);
1758
1759 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1760
1761 if (orderByComparator != null) {
1762 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1763 orderByComparator);
1764 }
1765
1766 else {
1767 query.append(JournalFeedModelImpl.ORDER_BY_JPQL);
1768 }
1769
1770 String sql = query.toString();
1771
1772 Session session = null;
1773
1774 try {
1775 session = openSession();
1776
1777 Query q = session.createQuery(sql);
1778
1779 QueryPos qPos = QueryPos.getInstance(q);
1780
1781 qPos.add(groupId);
1782
1783 list = (List<JournalFeed>)QueryUtil.list(q, getDialect(),
1784 start, end);
1785 }
1786 catch (Exception e) {
1787 throw processException(e);
1788 }
1789 finally {
1790 if (list == null) {
1791 FinderCacheUtil.removeResult(finderPath, finderArgs);
1792 }
1793 else {
1794 cacheResult(list);
1795
1796 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1797 }
1798
1799 closeSession(session);
1800 }
1801 }
1802
1803 return list;
1804 }
1805
1806
1815 public JournalFeed findByGroupId_First(long groupId,
1816 OrderByComparator orderByComparator)
1817 throws NoSuchFeedException, SystemException {
1818 JournalFeed journalFeed = fetchByGroupId_First(groupId,
1819 orderByComparator);
1820
1821 if (journalFeed != null) {
1822 return journalFeed;
1823 }
1824
1825 StringBundler msg = new StringBundler(4);
1826
1827 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1828
1829 msg.append("groupId=");
1830 msg.append(groupId);
1831
1832 msg.append(StringPool.CLOSE_CURLY_BRACE);
1833
1834 throw new NoSuchFeedException(msg.toString());
1835 }
1836
1837
1845 public JournalFeed fetchByGroupId_First(long groupId,
1846 OrderByComparator orderByComparator) throws SystemException {
1847 List<JournalFeed> list = findByGroupId(groupId, 0, 1, orderByComparator);
1848
1849 if (!list.isEmpty()) {
1850 return list.get(0);
1851 }
1852
1853 return null;
1854 }
1855
1856
1865 public JournalFeed findByGroupId_Last(long groupId,
1866 OrderByComparator orderByComparator)
1867 throws NoSuchFeedException, SystemException {
1868 JournalFeed journalFeed = fetchByGroupId_Last(groupId, orderByComparator);
1869
1870 if (journalFeed != null) {
1871 return journalFeed;
1872 }
1873
1874 StringBundler msg = new StringBundler(4);
1875
1876 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1877
1878 msg.append("groupId=");
1879 msg.append(groupId);
1880
1881 msg.append(StringPool.CLOSE_CURLY_BRACE);
1882
1883 throw new NoSuchFeedException(msg.toString());
1884 }
1885
1886
1894 public JournalFeed fetchByGroupId_Last(long groupId,
1895 OrderByComparator orderByComparator) throws SystemException {
1896 int count = countByGroupId(groupId);
1897
1898 List<JournalFeed> list = findByGroupId(groupId, count - 1, count,
1899 orderByComparator);
1900
1901 if (!list.isEmpty()) {
1902 return list.get(0);
1903 }
1904
1905 return null;
1906 }
1907
1908
1918 public JournalFeed[] findByGroupId_PrevAndNext(long id, long groupId,
1919 OrderByComparator orderByComparator)
1920 throws NoSuchFeedException, SystemException {
1921 JournalFeed journalFeed = findByPrimaryKey(id);
1922
1923 Session session = null;
1924
1925 try {
1926 session = openSession();
1927
1928 JournalFeed[] array = new JournalFeedImpl[3];
1929
1930 array[0] = getByGroupId_PrevAndNext(session, journalFeed, groupId,
1931 orderByComparator, true);
1932
1933 array[1] = journalFeed;
1934
1935 array[2] = getByGroupId_PrevAndNext(session, journalFeed, groupId,
1936 orderByComparator, false);
1937
1938 return array;
1939 }
1940 catch (Exception e) {
1941 throw processException(e);
1942 }
1943 finally {
1944 closeSession(session);
1945 }
1946 }
1947
1948 protected JournalFeed getByGroupId_PrevAndNext(Session session,
1949 JournalFeed journalFeed, long groupId,
1950 OrderByComparator orderByComparator, boolean previous) {
1951 StringBundler query = null;
1952
1953 if (orderByComparator != null) {
1954 query = new StringBundler(6 +
1955 (orderByComparator.getOrderByFields().length * 6));
1956 }
1957 else {
1958 query = new StringBundler(3);
1959 }
1960
1961 query.append(_SQL_SELECT_JOURNALFEED_WHERE);
1962
1963 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1964
1965 if (orderByComparator != null) {
1966 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1967
1968 if (orderByConditionFields.length > 0) {
1969 query.append(WHERE_AND);
1970 }
1971
1972 for (int i = 0; i < orderByConditionFields.length; i++) {
1973 query.append(_ORDER_BY_ENTITY_ALIAS);
1974 query.append(orderByConditionFields[i]);
1975
1976 if ((i + 1) < orderByConditionFields.length) {
1977 if (orderByComparator.isAscending() ^ previous) {
1978 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1979 }
1980 else {
1981 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1982 }
1983 }
1984 else {
1985 if (orderByComparator.isAscending() ^ previous) {
1986 query.append(WHERE_GREATER_THAN);
1987 }
1988 else {
1989 query.append(WHERE_LESSER_THAN);
1990 }
1991 }
1992 }
1993
1994 query.append(ORDER_BY_CLAUSE);
1995
1996 String[] orderByFields = orderByComparator.getOrderByFields();
1997
1998 for (int i = 0; i < orderByFields.length; i++) {
1999 query.append(_ORDER_BY_ENTITY_ALIAS);
2000 query.append(orderByFields[i]);
2001
2002 if ((i + 1) < orderByFields.length) {
2003 if (orderByComparator.isAscending() ^ previous) {
2004 query.append(ORDER_BY_ASC_HAS_NEXT);
2005 }
2006 else {
2007 query.append(ORDER_BY_DESC_HAS_NEXT);
2008 }
2009 }
2010 else {
2011 if (orderByComparator.isAscending() ^ previous) {
2012 query.append(ORDER_BY_ASC);
2013 }
2014 else {
2015 query.append(ORDER_BY_DESC);
2016 }
2017 }
2018 }
2019 }
2020
2021 else {
2022 query.append(JournalFeedModelImpl.ORDER_BY_JPQL);
2023 }
2024
2025 String sql = query.toString();
2026
2027 Query q = session.createQuery(sql);
2028
2029 q.setFirstResult(0);
2030 q.setMaxResults(2);
2031
2032 QueryPos qPos = QueryPos.getInstance(q);
2033
2034 qPos.add(groupId);
2035
2036 if (orderByComparator != null) {
2037 Object[] values = orderByComparator.getOrderByConditionValues(journalFeed);
2038
2039 for (Object value : values) {
2040 qPos.add(value);
2041 }
2042 }
2043
2044 List<JournalFeed> list = q.list();
2045
2046 if (list.size() == 2) {
2047 return list.get(1);
2048 }
2049 else {
2050 return null;
2051 }
2052 }
2053
2054
2061 public List<JournalFeed> filterFindByGroupId(long groupId)
2062 throws SystemException {
2063 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
2064 QueryUtil.ALL_POS, null);
2065 }
2066
2067
2080 public List<JournalFeed> filterFindByGroupId(long groupId, int start,
2081 int end) throws SystemException {
2082 return filterFindByGroupId(groupId, start, end, null);
2083 }
2084
2085
2099 public List<JournalFeed> filterFindByGroupId(long groupId, int start,
2100 int end, OrderByComparator orderByComparator) throws SystemException {
2101 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2102 return findByGroupId(groupId, start, end, orderByComparator);
2103 }
2104
2105 StringBundler query = null;
2106
2107 if (orderByComparator != null) {
2108 query = new StringBundler(3 +
2109 (orderByComparator.getOrderByFields().length * 3));
2110 }
2111 else {
2112 query = new StringBundler(3);
2113 }
2114
2115 if (getDB().isSupportsInlineDistinct()) {
2116 query.append(_FILTER_SQL_SELECT_JOURNALFEED_WHERE);
2117 }
2118 else {
2119 query.append(_FILTER_SQL_SELECT_JOURNALFEED_NO_INLINE_DISTINCT_WHERE_1);
2120 }
2121
2122 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2123
2124 if (!getDB().isSupportsInlineDistinct()) {
2125 query.append(_FILTER_SQL_SELECT_JOURNALFEED_NO_INLINE_DISTINCT_WHERE_2);
2126 }
2127
2128 if (orderByComparator != null) {
2129 if (getDB().isSupportsInlineDistinct()) {
2130 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2131 orderByComparator);
2132 }
2133 else {
2134 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2135 orderByComparator);
2136 }
2137 }
2138
2139 else {
2140 if (getDB().isSupportsInlineDistinct()) {
2141 query.append(JournalFeedModelImpl.ORDER_BY_JPQL);
2142 }
2143 else {
2144 query.append(JournalFeedModelImpl.ORDER_BY_SQL);
2145 }
2146 }
2147
2148 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2149 JournalFeed.class.getName(),
2150 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2151
2152 Session session = null;
2153
2154 try {
2155 session = openSession();
2156
2157 SQLQuery q = session.createSQLQuery(sql);
2158
2159 if (getDB().isSupportsInlineDistinct()) {
2160 q.addEntity(_FILTER_ENTITY_ALIAS, JournalFeedImpl.class);
2161 }
2162 else {
2163 q.addEntity(_FILTER_ENTITY_TABLE, JournalFeedImpl.class);
2164 }
2165
2166 QueryPos qPos = QueryPos.getInstance(q);
2167
2168 qPos.add(groupId);
2169
2170 return (List<JournalFeed>)QueryUtil.list(q, getDialect(), start, end);
2171 }
2172 catch (Exception e) {
2173 throw processException(e);
2174 }
2175 finally {
2176 closeSession(session);
2177 }
2178 }
2179
2180
2190 public JournalFeed[] filterFindByGroupId_PrevAndNext(long id, long groupId,
2191 OrderByComparator orderByComparator)
2192 throws NoSuchFeedException, SystemException {
2193 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2194 return findByGroupId_PrevAndNext(id, groupId, orderByComparator);
2195 }
2196
2197 JournalFeed journalFeed = findByPrimaryKey(id);
2198
2199 Session session = null;
2200
2201 try {
2202 session = openSession();
2203
2204 JournalFeed[] array = new JournalFeedImpl[3];
2205
2206 array[0] = filterGetByGroupId_PrevAndNext(session, journalFeed,
2207 groupId, orderByComparator, true);
2208
2209 array[1] = journalFeed;
2210
2211 array[2] = filterGetByGroupId_PrevAndNext(session, journalFeed,
2212 groupId, orderByComparator, false);
2213
2214 return array;
2215 }
2216 catch (Exception e) {
2217 throw processException(e);
2218 }
2219 finally {
2220 closeSession(session);
2221 }
2222 }
2223
2224 protected JournalFeed filterGetByGroupId_PrevAndNext(Session session,
2225 JournalFeed journalFeed, long groupId,
2226 OrderByComparator orderByComparator, boolean previous) {
2227 StringBundler query = null;
2228
2229 if (orderByComparator != null) {
2230 query = new StringBundler(6 +
2231 (orderByComparator.getOrderByFields().length * 6));
2232 }
2233 else {
2234 query = new StringBundler(3);
2235 }
2236
2237 if (getDB().isSupportsInlineDistinct()) {
2238 query.append(_FILTER_SQL_SELECT_JOURNALFEED_WHERE);
2239 }
2240 else {
2241 query.append(_FILTER_SQL_SELECT_JOURNALFEED_NO_INLINE_DISTINCT_WHERE_1);
2242 }
2243
2244 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2245
2246 if (!getDB().isSupportsInlineDistinct()) {
2247 query.append(_FILTER_SQL_SELECT_JOURNALFEED_NO_INLINE_DISTINCT_WHERE_2);
2248 }
2249
2250 if (orderByComparator != null) {
2251 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2252
2253 if (orderByConditionFields.length > 0) {
2254 query.append(WHERE_AND);
2255 }
2256
2257 for (int i = 0; i < orderByConditionFields.length; i++) {
2258 if (getDB().isSupportsInlineDistinct()) {
2259 query.append(_ORDER_BY_ENTITY_ALIAS);
2260 }
2261 else {
2262 query.append(_ORDER_BY_ENTITY_TABLE);
2263 }
2264
2265 query.append(orderByConditionFields[i]);
2266
2267 if ((i + 1) < orderByConditionFields.length) {
2268 if (orderByComparator.isAscending() ^ previous) {
2269 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2270 }
2271 else {
2272 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2273 }
2274 }
2275 else {
2276 if (orderByComparator.isAscending() ^ previous) {
2277 query.append(WHERE_GREATER_THAN);
2278 }
2279 else {
2280 query.append(WHERE_LESSER_THAN);
2281 }
2282 }
2283 }
2284
2285 query.append(ORDER_BY_CLAUSE);
2286
2287 String[] orderByFields = orderByComparator.getOrderByFields();
2288
2289 for (int i = 0; i < orderByFields.length; i++) {
2290 if (getDB().isSupportsInlineDistinct()) {
2291 query.append(_ORDER_BY_ENTITY_ALIAS);
2292 }
2293 else {
2294 query.append(_ORDER_BY_ENTITY_TABLE);
2295 }
2296
2297 query.append(orderByFields[i]);
2298
2299 if ((i + 1) < orderByFields.length) {
2300 if (orderByComparator.isAscending() ^ previous) {
2301 query.append(ORDER_BY_ASC_HAS_NEXT);
2302 }
2303 else {
2304 query.append(ORDER_BY_DESC_HAS_NEXT);
2305 }
2306 }
2307 else {
2308 if (orderByComparator.isAscending() ^ previous) {
2309 query.append(ORDER_BY_ASC);
2310 }
2311 else {
2312 query.append(ORDER_BY_DESC);
2313 }
2314 }
2315 }
2316 }
2317
2318 else {
2319 if (getDB().isSupportsInlineDistinct()) {
2320 query.append(JournalFeedModelImpl.ORDER_BY_JPQL);
2321 }
2322 else {
2323 query.append(JournalFeedModelImpl.ORDER_BY_SQL);
2324 }
2325 }
2326
2327 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2328 JournalFeed.class.getName(),
2329 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2330
2331 SQLQuery q = session.createSQLQuery(sql);
2332
2333 q.setFirstResult(0);
2334 q.setMaxResults(2);
2335
2336 if (getDB().isSupportsInlineDistinct()) {
2337 q.addEntity(_FILTER_ENTITY_ALIAS, JournalFeedImpl.class);
2338 }
2339 else {
2340 q.addEntity(_FILTER_ENTITY_TABLE, JournalFeedImpl.class);
2341 }
2342
2343 QueryPos qPos = QueryPos.getInstance(q);
2344
2345 qPos.add(groupId);
2346
2347 if (orderByComparator != null) {
2348 Object[] values = orderByComparator.getOrderByConditionValues(journalFeed);
2349
2350 for (Object value : values) {
2351 qPos.add(value);
2352 }
2353 }
2354
2355 List<JournalFeed> list = q.list();
2356
2357 if (list.size() == 2) {
2358 return list.get(1);
2359 }
2360 else {
2361 return null;
2362 }
2363 }
2364
2365
2374 public JournalFeed findByG_F(long groupId, String feedId)
2375 throws NoSuchFeedException, SystemException {
2376 JournalFeed journalFeed = fetchByG_F(groupId, feedId);
2377
2378 if (journalFeed == null) {
2379 StringBundler msg = new StringBundler(6);
2380
2381 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2382
2383 msg.append("groupId=");
2384 msg.append(groupId);
2385
2386 msg.append(", feedId=");
2387 msg.append(feedId);
2388
2389 msg.append(StringPool.CLOSE_CURLY_BRACE);
2390
2391 if (_log.isWarnEnabled()) {
2392 _log.warn(msg.toString());
2393 }
2394
2395 throw new NoSuchFeedException(msg.toString());
2396 }
2397
2398 return journalFeed;
2399 }
2400
2401
2409 public JournalFeed fetchByG_F(long groupId, String feedId)
2410 throws SystemException {
2411 return fetchByG_F(groupId, feedId, true);
2412 }
2413
2414
2423 public JournalFeed fetchByG_F(long groupId, String feedId,
2424 boolean retrieveFromCache) throws SystemException {
2425 Object[] finderArgs = new Object[] { groupId, feedId };
2426
2427 Object result = null;
2428
2429 if (retrieveFromCache) {
2430 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_F,
2431 finderArgs, this);
2432 }
2433
2434 if (result instanceof JournalFeed) {
2435 JournalFeed journalFeed = (JournalFeed)result;
2436
2437 if ((groupId != journalFeed.getGroupId()) ||
2438 !Validator.equals(feedId, journalFeed.getFeedId())) {
2439 result = null;
2440 }
2441 }
2442
2443 if (result == null) {
2444 StringBundler query = new StringBundler(4);
2445
2446 query.append(_SQL_SELECT_JOURNALFEED_WHERE);
2447
2448 query.append(_FINDER_COLUMN_G_F_GROUPID_2);
2449
2450 if (feedId == null) {
2451 query.append(_FINDER_COLUMN_G_F_FEEDID_1);
2452 }
2453 else {
2454 if (feedId.equals(StringPool.BLANK)) {
2455 query.append(_FINDER_COLUMN_G_F_FEEDID_3);
2456 }
2457 else {
2458 query.append(_FINDER_COLUMN_G_F_FEEDID_2);
2459 }
2460 }
2461
2462 query.append(JournalFeedModelImpl.ORDER_BY_JPQL);
2463
2464 String sql = query.toString();
2465
2466 Session session = null;
2467
2468 try {
2469 session = openSession();
2470
2471 Query q = session.createQuery(sql);
2472
2473 QueryPos qPos = QueryPos.getInstance(q);
2474
2475 qPos.add(groupId);
2476
2477 if (feedId != null) {
2478 qPos.add(feedId);
2479 }
2480
2481 List<JournalFeed> list = q.list();
2482
2483 result = list;
2484
2485 JournalFeed journalFeed = null;
2486
2487 if (list.isEmpty()) {
2488 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F,
2489 finderArgs, list);
2490 }
2491 else {
2492 journalFeed = list.get(0);
2493
2494 cacheResult(journalFeed);
2495
2496 if ((journalFeed.getGroupId() != groupId) ||
2497 (journalFeed.getFeedId() == null) ||
2498 !journalFeed.getFeedId().equals(feedId)) {
2499 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F,
2500 finderArgs, journalFeed);
2501 }
2502 }
2503
2504 return journalFeed;
2505 }
2506 catch (Exception e) {
2507 throw processException(e);
2508 }
2509 finally {
2510 if (result == null) {
2511 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F,
2512 finderArgs);
2513 }
2514
2515 closeSession(session);
2516 }
2517 }
2518 else {
2519 if (result instanceof List<?>) {
2520 return null;
2521 }
2522 else {
2523 return (JournalFeed)result;
2524 }
2525 }
2526 }
2527
2528
2534 public List<JournalFeed> findAll() throws SystemException {
2535 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2536 }
2537
2538
2550 public List<JournalFeed> findAll(int start, int end)
2551 throws SystemException {
2552 return findAll(start, end, null);
2553 }
2554
2555
2568 public List<JournalFeed> findAll(int start, int end,
2569 OrderByComparator orderByComparator) throws SystemException {
2570 FinderPath finderPath = null;
2571 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2572
2573 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2574 (orderByComparator == null)) {
2575 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2576 finderArgs = FINDER_ARGS_EMPTY;
2577 }
2578 else {
2579 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2580 finderArgs = new Object[] { start, end, orderByComparator };
2581 }
2582
2583 List<JournalFeed> list = (List<JournalFeed>)FinderCacheUtil.getResult(finderPath,
2584 finderArgs, this);
2585
2586 if (list == null) {
2587 StringBundler query = null;
2588 String sql = null;
2589
2590 if (orderByComparator != null) {
2591 query = new StringBundler(2 +
2592 (orderByComparator.getOrderByFields().length * 3));
2593
2594 query.append(_SQL_SELECT_JOURNALFEED);
2595
2596 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2597 orderByComparator);
2598
2599 sql = query.toString();
2600 }
2601 else {
2602 sql = _SQL_SELECT_JOURNALFEED.concat(JournalFeedModelImpl.ORDER_BY_JPQL);
2603 }
2604
2605 Session session = null;
2606
2607 try {
2608 session = openSession();
2609
2610 Query q = session.createQuery(sql);
2611
2612 if (orderByComparator == null) {
2613 list = (List<JournalFeed>)QueryUtil.list(q, getDialect(),
2614 start, end, false);
2615
2616 Collections.sort(list);
2617 }
2618 else {
2619 list = (List<JournalFeed>)QueryUtil.list(q, getDialect(),
2620 start, end);
2621 }
2622 }
2623 catch (Exception e) {
2624 throw processException(e);
2625 }
2626 finally {
2627 if (list == null) {
2628 FinderCacheUtil.removeResult(finderPath, finderArgs);
2629 }
2630 else {
2631 cacheResult(list);
2632
2633 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2634 }
2635
2636 closeSession(session);
2637 }
2638 }
2639
2640 return list;
2641 }
2642
2643
2649 public void removeByUuid(String uuid) throws SystemException {
2650 for (JournalFeed journalFeed : findByUuid(uuid)) {
2651 remove(journalFeed);
2652 }
2653 }
2654
2655
2663 public JournalFeed removeByUUID_G(String uuid, long groupId)
2664 throws NoSuchFeedException, SystemException {
2665 JournalFeed journalFeed = findByUUID_G(uuid, groupId);
2666
2667 return remove(journalFeed);
2668 }
2669
2670
2677 public void removeByUuid_C(String uuid, long companyId)
2678 throws SystemException {
2679 for (JournalFeed journalFeed : findByUuid_C(uuid, companyId)) {
2680 remove(journalFeed);
2681 }
2682 }
2683
2684
2690 public void removeByGroupId(long groupId) throws SystemException {
2691 for (JournalFeed journalFeed : findByGroupId(groupId)) {
2692 remove(journalFeed);
2693 }
2694 }
2695
2696
2704 public JournalFeed removeByG_F(long groupId, String feedId)
2705 throws NoSuchFeedException, SystemException {
2706 JournalFeed journalFeed = findByG_F(groupId, feedId);
2707
2708 return remove(journalFeed);
2709 }
2710
2711
2716 public void removeAll() throws SystemException {
2717 for (JournalFeed journalFeed : findAll()) {
2718 remove(journalFeed);
2719 }
2720 }
2721
2722
2729 public int countByUuid(String uuid) throws SystemException {
2730 Object[] finderArgs = new Object[] { uuid };
2731
2732 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
2733 finderArgs, this);
2734
2735 if (count == null) {
2736 StringBundler query = new StringBundler(2);
2737
2738 query.append(_SQL_COUNT_JOURNALFEED_WHERE);
2739
2740 if (uuid == null) {
2741 query.append(_FINDER_COLUMN_UUID_UUID_1);
2742 }
2743 else {
2744 if (uuid.equals(StringPool.BLANK)) {
2745 query.append(_FINDER_COLUMN_UUID_UUID_3);
2746 }
2747 else {
2748 query.append(_FINDER_COLUMN_UUID_UUID_2);
2749 }
2750 }
2751
2752 String sql = query.toString();
2753
2754 Session session = null;
2755
2756 try {
2757 session = openSession();
2758
2759 Query q = session.createQuery(sql);
2760
2761 QueryPos qPos = QueryPos.getInstance(q);
2762
2763 if (uuid != null) {
2764 qPos.add(uuid);
2765 }
2766
2767 count = (Long)q.uniqueResult();
2768 }
2769 catch (Exception e) {
2770 throw processException(e);
2771 }
2772 finally {
2773 if (count == null) {
2774 count = Long.valueOf(0);
2775 }
2776
2777 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
2778 finderArgs, count);
2779
2780 closeSession(session);
2781 }
2782 }
2783
2784 return count.intValue();
2785 }
2786
2787
2795 public int countByUUID_G(String uuid, long groupId)
2796 throws SystemException {
2797 Object[] finderArgs = new Object[] { uuid, groupId };
2798
2799 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
2800 finderArgs, this);
2801
2802 if (count == null) {
2803 StringBundler query = new StringBundler(3);
2804
2805 query.append(_SQL_COUNT_JOURNALFEED_WHERE);
2806
2807 if (uuid == null) {
2808 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
2809 }
2810 else {
2811 if (uuid.equals(StringPool.BLANK)) {
2812 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
2813 }
2814 else {
2815 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
2816 }
2817 }
2818
2819 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
2820
2821 String sql = query.toString();
2822
2823 Session session = null;
2824
2825 try {
2826 session = openSession();
2827
2828 Query q = session.createQuery(sql);
2829
2830 QueryPos qPos = QueryPos.getInstance(q);
2831
2832 if (uuid != null) {
2833 qPos.add(uuid);
2834 }
2835
2836 qPos.add(groupId);
2837
2838 count = (Long)q.uniqueResult();
2839 }
2840 catch (Exception e) {
2841 throw processException(e);
2842 }
2843 finally {
2844 if (count == null) {
2845 count = Long.valueOf(0);
2846 }
2847
2848 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
2849 finderArgs, count);
2850
2851 closeSession(session);
2852 }
2853 }
2854
2855 return count.intValue();
2856 }
2857
2858
2866 public int countByUuid_C(String uuid, long companyId)
2867 throws SystemException {
2868 Object[] finderArgs = new Object[] { uuid, companyId };
2869
2870 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_C,
2871 finderArgs, this);
2872
2873 if (count == null) {
2874 StringBundler query = new StringBundler(3);
2875
2876 query.append(_SQL_COUNT_JOURNALFEED_WHERE);
2877
2878 if (uuid == null) {
2879 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
2880 }
2881 else {
2882 if (uuid.equals(StringPool.BLANK)) {
2883 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
2884 }
2885 else {
2886 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
2887 }
2888 }
2889
2890 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
2891
2892 String sql = query.toString();
2893
2894 Session session = null;
2895
2896 try {
2897 session = openSession();
2898
2899 Query q = session.createQuery(sql);
2900
2901 QueryPos qPos = QueryPos.getInstance(q);
2902
2903 if (uuid != null) {
2904 qPos.add(uuid);
2905 }
2906
2907 qPos.add(companyId);
2908
2909 count = (Long)q.uniqueResult();
2910 }
2911 catch (Exception e) {
2912 throw processException(e);
2913 }
2914 finally {
2915 if (count == null) {
2916 count = Long.valueOf(0);
2917 }
2918
2919 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_C,
2920 finderArgs, count);
2921
2922 closeSession(session);
2923 }
2924 }
2925
2926 return count.intValue();
2927 }
2928
2929
2936 public int countByGroupId(long groupId) throws SystemException {
2937 Object[] finderArgs = new Object[] { groupId };
2938
2939 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2940 finderArgs, this);
2941
2942 if (count == null) {
2943 StringBundler query = new StringBundler(2);
2944
2945 query.append(_SQL_COUNT_JOURNALFEED_WHERE);
2946
2947 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2948
2949 String sql = query.toString();
2950
2951 Session session = null;
2952
2953 try {
2954 session = openSession();
2955
2956 Query q = session.createQuery(sql);
2957
2958 QueryPos qPos = QueryPos.getInstance(q);
2959
2960 qPos.add(groupId);
2961
2962 count = (Long)q.uniqueResult();
2963 }
2964 catch (Exception e) {
2965 throw processException(e);
2966 }
2967 finally {
2968 if (count == null) {
2969 count = Long.valueOf(0);
2970 }
2971
2972 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2973 finderArgs, count);
2974
2975 closeSession(session);
2976 }
2977 }
2978
2979 return count.intValue();
2980 }
2981
2982
2989 public int filterCountByGroupId(long groupId) throws SystemException {
2990 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2991 return countByGroupId(groupId);
2992 }
2993
2994 StringBundler query = new StringBundler(2);
2995
2996 query.append(_FILTER_SQL_COUNT_JOURNALFEED_WHERE);
2997
2998 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2999
3000 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3001 JournalFeed.class.getName(),
3002 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3003
3004 Session session = null;
3005
3006 try {
3007 session = openSession();
3008
3009 SQLQuery q = session.createSQLQuery(sql);
3010
3011 q.addScalar(COUNT_COLUMN_NAME,
3012 com.liferay.portal.kernel.dao.orm.Type.LONG);
3013
3014 QueryPos qPos = QueryPos.getInstance(q);
3015
3016 qPos.add(groupId);
3017
3018 Long count = (Long)q.uniqueResult();
3019
3020 return count.intValue();
3021 }
3022 catch (Exception e) {
3023 throw processException(e);
3024 }
3025 finally {
3026 closeSession(session);
3027 }
3028 }
3029
3030
3038 public int countByG_F(long groupId, String feedId)
3039 throws SystemException {
3040 Object[] finderArgs = new Object[] { groupId, feedId };
3041
3042 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F,
3043 finderArgs, this);
3044
3045 if (count == null) {
3046 StringBundler query = new StringBundler(3);
3047
3048 query.append(_SQL_COUNT_JOURNALFEED_WHERE);
3049
3050 query.append(_FINDER_COLUMN_G_F_GROUPID_2);
3051
3052 if (feedId == null) {
3053 query.append(_FINDER_COLUMN_G_F_FEEDID_1);
3054 }
3055 else {
3056 if (feedId.equals(StringPool.BLANK)) {
3057 query.append(_FINDER_COLUMN_G_F_FEEDID_3);
3058 }
3059 else {
3060 query.append(_FINDER_COLUMN_G_F_FEEDID_2);
3061 }
3062 }
3063
3064 String sql = query.toString();
3065
3066 Session session = null;
3067
3068 try {
3069 session = openSession();
3070
3071 Query q = session.createQuery(sql);
3072
3073 QueryPos qPos = QueryPos.getInstance(q);
3074
3075 qPos.add(groupId);
3076
3077 if (feedId != null) {
3078 qPos.add(feedId);
3079 }
3080
3081 count = (Long)q.uniqueResult();
3082 }
3083 catch (Exception e) {
3084 throw processException(e);
3085 }
3086 finally {
3087 if (count == null) {
3088 count = Long.valueOf(0);
3089 }
3090
3091 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F, finderArgs,
3092 count);
3093
3094 closeSession(session);
3095 }
3096 }
3097
3098 return count.intValue();
3099 }
3100
3101
3107 public int countAll() throws SystemException {
3108 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3109 FINDER_ARGS_EMPTY, this);
3110
3111 if (count == null) {
3112 Session session = null;
3113
3114 try {
3115 session = openSession();
3116
3117 Query q = session.createQuery(_SQL_COUNT_JOURNALFEED);
3118
3119 count = (Long)q.uniqueResult();
3120 }
3121 catch (Exception e) {
3122 throw processException(e);
3123 }
3124 finally {
3125 if (count == null) {
3126 count = Long.valueOf(0);
3127 }
3128
3129 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3130 FINDER_ARGS_EMPTY, count);
3131
3132 closeSession(session);
3133 }
3134 }
3135
3136 return count.intValue();
3137 }
3138
3139
3142 public void afterPropertiesSet() {
3143 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3144 com.liferay.portal.util.PropsUtil.get(
3145 "value.object.listener.com.liferay.portlet.journal.model.JournalFeed")));
3146
3147 if (listenerClassNames.length > 0) {
3148 try {
3149 List<ModelListener<JournalFeed>> listenersList = new ArrayList<ModelListener<JournalFeed>>();
3150
3151 for (String listenerClassName : listenerClassNames) {
3152 listenersList.add((ModelListener<JournalFeed>)InstanceFactory.newInstance(
3153 listenerClassName));
3154 }
3155
3156 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3157 }
3158 catch (Exception e) {
3159 _log.error(e);
3160 }
3161 }
3162 }
3163
3164 public void destroy() {
3165 EntityCacheUtil.removeCache(JournalFeedImpl.class.getName());
3166 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3167 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3168 }
3169
3170 @BeanReference(type = JournalArticlePersistence.class)
3171 protected JournalArticlePersistence journalArticlePersistence;
3172 @BeanReference(type = JournalArticleImagePersistence.class)
3173 protected JournalArticleImagePersistence journalArticleImagePersistence;
3174 @BeanReference(type = JournalArticleResourcePersistence.class)
3175 protected JournalArticleResourcePersistence journalArticleResourcePersistence;
3176 @BeanReference(type = JournalContentSearchPersistence.class)
3177 protected JournalContentSearchPersistence journalContentSearchPersistence;
3178 @BeanReference(type = JournalFeedPersistence.class)
3179 protected JournalFeedPersistence journalFeedPersistence;
3180 @BeanReference(type = JournalFolderPersistence.class)
3181 protected JournalFolderPersistence journalFolderPersistence;
3182 @BeanReference(type = JournalStructurePersistence.class)
3183 protected JournalStructurePersistence journalStructurePersistence;
3184 @BeanReference(type = JournalTemplatePersistence.class)
3185 protected JournalTemplatePersistence journalTemplatePersistence;
3186 @BeanReference(type = UserPersistence.class)
3187 protected UserPersistence userPersistence;
3188 @BeanReference(type = ExpandoValuePersistence.class)
3189 protected ExpandoValuePersistence expandoValuePersistence;
3190 private static final String _SQL_SELECT_JOURNALFEED = "SELECT journalFeed FROM JournalFeed journalFeed";
3191 private static final String _SQL_SELECT_JOURNALFEED_WHERE = "SELECT journalFeed FROM JournalFeed journalFeed WHERE ";
3192 private static final String _SQL_COUNT_JOURNALFEED = "SELECT COUNT(journalFeed) FROM JournalFeed journalFeed";
3193 private static final String _SQL_COUNT_JOURNALFEED_WHERE = "SELECT COUNT(journalFeed) FROM JournalFeed journalFeed WHERE ";
3194 private static final String _FINDER_COLUMN_UUID_UUID_1 = "journalFeed.uuid IS NULL";
3195 private static final String _FINDER_COLUMN_UUID_UUID_2 = "journalFeed.uuid = ?";
3196 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(journalFeed.uuid IS NULL OR journalFeed.uuid = ?)";
3197 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "journalFeed.uuid IS NULL AND ";
3198 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "journalFeed.uuid = ? AND ";
3199 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(journalFeed.uuid IS NULL OR journalFeed.uuid = ?) AND ";
3200 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "journalFeed.groupId = ?";
3201 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "journalFeed.uuid IS NULL AND ";
3202 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "journalFeed.uuid = ? AND ";
3203 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(journalFeed.uuid IS NULL OR journalFeed.uuid = ?) AND ";
3204 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "journalFeed.companyId = ?";
3205 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "journalFeed.groupId = ?";
3206 private static final String _FINDER_COLUMN_G_F_GROUPID_2 = "journalFeed.groupId = ? AND ";
3207 private static final String _FINDER_COLUMN_G_F_FEEDID_1 = "journalFeed.feedId IS NULL";
3208 private static final String _FINDER_COLUMN_G_F_FEEDID_2 = "journalFeed.feedId = ?";
3209 private static final String _FINDER_COLUMN_G_F_FEEDID_3 = "(journalFeed.feedId IS NULL OR journalFeed.feedId = ?)";
3210 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "journalFeed.id_";
3211 private static final String _FILTER_SQL_SELECT_JOURNALFEED_WHERE = "SELECT DISTINCT {journalFeed.*} FROM JournalFeed journalFeed WHERE ";
3212 private static final String _FILTER_SQL_SELECT_JOURNALFEED_NO_INLINE_DISTINCT_WHERE_1 =
3213 "SELECT {JournalFeed.*} FROM (SELECT DISTINCT journalFeed.id_ FROM JournalFeed journalFeed WHERE ";
3214 private static final String _FILTER_SQL_SELECT_JOURNALFEED_NO_INLINE_DISTINCT_WHERE_2 =
3215 ") TEMP_TABLE INNER JOIN JournalFeed ON TEMP_TABLE.id_ = JournalFeed.id_";
3216 private static final String _FILTER_SQL_COUNT_JOURNALFEED_WHERE = "SELECT COUNT(DISTINCT journalFeed.id_) AS COUNT_VALUE FROM JournalFeed journalFeed WHERE ";
3217 private static final String _FILTER_ENTITY_ALIAS = "journalFeed";
3218 private static final String _FILTER_ENTITY_TABLE = "JournalFeed";
3219 private static final String _ORDER_BY_ENTITY_ALIAS = "journalFeed.";
3220 private static final String _ORDER_BY_ENTITY_TABLE = "JournalFeed.";
3221 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalFeed exists with the primary key ";
3222 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalFeed exists with the key {";
3223 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3224 private static Log _log = LogFactoryUtil.getLog(JournalFeedPersistenceImpl.class);
3225 private static JournalFeed _nullJournalFeed = new JournalFeedImpl() {
3226 @Override
3227 public Object clone() {
3228 return this;
3229 }
3230
3231 @Override
3232 public CacheModel<JournalFeed> toCacheModel() {
3233 return _nullJournalFeedCacheModel;
3234 }
3235 };
3236
3237 private static CacheModel<JournalFeed> _nullJournalFeedCacheModel = new CacheModel<JournalFeed>() {
3238 public JournalFeed toEntityModel() {
3239 return _nullJournalFeed;
3240 }
3241 };
3242 }