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