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