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