001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.journal.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.annotation.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.SQLQuery;
027    import com.liferay.portal.kernel.dao.orm.Session;
028    import com.liferay.portal.kernel.exception.SystemException;
029    import com.liferay.portal.kernel.log.Log;
030    import com.liferay.portal.kernel.log.LogFactoryUtil;
031    import com.liferay.portal.kernel.util.GetterUtil;
032    import com.liferay.portal.kernel.util.InstanceFactory;
033    import com.liferay.portal.kernel.util.OrderByComparator;
034    import com.liferay.portal.kernel.util.StringBundler;
035    import com.liferay.portal.kernel.util.StringPool;
036    import com.liferay.portal.kernel.util.StringUtil;
037    import com.liferay.portal.kernel.util.Validator;
038    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
039    import com.liferay.portal.model.ModelListener;
040    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
041    import com.liferay.portal.service.persistence.BatchSessionUtil;
042    import com.liferay.portal.service.persistence.ResourcePersistence;
043    import com.liferay.portal.service.persistence.UserPersistence;
044    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
045    
046    import com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence;
047    import com.liferay.portlet.journal.NoSuchFeedException;
048    import com.liferay.portlet.journal.model.JournalFeed;
049    import com.liferay.portlet.journal.model.impl.JournalFeedImpl;
050    import com.liferay.portlet.journal.model.impl.JournalFeedModelImpl;
051    
052    import java.io.Serializable;
053    
054    import java.util.ArrayList;
055    import java.util.Collections;
056    import java.util.List;
057    
058    /**
059     * The persistence implementation for the journal feed service.
060     *
061     * <p>
062     * Never modify or reference this class directly. Always use {@link JournalFeedUtil} to access the journal feed persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
063     * </p>
064     *
065     * <p>
066     * Caching information and settings can be found in <code>portal.properties</code>
067     * </p>
068     *
069     * @author Brian Wing Shun Chan
070     * @see JournalFeedPersistence
071     * @see JournalFeedUtil
072     * @generated
073     */
074    public class JournalFeedPersistenceImpl extends BasePersistenceImpl<JournalFeed>
075            implements JournalFeedPersistence {
076            public static final String FINDER_CLASS_NAME_ENTITY = JournalFeedImpl.class.getName();
077            public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
078                    ".List";
079            public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
080                            JournalFeedModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
081                            "findByUuid",
082                            new String[] {
083                                    String.class.getName(),
084                                    
085                            "java.lang.Integer", "java.lang.Integer",
086                                    "com.liferay.portal.kernel.util.OrderByComparator"
087                            });
088            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
089                            JournalFeedModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
090                            "countByUuid", new String[] { String.class.getName() });
091            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
092                            JournalFeedModelImpl.FINDER_CACHE_ENABLED,
093                            FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
094                            new String[] { String.class.getName(), Long.class.getName() });
095            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
096                            JournalFeedModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
097                            "countByUUID_G",
098                            new String[] { String.class.getName(), Long.class.getName() });
099            public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
100                            JournalFeedModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
101                            "findByGroupId",
102                            new String[] {
103                                    Long.class.getName(),
104                                    
105                            "java.lang.Integer", "java.lang.Integer",
106                                    "com.liferay.portal.kernel.util.OrderByComparator"
107                            });
108            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
109                            JournalFeedModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
110                            "countByGroupId", new String[] { Long.class.getName() });
111            public static final FinderPath FINDER_PATH_FETCH_BY_G_F = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
112                            JournalFeedModelImpl.FINDER_CACHE_ENABLED,
113                            FINDER_CLASS_NAME_ENTITY, "fetchByG_F",
114                            new String[] { Long.class.getName(), String.class.getName() });
115            public static final FinderPath FINDER_PATH_COUNT_BY_G_F = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
116                            JournalFeedModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
117                            "countByG_F",
118                            new String[] { Long.class.getName(), String.class.getName() });
119            public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
120                            JournalFeedModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
121                            "findAll", new String[0]);
122            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
123                            JournalFeedModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
124                            "countAll", new String[0]);
125    
126            /**
127             * Caches the journal feed in the entity cache if it is enabled.
128             *
129             * @param journalFeed the journal feed to cache
130             */
131            public void cacheResult(JournalFeed journalFeed) {
132                    EntityCacheUtil.putResult(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
133                            JournalFeedImpl.class, journalFeed.getPrimaryKey(), journalFeed);
134    
135                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
136                            new Object[] {
137                                    journalFeed.getUuid(), new Long(journalFeed.getGroupId())
138                            }, journalFeed);
139    
140                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F,
141                            new Object[] {
142                                    new Long(journalFeed.getGroupId()),
143                                    
144                            journalFeed.getFeedId()
145                            }, journalFeed);
146            }
147    
148            /**
149             * Caches the journal feeds in the entity cache if it is enabled.
150             *
151             * @param journalFeeds the journal feeds to cache
152             */
153            public void cacheResult(List<JournalFeed> journalFeeds) {
154                    for (JournalFeed journalFeed : journalFeeds) {
155                            if (EntityCacheUtil.getResult(
156                                                    JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
157                                                    JournalFeedImpl.class, journalFeed.getPrimaryKey(), this) == null) {
158                                    cacheResult(journalFeed);
159                            }
160                    }
161            }
162    
163            /**
164             * Clears the cache for all journal feeds.
165             *
166             * <p>
167             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
168             * </p>
169             */
170            public void clearCache() {
171                    CacheRegistryUtil.clear(JournalFeedImpl.class.getName());
172                    EntityCacheUtil.clearCache(JournalFeedImpl.class.getName());
173                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
174                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
175            }
176    
177            /**
178             * Clears the cache for the journal feed.
179             *
180             * <p>
181             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
182             * </p>
183             */
184            public void clearCache(JournalFeed journalFeed) {
185                    EntityCacheUtil.removeResult(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
186                            JournalFeedImpl.class, journalFeed.getPrimaryKey());
187    
188                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
189                            new Object[] {
190                                    journalFeed.getUuid(), new Long(journalFeed.getGroupId())
191                            });
192    
193                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F,
194                            new Object[] {
195                                    new Long(journalFeed.getGroupId()),
196                                    
197                            journalFeed.getFeedId()
198                            });
199            }
200    
201            /**
202             * Creates a new journal feed with the primary key. Does not add the journal feed to the database.
203             *
204             * @param id the primary key for the new journal feed
205             * @return the new journal feed
206             */
207            public JournalFeed create(long id) {
208                    JournalFeed journalFeed = new JournalFeedImpl();
209    
210                    journalFeed.setNew(true);
211                    journalFeed.setPrimaryKey(id);
212    
213                    String uuid = PortalUUIDUtil.generate();
214    
215                    journalFeed.setUuid(uuid);
216    
217                    return journalFeed;
218            }
219    
220            /**
221             * Removes the journal feed with the primary key from the database. Also notifies the appropriate model listeners.
222             *
223             * @param primaryKey the primary key of the journal feed to remove
224             * @return the journal feed that was removed
225             * @throws com.liferay.portal.NoSuchModelException if a journal feed with the primary key could not be found
226             * @throws SystemException if a system exception occurred
227             */
228            public JournalFeed remove(Serializable primaryKey)
229                    throws NoSuchModelException, SystemException {
230                    return remove(((Long)primaryKey).longValue());
231            }
232    
233            /**
234             * Removes the journal feed with the primary key from the database. Also notifies the appropriate model listeners.
235             *
236             * @param id the primary key of the journal feed to remove
237             * @return the journal feed that was removed
238             * @throws com.liferay.portlet.journal.NoSuchFeedException if a journal feed with the primary key could not be found
239             * @throws SystemException if a system exception occurred
240             */
241            public JournalFeed remove(long id)
242                    throws NoSuchFeedException, SystemException {
243                    Session session = null;
244    
245                    try {
246                            session = openSession();
247    
248                            JournalFeed journalFeed = (JournalFeed)session.get(JournalFeedImpl.class,
249                                            new Long(id));
250    
251                            if (journalFeed == null) {
252                                    if (_log.isWarnEnabled()) {
253                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + id);
254                                    }
255    
256                                    throw new NoSuchFeedException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
257                                            id);
258                            }
259    
260                            return remove(journalFeed);
261                    }
262                    catch (NoSuchFeedException nsee) {
263                            throw nsee;
264                    }
265                    catch (Exception e) {
266                            throw processException(e);
267                    }
268                    finally {
269                            closeSession(session);
270                    }
271            }
272    
273            protected JournalFeed removeImpl(JournalFeed journalFeed)
274                    throws SystemException {
275                    journalFeed = toUnwrappedModel(journalFeed);
276    
277                    Session session = null;
278    
279                    try {
280                            session = openSession();
281    
282                            if (journalFeed.isCachedModel() || BatchSessionUtil.isEnabled()) {
283                                    Object staleObject = session.get(JournalFeedImpl.class,
284                                                    journalFeed.getPrimaryKeyObj());
285    
286                                    if (staleObject != null) {
287                                            session.evict(staleObject);
288                                    }
289                            }
290    
291                            session.delete(journalFeed);
292    
293                            session.flush();
294                    }
295                    catch (Exception e) {
296                            throw processException(e);
297                    }
298                    finally {
299                            closeSession(session);
300                    }
301    
302                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
303    
304                    JournalFeedModelImpl journalFeedModelImpl = (JournalFeedModelImpl)journalFeed;
305    
306                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
307                            new Object[] {
308                                    journalFeedModelImpl.getOriginalUuid(),
309                                    new Long(journalFeedModelImpl.getOriginalGroupId())
310                            });
311    
312                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F,
313                            new Object[] {
314                                    new Long(journalFeedModelImpl.getOriginalGroupId()),
315                                    
316                            journalFeedModelImpl.getOriginalFeedId()
317                            });
318    
319                    EntityCacheUtil.removeResult(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
320                            JournalFeedImpl.class, journalFeed.getPrimaryKey());
321    
322                    return journalFeed;
323            }
324    
325            public JournalFeed updateImpl(
326                    com.liferay.portlet.journal.model.JournalFeed journalFeed, boolean merge)
327                    throws SystemException {
328                    journalFeed = toUnwrappedModel(journalFeed);
329    
330                    boolean isNew = journalFeed.isNew();
331    
332                    JournalFeedModelImpl journalFeedModelImpl = (JournalFeedModelImpl)journalFeed;
333    
334                    if (Validator.isNull(journalFeed.getUuid())) {
335                            String uuid = PortalUUIDUtil.generate();
336    
337                            journalFeed.setUuid(uuid);
338                    }
339    
340                    Session session = null;
341    
342                    try {
343                            session = openSession();
344    
345                            BatchSessionUtil.update(session, journalFeed, merge);
346    
347                            journalFeed.setNew(false);
348                    }
349                    catch (Exception e) {
350                            throw processException(e);
351                    }
352                    finally {
353                            closeSession(session);
354                    }
355    
356                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
357    
358                    EntityCacheUtil.putResult(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
359                            JournalFeedImpl.class, journalFeed.getPrimaryKey(), journalFeed);
360    
361                    if (!isNew &&
362                                    (!Validator.equals(journalFeed.getUuid(),
363                                            journalFeedModelImpl.getOriginalUuid()) ||
364                                    (journalFeed.getGroupId() != journalFeedModelImpl.getOriginalGroupId()))) {
365                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
366                                    new Object[] {
367                                            journalFeedModelImpl.getOriginalUuid(),
368                                            new Long(journalFeedModelImpl.getOriginalGroupId())
369                                    });
370                    }
371    
372                    if (isNew ||
373                                    (!Validator.equals(journalFeed.getUuid(),
374                                            journalFeedModelImpl.getOriginalUuid()) ||
375                                    (journalFeed.getGroupId() != journalFeedModelImpl.getOriginalGroupId()))) {
376                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
377                                    new Object[] {
378                                            journalFeed.getUuid(), new Long(journalFeed.getGroupId())
379                                    }, journalFeed);
380                    }
381    
382                    if (!isNew &&
383                                    ((journalFeed.getGroupId() != journalFeedModelImpl.getOriginalGroupId()) ||
384                                    !Validator.equals(journalFeed.getFeedId(),
385                                            journalFeedModelImpl.getOriginalFeedId()))) {
386                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F,
387                                    new Object[] {
388                                            new Long(journalFeedModelImpl.getOriginalGroupId()),
389                                            
390                                    journalFeedModelImpl.getOriginalFeedId()
391                                    });
392                    }
393    
394                    if (isNew ||
395                                    ((journalFeed.getGroupId() != journalFeedModelImpl.getOriginalGroupId()) ||
396                                    !Validator.equals(journalFeed.getFeedId(),
397                                            journalFeedModelImpl.getOriginalFeedId()))) {
398                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F,
399                                    new Object[] {
400                                            new Long(journalFeed.getGroupId()),
401                                            
402                                    journalFeed.getFeedId()
403                                    }, journalFeed);
404                    }
405    
406                    return journalFeed;
407            }
408    
409            protected JournalFeed toUnwrappedModel(JournalFeed journalFeed) {
410                    if (journalFeed instanceof JournalFeedImpl) {
411                            return journalFeed;
412                    }
413    
414                    JournalFeedImpl journalFeedImpl = new JournalFeedImpl();
415    
416                    journalFeedImpl.setNew(journalFeed.isNew());
417                    journalFeedImpl.setPrimaryKey(journalFeed.getPrimaryKey());
418    
419                    journalFeedImpl.setUuid(journalFeed.getUuid());
420                    journalFeedImpl.setId(journalFeed.getId());
421                    journalFeedImpl.setGroupId(journalFeed.getGroupId());
422                    journalFeedImpl.setCompanyId(journalFeed.getCompanyId());
423                    journalFeedImpl.setUserId(journalFeed.getUserId());
424                    journalFeedImpl.setUserName(journalFeed.getUserName());
425                    journalFeedImpl.setCreateDate(journalFeed.getCreateDate());
426                    journalFeedImpl.setModifiedDate(journalFeed.getModifiedDate());
427                    journalFeedImpl.setFeedId(journalFeed.getFeedId());
428                    journalFeedImpl.setName(journalFeed.getName());
429                    journalFeedImpl.setDescription(journalFeed.getDescription());
430                    journalFeedImpl.setType(journalFeed.getType());
431                    journalFeedImpl.setStructureId(journalFeed.getStructureId());
432                    journalFeedImpl.setTemplateId(journalFeed.getTemplateId());
433                    journalFeedImpl.setRendererTemplateId(journalFeed.getRendererTemplateId());
434                    journalFeedImpl.setDelta(journalFeed.getDelta());
435                    journalFeedImpl.setOrderByCol(journalFeed.getOrderByCol());
436                    journalFeedImpl.setOrderByType(journalFeed.getOrderByType());
437                    journalFeedImpl.setTargetLayoutFriendlyUrl(journalFeed.getTargetLayoutFriendlyUrl());
438                    journalFeedImpl.setTargetPortletId(journalFeed.getTargetPortletId());
439                    journalFeedImpl.setContentField(journalFeed.getContentField());
440                    journalFeedImpl.setFeedType(journalFeed.getFeedType());
441                    journalFeedImpl.setFeedVersion(journalFeed.getFeedVersion());
442    
443                    return journalFeedImpl;
444            }
445    
446            /**
447             * Finds the journal feed with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
448             *
449             * @param primaryKey the primary key of the journal feed to find
450             * @return the journal feed
451             * @throws com.liferay.portal.NoSuchModelException if a journal feed with the primary key could not be found
452             * @throws SystemException if a system exception occurred
453             */
454            public JournalFeed findByPrimaryKey(Serializable primaryKey)
455                    throws NoSuchModelException, SystemException {
456                    return findByPrimaryKey(((Long)primaryKey).longValue());
457            }
458    
459            /**
460             * Finds the journal feed with the primary key or throws a {@link com.liferay.portlet.journal.NoSuchFeedException} if it could not be found.
461             *
462             * @param id the primary key of the journal feed to find
463             * @return the journal feed
464             * @throws com.liferay.portlet.journal.NoSuchFeedException if a journal feed with the primary key could not be found
465             * @throws SystemException if a system exception occurred
466             */
467            public JournalFeed findByPrimaryKey(long id)
468                    throws NoSuchFeedException, SystemException {
469                    JournalFeed journalFeed = fetchByPrimaryKey(id);
470    
471                    if (journalFeed == null) {
472                            if (_log.isWarnEnabled()) {
473                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + id);
474                            }
475    
476                            throw new NoSuchFeedException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
477                                    id);
478                    }
479    
480                    return journalFeed;
481            }
482    
483            /**
484             * Finds the journal feed with the primary key or returns <code>null</code> if it could not be found.
485             *
486             * @param primaryKey the primary key of the journal feed to find
487             * @return the journal feed, or <code>null</code> if a journal feed with the primary key could not be found
488             * @throws SystemException if a system exception occurred
489             */
490            public JournalFeed fetchByPrimaryKey(Serializable primaryKey)
491                    throws SystemException {
492                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
493            }
494    
495            /**
496             * Finds the journal feed with the primary key or returns <code>null</code> if it could not be found.
497             *
498             * @param id the primary key of the journal feed to find
499             * @return the journal feed, or <code>null</code> if a journal feed with the primary key could not be found
500             * @throws SystemException if a system exception occurred
501             */
502            public JournalFeed fetchByPrimaryKey(long id) throws SystemException {
503                    JournalFeed journalFeed = (JournalFeed)EntityCacheUtil.getResult(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
504                                    JournalFeedImpl.class, id, this);
505    
506                    if (journalFeed == null) {
507                            Session session = null;
508    
509                            try {
510                                    session = openSession();
511    
512                                    journalFeed = (JournalFeed)session.get(JournalFeedImpl.class,
513                                                    new Long(id));
514                            }
515                            catch (Exception e) {
516                                    throw processException(e);
517                            }
518                            finally {
519                                    if (journalFeed != null) {
520                                            cacheResult(journalFeed);
521                                    }
522    
523                                    closeSession(session);
524                            }
525                    }
526    
527                    return journalFeed;
528            }
529    
530            /**
531             * Finds all the journal feeds where uuid = &#63;.
532             *
533             * @param uuid the uuid to search with
534             * @return the matching journal feeds
535             * @throws SystemException if a system exception occurred
536             */
537            public List<JournalFeed> findByUuid(String uuid) throws SystemException {
538                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
539            }
540    
541            /**
542             * Finds a range of all the journal feeds where uuid = &#63;.
543             *
544             * <p>
545             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
546             * </p>
547             *
548             * @param uuid the uuid to search with
549             * @param start the lower bound of the range of journal feeds to return
550             * @param end the upper bound of the range of journal feeds to return (not inclusive)
551             * @return the range of matching journal feeds
552             * @throws SystemException if a system exception occurred
553             */
554            public List<JournalFeed> findByUuid(String uuid, int start, int end)
555                    throws SystemException {
556                    return findByUuid(uuid, start, end, null);
557            }
558    
559            /**
560             * Finds an ordered range of all the journal feeds where uuid = &#63;.
561             *
562             * <p>
563             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
564             * </p>
565             *
566             * @param uuid the uuid to search with
567             * @param start the lower bound of the range of journal feeds to return
568             * @param end the upper bound of the range of journal feeds to return (not inclusive)
569             * @param orderByComparator the comparator to order the results by
570             * @return the ordered range of matching journal feeds
571             * @throws SystemException if a system exception occurred
572             */
573            public List<JournalFeed> findByUuid(String uuid, int start, int end,
574                    OrderByComparator orderByComparator) throws SystemException {
575                    Object[] finderArgs = new Object[] {
576                                    uuid,
577                                    
578                                    String.valueOf(start), String.valueOf(end),
579                                    String.valueOf(orderByComparator)
580                            };
581    
582                    List<JournalFeed> list = (List<JournalFeed>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
583                                    finderArgs, this);
584    
585                    if (list == null) {
586                            Session session = null;
587    
588                            try {
589                                    session = openSession();
590    
591                                    StringBundler query = null;
592    
593                                    if (orderByComparator != null) {
594                                            query = new StringBundler(3 +
595                                                            (orderByComparator.getOrderByFields().length * 3));
596                                    }
597                                    else {
598                                            query = new StringBundler(3);
599                                    }
600    
601                                    query.append(_SQL_SELECT_JOURNALFEED_WHERE);
602    
603                                    if (uuid == null) {
604                                            query.append(_FINDER_COLUMN_UUID_UUID_1);
605                                    }
606                                    else {
607                                            if (uuid.equals(StringPool.BLANK)) {
608                                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
609                                            }
610                                            else {
611                                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
612                                            }
613                                    }
614    
615                                    if (orderByComparator != null) {
616                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
617                                                    orderByComparator);
618                                    }
619    
620                                    else {
621                                            query.append(JournalFeedModelImpl.ORDER_BY_JPQL);
622                                    }
623    
624                                    String sql = query.toString();
625    
626                                    Query q = session.createQuery(sql);
627    
628                                    QueryPos qPos = QueryPos.getInstance(q);
629    
630                                    if (uuid != null) {
631                                            qPos.add(uuid);
632                                    }
633    
634                                    list = (List<JournalFeed>)QueryUtil.list(q, getDialect(),
635                                                    start, end);
636                            }
637                            catch (Exception e) {
638                                    throw processException(e);
639                            }
640                            finally {
641                                    if (list == null) {
642                                            list = new ArrayList<JournalFeed>();
643                                    }
644    
645                                    cacheResult(list);
646    
647                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
648                                            list);
649    
650                                    closeSession(session);
651                            }
652                    }
653    
654                    return list;
655            }
656    
657            /**
658             * Finds the first journal feed in the ordered set where uuid = &#63;.
659             *
660             * <p>
661             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
662             * </p>
663             *
664             * @param uuid the uuid to search with
665             * @param orderByComparator the comparator to order the set by
666             * @return the first matching journal feed
667             * @throws com.liferay.portlet.journal.NoSuchFeedException if a matching journal feed could not be found
668             * @throws SystemException if a system exception occurred
669             */
670            public JournalFeed findByUuid_First(String uuid,
671                    OrderByComparator orderByComparator)
672                    throws NoSuchFeedException, SystemException {
673                    List<JournalFeed> list = findByUuid(uuid, 0, 1, orderByComparator);
674    
675                    if (list.isEmpty()) {
676                            StringBundler msg = new StringBundler(4);
677    
678                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
679    
680                            msg.append("uuid=");
681                            msg.append(uuid);
682    
683                            msg.append(StringPool.CLOSE_CURLY_BRACE);
684    
685                            throw new NoSuchFeedException(msg.toString());
686                    }
687                    else {
688                            return list.get(0);
689                    }
690            }
691    
692            /**
693             * Finds the last journal feed in the ordered set where uuid = &#63;.
694             *
695             * <p>
696             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
697             * </p>
698             *
699             * @param uuid the uuid to search with
700             * @param orderByComparator the comparator to order the set by
701             * @return the last matching journal feed
702             * @throws com.liferay.portlet.journal.NoSuchFeedException if a matching journal feed could not be found
703             * @throws SystemException if a system exception occurred
704             */
705            public JournalFeed findByUuid_Last(String uuid,
706                    OrderByComparator orderByComparator)
707                    throws NoSuchFeedException, SystemException {
708                    int count = countByUuid(uuid);
709    
710                    List<JournalFeed> list = findByUuid(uuid, count - 1, count,
711                                    orderByComparator);
712    
713                    if (list.isEmpty()) {
714                            StringBundler msg = new StringBundler(4);
715    
716                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
717    
718                            msg.append("uuid=");
719                            msg.append(uuid);
720    
721                            msg.append(StringPool.CLOSE_CURLY_BRACE);
722    
723                            throw new NoSuchFeedException(msg.toString());
724                    }
725                    else {
726                            return list.get(0);
727                    }
728            }
729    
730            /**
731             * Finds the journal feeds before and after the current journal feed in the ordered set where uuid = &#63;.
732             *
733             * <p>
734             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
735             * </p>
736             *
737             * @param id the primary key of the current journal feed
738             * @param uuid the uuid to search with
739             * @param orderByComparator the comparator to order the set by
740             * @return the previous, current, and next journal feed
741             * @throws com.liferay.portlet.journal.NoSuchFeedException if a journal feed with the primary key could not be found
742             * @throws SystemException if a system exception occurred
743             */
744            public JournalFeed[] findByUuid_PrevAndNext(long id, String uuid,
745                    OrderByComparator orderByComparator)
746                    throws NoSuchFeedException, SystemException {
747                    JournalFeed journalFeed = findByPrimaryKey(id);
748    
749                    Session session = null;
750    
751                    try {
752                            session = openSession();
753    
754                            JournalFeed[] array = new JournalFeedImpl[3];
755    
756                            array[0] = getByUuid_PrevAndNext(session, journalFeed, uuid,
757                                            orderByComparator, true);
758    
759                            array[1] = journalFeed;
760    
761                            array[2] = getByUuid_PrevAndNext(session, journalFeed, uuid,
762                                            orderByComparator, false);
763    
764                            return array;
765                    }
766                    catch (Exception e) {
767                            throw processException(e);
768                    }
769                    finally {
770                            closeSession(session);
771                    }
772            }
773    
774            protected JournalFeed getByUuid_PrevAndNext(Session session,
775                    JournalFeed journalFeed, String uuid,
776                    OrderByComparator orderByComparator, boolean previous) {
777                    StringBundler query = null;
778    
779                    if (orderByComparator != null) {
780                            query = new StringBundler(6 +
781                                            (orderByComparator.getOrderByFields().length * 6));
782                    }
783                    else {
784                            query = new StringBundler(3);
785                    }
786    
787                    query.append(_SQL_SELECT_JOURNALFEED_WHERE);
788    
789                    if (uuid == null) {
790                            query.append(_FINDER_COLUMN_UUID_UUID_1);
791                    }
792                    else {
793                            if (uuid.equals(StringPool.BLANK)) {
794                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
795                            }
796                            else {
797                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
798                            }
799                    }
800    
801                    if (orderByComparator != null) {
802                            String[] orderByFields = orderByComparator.getOrderByFields();
803    
804                            if (orderByFields.length > 0) {
805                                    query.append(WHERE_AND);
806                            }
807    
808                            for (int i = 0; i < orderByFields.length; i++) {
809                                    query.append(_ORDER_BY_ENTITY_ALIAS);
810                                    query.append(orderByFields[i]);
811    
812                                    if ((i + 1) < orderByFields.length) {
813                                            if (orderByComparator.isAscending() ^ previous) {
814                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
815                                            }
816                                            else {
817                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
818                                            }
819                                    }
820                                    else {
821                                            if (orderByComparator.isAscending() ^ previous) {
822                                                    query.append(WHERE_GREATER_THAN);
823                                            }
824                                            else {
825                                                    query.append(WHERE_LESSER_THAN);
826                                            }
827                                    }
828                            }
829    
830                            query.append(ORDER_BY_CLAUSE);
831    
832                            for (int i = 0; i < orderByFields.length; i++) {
833                                    query.append(_ORDER_BY_ENTITY_ALIAS);
834                                    query.append(orderByFields[i]);
835    
836                                    if ((i + 1) < orderByFields.length) {
837                                            if (orderByComparator.isAscending() ^ previous) {
838                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
839                                            }
840                                            else {
841                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
842                                            }
843                                    }
844                                    else {
845                                            if (orderByComparator.isAscending() ^ previous) {
846                                                    query.append(ORDER_BY_ASC);
847                                            }
848                                            else {
849                                                    query.append(ORDER_BY_DESC);
850                                            }
851                                    }
852                            }
853                    }
854    
855                    else {
856                            query.append(JournalFeedModelImpl.ORDER_BY_JPQL);
857                    }
858    
859                    String sql = query.toString();
860    
861                    Query q = session.createQuery(sql);
862    
863                    q.setFirstResult(0);
864                    q.setMaxResults(2);
865    
866                    QueryPos qPos = QueryPos.getInstance(q);
867    
868                    if (uuid != null) {
869                            qPos.add(uuid);
870                    }
871    
872                    if (orderByComparator != null) {
873                            Object[] values = orderByComparator.getOrderByValues(journalFeed);
874    
875                            for (Object value : values) {
876                                    qPos.add(value);
877                            }
878                    }
879    
880                    List<JournalFeed> list = q.list();
881    
882                    if (list.size() == 2) {
883                            return list.get(1);
884                    }
885                    else {
886                            return null;
887                    }
888            }
889    
890            /**
891             * Finds the journal feed where uuid = &#63; and groupId = &#63; or throws a {@link com.liferay.portlet.journal.NoSuchFeedException} if it could not be found.
892             *
893             * @param uuid the uuid to search with
894             * @param groupId the group id to search with
895             * @return the matching journal feed
896             * @throws com.liferay.portlet.journal.NoSuchFeedException if a matching journal feed could not be found
897             * @throws SystemException if a system exception occurred
898             */
899            public JournalFeed findByUUID_G(String uuid, long groupId)
900                    throws NoSuchFeedException, SystemException {
901                    JournalFeed journalFeed = fetchByUUID_G(uuid, groupId);
902    
903                    if (journalFeed == null) {
904                            StringBundler msg = new StringBundler(6);
905    
906                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
907    
908                            msg.append("uuid=");
909                            msg.append(uuid);
910    
911                            msg.append(", groupId=");
912                            msg.append(groupId);
913    
914                            msg.append(StringPool.CLOSE_CURLY_BRACE);
915    
916                            if (_log.isWarnEnabled()) {
917                                    _log.warn(msg.toString());
918                            }
919    
920                            throw new NoSuchFeedException(msg.toString());
921                    }
922    
923                    return journalFeed;
924            }
925    
926            /**
927             * Finds the journal feed where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
928             *
929             * @param uuid the uuid to search with
930             * @param groupId the group id to search with
931             * @return the matching journal feed, or <code>null</code> if a matching journal feed could not be found
932             * @throws SystemException if a system exception occurred
933             */
934            public JournalFeed fetchByUUID_G(String uuid, long groupId)
935                    throws SystemException {
936                    return fetchByUUID_G(uuid, groupId, true);
937            }
938    
939            /**
940             * Finds the journal feed where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
941             *
942             * @param uuid the uuid to search with
943             * @param groupId the group id to search with
944             * @return the matching journal feed, or <code>null</code> if a matching journal feed could not be found
945             * @throws SystemException if a system exception occurred
946             */
947            public JournalFeed fetchByUUID_G(String uuid, long groupId,
948                    boolean retrieveFromCache) throws SystemException {
949                    Object[] finderArgs = new Object[] { uuid, groupId };
950    
951                    Object result = null;
952    
953                    if (retrieveFromCache) {
954                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
955                                            finderArgs, this);
956                    }
957    
958                    if (result == null) {
959                            Session session = null;
960    
961                            try {
962                                    session = openSession();
963    
964                                    StringBundler query = new StringBundler(4);
965    
966                                    query.append(_SQL_SELECT_JOURNALFEED_WHERE);
967    
968                                    if (uuid == null) {
969                                            query.append(_FINDER_COLUMN_UUID_G_UUID_1);
970                                    }
971                                    else {
972                                            if (uuid.equals(StringPool.BLANK)) {
973                                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
974                                            }
975                                            else {
976                                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
977                                            }
978                                    }
979    
980                                    query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
981    
982                                    query.append(JournalFeedModelImpl.ORDER_BY_JPQL);
983    
984                                    String sql = query.toString();
985    
986                                    Query q = session.createQuery(sql);
987    
988                                    QueryPos qPos = QueryPos.getInstance(q);
989    
990                                    if (uuid != null) {
991                                            qPos.add(uuid);
992                                    }
993    
994                                    qPos.add(groupId);
995    
996                                    List<JournalFeed> list = q.list();
997    
998                                    result = list;
999    
1000                                    JournalFeed journalFeed = null;
1001    
1002                                    if (list.isEmpty()) {
1003                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1004                                                    finderArgs, list);
1005                                    }
1006                                    else {
1007                                            journalFeed = list.get(0);
1008    
1009                                            cacheResult(journalFeed);
1010    
1011                                            if ((journalFeed.getUuid() == null) ||
1012                                                            !journalFeed.getUuid().equals(uuid) ||
1013                                                            (journalFeed.getGroupId() != groupId)) {
1014                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1015                                                            finderArgs, journalFeed);
1016                                            }
1017                                    }
1018    
1019                                    return journalFeed;
1020                            }
1021                            catch (Exception e) {
1022                                    throw processException(e);
1023                            }
1024                            finally {
1025                                    if (result == null) {
1026                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1027                                                    finderArgs, new ArrayList<JournalFeed>());
1028                                    }
1029    
1030                                    closeSession(session);
1031                            }
1032                    }
1033                    else {
1034                            if (result instanceof List<?>) {
1035                                    return null;
1036                            }
1037                            else {
1038                                    return (JournalFeed)result;
1039                            }
1040                    }
1041            }
1042    
1043            /**
1044             * Finds all the journal feeds where groupId = &#63;.
1045             *
1046             * @param groupId the group id to search with
1047             * @return the matching journal feeds
1048             * @throws SystemException if a system exception occurred
1049             */
1050            public List<JournalFeed> findByGroupId(long groupId)
1051                    throws SystemException {
1052                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1053            }
1054    
1055            /**
1056             * Finds a range of all the journal feeds where groupId = &#63;.
1057             *
1058             * <p>
1059             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1060             * </p>
1061             *
1062             * @param groupId the group id to search with
1063             * @param start the lower bound of the range of journal feeds to return
1064             * @param end the upper bound of the range of journal feeds to return (not inclusive)
1065             * @return the range of matching journal feeds
1066             * @throws SystemException if a system exception occurred
1067             */
1068            public List<JournalFeed> findByGroupId(long groupId, int start, int end)
1069                    throws SystemException {
1070                    return findByGroupId(groupId, start, end, null);
1071            }
1072    
1073            /**
1074             * Finds an ordered range of all the journal feeds where groupId = &#63;.
1075             *
1076             * <p>
1077             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1078             * </p>
1079             *
1080             * @param groupId the group id to search with
1081             * @param start the lower bound of the range of journal feeds to return
1082             * @param end the upper bound of the range of journal feeds to return (not inclusive)
1083             * @param orderByComparator the comparator to order the results by
1084             * @return the ordered range of matching journal feeds
1085             * @throws SystemException if a system exception occurred
1086             */
1087            public List<JournalFeed> findByGroupId(long groupId, int start, int end,
1088                    OrderByComparator orderByComparator) throws SystemException {
1089                    Object[] finderArgs = new Object[] {
1090                                    groupId,
1091                                    
1092                                    String.valueOf(start), String.valueOf(end),
1093                                    String.valueOf(orderByComparator)
1094                            };
1095    
1096                    List<JournalFeed> list = (List<JournalFeed>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
1097                                    finderArgs, this);
1098    
1099                    if (list == null) {
1100                            Session session = null;
1101    
1102                            try {
1103                                    session = openSession();
1104    
1105                                    StringBundler query = null;
1106    
1107                                    if (orderByComparator != null) {
1108                                            query = new StringBundler(3 +
1109                                                            (orderByComparator.getOrderByFields().length * 3));
1110                                    }
1111                                    else {
1112                                            query = new StringBundler(3);
1113                                    }
1114    
1115                                    query.append(_SQL_SELECT_JOURNALFEED_WHERE);
1116    
1117                                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1118    
1119                                    if (orderByComparator != null) {
1120                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1121                                                    orderByComparator);
1122                                    }
1123    
1124                                    else {
1125                                            query.append(JournalFeedModelImpl.ORDER_BY_JPQL);
1126                                    }
1127    
1128                                    String sql = query.toString();
1129    
1130                                    Query q = session.createQuery(sql);
1131    
1132                                    QueryPos qPos = QueryPos.getInstance(q);
1133    
1134                                    qPos.add(groupId);
1135    
1136                                    list = (List<JournalFeed>)QueryUtil.list(q, getDialect(),
1137                                                    start, end);
1138                            }
1139                            catch (Exception e) {
1140                                    throw processException(e);
1141                            }
1142                            finally {
1143                                    if (list == null) {
1144                                            list = new ArrayList<JournalFeed>();
1145                                    }
1146    
1147                                    cacheResult(list);
1148    
1149                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
1150                                            finderArgs, list);
1151    
1152                                    closeSession(session);
1153                            }
1154                    }
1155    
1156                    return list;
1157            }
1158    
1159            /**
1160             * Finds the first journal feed in the ordered set where groupId = &#63;.
1161             *
1162             * <p>
1163             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1164             * </p>
1165             *
1166             * @param groupId the group id to search with
1167             * @param orderByComparator the comparator to order the set by
1168             * @return the first matching journal feed
1169             * @throws com.liferay.portlet.journal.NoSuchFeedException if a matching journal feed could not be found
1170             * @throws SystemException if a system exception occurred
1171             */
1172            public JournalFeed findByGroupId_First(long groupId,
1173                    OrderByComparator orderByComparator)
1174                    throws NoSuchFeedException, SystemException {
1175                    List<JournalFeed> list = findByGroupId(groupId, 0, 1, orderByComparator);
1176    
1177                    if (list.isEmpty()) {
1178                            StringBundler msg = new StringBundler(4);
1179    
1180                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1181    
1182                            msg.append("groupId=");
1183                            msg.append(groupId);
1184    
1185                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1186    
1187                            throw new NoSuchFeedException(msg.toString());
1188                    }
1189                    else {
1190                            return list.get(0);
1191                    }
1192            }
1193    
1194            /**
1195             * Finds the last journal feed in the ordered set where groupId = &#63;.
1196             *
1197             * <p>
1198             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1199             * </p>
1200             *
1201             * @param groupId the group id to search with
1202             * @param orderByComparator the comparator to order the set by
1203             * @return the last matching journal feed
1204             * @throws com.liferay.portlet.journal.NoSuchFeedException if a matching journal feed could not be found
1205             * @throws SystemException if a system exception occurred
1206             */
1207            public JournalFeed findByGroupId_Last(long groupId,
1208                    OrderByComparator orderByComparator)
1209                    throws NoSuchFeedException, SystemException {
1210                    int count = countByGroupId(groupId);
1211    
1212                    List<JournalFeed> list = findByGroupId(groupId, count - 1, count,
1213                                    orderByComparator);
1214    
1215                    if (list.isEmpty()) {
1216                            StringBundler msg = new StringBundler(4);
1217    
1218                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1219    
1220                            msg.append("groupId=");
1221                            msg.append(groupId);
1222    
1223                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1224    
1225                            throw new NoSuchFeedException(msg.toString());
1226                    }
1227                    else {
1228                            return list.get(0);
1229                    }
1230            }
1231    
1232            /**
1233             * Finds the journal feeds before and after the current journal feed in the ordered set where groupId = &#63;.
1234             *
1235             * <p>
1236             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1237             * </p>
1238             *
1239             * @param id the primary key of the current journal feed
1240             * @param groupId the group id to search with
1241             * @param orderByComparator the comparator to order the set by
1242             * @return the previous, current, and next journal feed
1243             * @throws com.liferay.portlet.journal.NoSuchFeedException if a journal feed with the primary key could not be found
1244             * @throws SystemException if a system exception occurred
1245             */
1246            public JournalFeed[] findByGroupId_PrevAndNext(long id, long groupId,
1247                    OrderByComparator orderByComparator)
1248                    throws NoSuchFeedException, SystemException {
1249                    JournalFeed journalFeed = findByPrimaryKey(id);
1250    
1251                    Session session = null;
1252    
1253                    try {
1254                            session = openSession();
1255    
1256                            JournalFeed[] array = new JournalFeedImpl[3];
1257    
1258                            array[0] = getByGroupId_PrevAndNext(session, journalFeed, groupId,
1259                                            orderByComparator, true);
1260    
1261                            array[1] = journalFeed;
1262    
1263                            array[2] = getByGroupId_PrevAndNext(session, journalFeed, groupId,
1264                                            orderByComparator, false);
1265    
1266                            return array;
1267                    }
1268                    catch (Exception e) {
1269                            throw processException(e);
1270                    }
1271                    finally {
1272                            closeSession(session);
1273                    }
1274            }
1275    
1276            protected JournalFeed getByGroupId_PrevAndNext(Session session,
1277                    JournalFeed journalFeed, long groupId,
1278                    OrderByComparator orderByComparator, boolean previous) {
1279                    StringBundler query = null;
1280    
1281                    if (orderByComparator != null) {
1282                            query = new StringBundler(6 +
1283                                            (orderByComparator.getOrderByFields().length * 6));
1284                    }
1285                    else {
1286                            query = new StringBundler(3);
1287                    }
1288    
1289                    query.append(_SQL_SELECT_JOURNALFEED_WHERE);
1290    
1291                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1292    
1293                    if (orderByComparator != null) {
1294                            String[] orderByFields = orderByComparator.getOrderByFields();
1295    
1296                            if (orderByFields.length > 0) {
1297                                    query.append(WHERE_AND);
1298                            }
1299    
1300                            for (int i = 0; i < orderByFields.length; i++) {
1301                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1302                                    query.append(orderByFields[i]);
1303    
1304                                    if ((i + 1) < orderByFields.length) {
1305                                            if (orderByComparator.isAscending() ^ previous) {
1306                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1307                                            }
1308                                            else {
1309                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1310                                            }
1311                                    }
1312                                    else {
1313                                            if (orderByComparator.isAscending() ^ previous) {
1314                                                    query.append(WHERE_GREATER_THAN);
1315                                            }
1316                                            else {
1317                                                    query.append(WHERE_LESSER_THAN);
1318                                            }
1319                                    }
1320                            }
1321    
1322                            query.append(ORDER_BY_CLAUSE);
1323    
1324                            for (int i = 0; i < orderByFields.length; i++) {
1325                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1326                                    query.append(orderByFields[i]);
1327    
1328                                    if ((i + 1) < orderByFields.length) {
1329                                            if (orderByComparator.isAscending() ^ previous) {
1330                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1331                                            }
1332                                            else {
1333                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1334                                            }
1335                                    }
1336                                    else {
1337                                            if (orderByComparator.isAscending() ^ previous) {
1338                                                    query.append(ORDER_BY_ASC);
1339                                            }
1340                                            else {
1341                                                    query.append(ORDER_BY_DESC);
1342                                            }
1343                                    }
1344                            }
1345                    }
1346    
1347                    else {
1348                            query.append(JournalFeedModelImpl.ORDER_BY_JPQL);
1349                    }
1350    
1351                    String sql = query.toString();
1352    
1353                    Query q = session.createQuery(sql);
1354    
1355                    q.setFirstResult(0);
1356                    q.setMaxResults(2);
1357    
1358                    QueryPos qPos = QueryPos.getInstance(q);
1359    
1360                    qPos.add(groupId);
1361    
1362                    if (orderByComparator != null) {
1363                            Object[] values = orderByComparator.getOrderByValues(journalFeed);
1364    
1365                            for (Object value : values) {
1366                                    qPos.add(value);
1367                            }
1368                    }
1369    
1370                    List<JournalFeed> list = q.list();
1371    
1372                    if (list.size() == 2) {
1373                            return list.get(1);
1374                    }
1375                    else {
1376                            return null;
1377                    }
1378            }
1379    
1380            /**
1381             * Filters by the user's permissions and finds all the journal feeds where groupId = &#63;.
1382             *
1383             * @param groupId the group id to search with
1384             * @return the matching journal feeds that the user has permission to view
1385             * @throws SystemException if a system exception occurred
1386             */
1387            public List<JournalFeed> filterFindByGroupId(long groupId)
1388                    throws SystemException {
1389                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1390                            QueryUtil.ALL_POS, null);
1391            }
1392    
1393            /**
1394             * Filters by the user's permissions and finds a range of all the journal feeds where groupId = &#63;.
1395             *
1396             * <p>
1397             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1398             * </p>
1399             *
1400             * @param groupId the group id to search with
1401             * @param start the lower bound of the range of journal feeds to return
1402             * @param end the upper bound of the range of journal feeds to return (not inclusive)
1403             * @return the range of matching journal feeds that the user has permission to view
1404             * @throws SystemException if a system exception occurred
1405             */
1406            public List<JournalFeed> filterFindByGroupId(long groupId, int start,
1407                    int end) throws SystemException {
1408                    return filterFindByGroupId(groupId, start, end, null);
1409            }
1410    
1411            /**
1412             * Filters by the user's permissions and finds an ordered range of all the journal feeds where groupId = &#63;.
1413             *
1414             * <p>
1415             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1416             * </p>
1417             *
1418             * @param groupId the group id to search with
1419             * @param start the lower bound of the range of journal feeds to return
1420             * @param end the upper bound of the range of journal feeds to return (not inclusive)
1421             * @param orderByComparator the comparator to order the results by
1422             * @return the ordered range of matching journal feeds that the user has permission to view
1423             * @throws SystemException if a system exception occurred
1424             */
1425            public List<JournalFeed> filterFindByGroupId(long groupId, int start,
1426                    int end, OrderByComparator orderByComparator) throws SystemException {
1427                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1428                            return findByGroupId(groupId, start, end, orderByComparator);
1429                    }
1430    
1431                    Session session = null;
1432    
1433                    try {
1434                            session = openSession();
1435    
1436                            StringBundler query = null;
1437    
1438                            if (orderByComparator != null) {
1439                                    query = new StringBundler(3 +
1440                                                    (orderByComparator.getOrderByFields().length * 3));
1441                            }
1442                            else {
1443                                    query = new StringBundler(3);
1444                            }
1445    
1446                            query.append(_FILTER_SQL_SELECT_JOURNALFEED_WHERE);
1447    
1448                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1449    
1450                            if (orderByComparator != null) {
1451                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1452                                            orderByComparator);
1453                            }
1454    
1455                            else {
1456                                    query.append(JournalFeedModelImpl.ORDER_BY_JPQL);
1457                            }
1458    
1459                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1460                                            JournalFeed.class.getName(), _FILTER_COLUMN_PK,
1461                                            _FILTER_COLUMN_USERID, groupId);
1462    
1463                            SQLQuery q = session.createSQLQuery(sql);
1464    
1465                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalFeedImpl.class);
1466    
1467                            QueryPos qPos = QueryPos.getInstance(q);
1468    
1469                            qPos.add(groupId);
1470    
1471                            return (List<JournalFeed>)QueryUtil.list(q, getDialect(), start, end);
1472                    }
1473                    catch (Exception e) {
1474                            throw processException(e);
1475                    }
1476                    finally {
1477                            closeSession(session);
1478                    }
1479            }
1480    
1481            /**
1482             * Finds the journal feed where groupId = &#63; and feedId = &#63; or throws a {@link com.liferay.portlet.journal.NoSuchFeedException} if it could not be found.
1483             *
1484             * @param groupId the group id to search with
1485             * @param feedId the feed id to search with
1486             * @return the matching journal feed
1487             * @throws com.liferay.portlet.journal.NoSuchFeedException if a matching journal feed could not be found
1488             * @throws SystemException if a system exception occurred
1489             */
1490            public JournalFeed findByG_F(long groupId, String feedId)
1491                    throws NoSuchFeedException, SystemException {
1492                    JournalFeed journalFeed = fetchByG_F(groupId, feedId);
1493    
1494                    if (journalFeed == null) {
1495                            StringBundler msg = new StringBundler(6);
1496    
1497                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1498    
1499                            msg.append("groupId=");
1500                            msg.append(groupId);
1501    
1502                            msg.append(", feedId=");
1503                            msg.append(feedId);
1504    
1505                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1506    
1507                            if (_log.isWarnEnabled()) {
1508                                    _log.warn(msg.toString());
1509                            }
1510    
1511                            throw new NoSuchFeedException(msg.toString());
1512                    }
1513    
1514                    return journalFeed;
1515            }
1516    
1517            /**
1518             * Finds the journal feed where groupId = &#63; and feedId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1519             *
1520             * @param groupId the group id to search with
1521             * @param feedId the feed id to search with
1522             * @return the matching journal feed, or <code>null</code> if a matching journal feed could not be found
1523             * @throws SystemException if a system exception occurred
1524             */
1525            public JournalFeed fetchByG_F(long groupId, String feedId)
1526                    throws SystemException {
1527                    return fetchByG_F(groupId, feedId, true);
1528            }
1529    
1530            /**
1531             * Finds the journal feed where groupId = &#63; and feedId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1532             *
1533             * @param groupId the group id to search with
1534             * @param feedId the feed id to search with
1535             * @return the matching journal feed, or <code>null</code> if a matching journal feed could not be found
1536             * @throws SystemException if a system exception occurred
1537             */
1538            public JournalFeed fetchByG_F(long groupId, String feedId,
1539                    boolean retrieveFromCache) throws SystemException {
1540                    Object[] finderArgs = new Object[] { groupId, feedId };
1541    
1542                    Object result = null;
1543    
1544                    if (retrieveFromCache) {
1545                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_F,
1546                                            finderArgs, this);
1547                    }
1548    
1549                    if (result == null) {
1550                            Session session = null;
1551    
1552                            try {
1553                                    session = openSession();
1554    
1555                                    StringBundler query = new StringBundler(4);
1556    
1557                                    query.append(_SQL_SELECT_JOURNALFEED_WHERE);
1558    
1559                                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
1560    
1561                                    if (feedId == null) {
1562                                            query.append(_FINDER_COLUMN_G_F_FEEDID_1);
1563                                    }
1564                                    else {
1565                                            if (feedId.equals(StringPool.BLANK)) {
1566                                                    query.append(_FINDER_COLUMN_G_F_FEEDID_3);
1567                                            }
1568                                            else {
1569                                                    query.append(_FINDER_COLUMN_G_F_FEEDID_2);
1570                                            }
1571                                    }
1572    
1573                                    query.append(JournalFeedModelImpl.ORDER_BY_JPQL);
1574    
1575                                    String sql = query.toString();
1576    
1577                                    Query q = session.createQuery(sql);
1578    
1579                                    QueryPos qPos = QueryPos.getInstance(q);
1580    
1581                                    qPos.add(groupId);
1582    
1583                                    if (feedId != null) {
1584                                            qPos.add(feedId);
1585                                    }
1586    
1587                                    List<JournalFeed> list = q.list();
1588    
1589                                    result = list;
1590    
1591                                    JournalFeed journalFeed = null;
1592    
1593                                    if (list.isEmpty()) {
1594                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F,
1595                                                    finderArgs, list);
1596                                    }
1597                                    else {
1598                                            journalFeed = list.get(0);
1599    
1600                                            cacheResult(journalFeed);
1601    
1602                                            if ((journalFeed.getGroupId() != groupId) ||
1603                                                            (journalFeed.getFeedId() == null) ||
1604                                                            !journalFeed.getFeedId().equals(feedId)) {
1605                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F,
1606                                                            finderArgs, journalFeed);
1607                                            }
1608                                    }
1609    
1610                                    return journalFeed;
1611                            }
1612                            catch (Exception e) {
1613                                    throw processException(e);
1614                            }
1615                            finally {
1616                                    if (result == null) {
1617                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F,
1618                                                    finderArgs, new ArrayList<JournalFeed>());
1619                                    }
1620    
1621                                    closeSession(session);
1622                            }
1623                    }
1624                    else {
1625                            if (result instanceof List<?>) {
1626                                    return null;
1627                            }
1628                            else {
1629                                    return (JournalFeed)result;
1630                            }
1631                    }
1632            }
1633    
1634            /**
1635             * Finds all the journal feeds.
1636             *
1637             * @return the journal feeds
1638             * @throws SystemException if a system exception occurred
1639             */
1640            public List<JournalFeed> findAll() throws SystemException {
1641                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1642            }
1643    
1644            /**
1645             * Finds a range of all the journal feeds.
1646             *
1647             * <p>
1648             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1649             * </p>
1650             *
1651             * @param start the lower bound of the range of journal feeds to return
1652             * @param end the upper bound of the range of journal feeds to return (not inclusive)
1653             * @return the range of journal feeds
1654             * @throws SystemException if a system exception occurred
1655             */
1656            public List<JournalFeed> findAll(int start, int end)
1657                    throws SystemException {
1658                    return findAll(start, end, null);
1659            }
1660    
1661            /**
1662             * Finds an ordered range of all the journal feeds.
1663             *
1664             * <p>
1665             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1666             * </p>
1667             *
1668             * @param start the lower bound of the range of journal feeds to return
1669             * @param end the upper bound of the range of journal feeds to return (not inclusive)
1670             * @param orderByComparator the comparator to order the results by
1671             * @return the ordered range of journal feeds
1672             * @throws SystemException if a system exception occurred
1673             */
1674            public List<JournalFeed> findAll(int start, int end,
1675                    OrderByComparator orderByComparator) throws SystemException {
1676                    Object[] finderArgs = new Object[] {
1677                                    String.valueOf(start), String.valueOf(end),
1678                                    String.valueOf(orderByComparator)
1679                            };
1680    
1681                    List<JournalFeed> list = (List<JournalFeed>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1682                                    finderArgs, this);
1683    
1684                    if (list == null) {
1685                            Session session = null;
1686    
1687                            try {
1688                                    session = openSession();
1689    
1690                                    StringBundler query = null;
1691                                    String sql = null;
1692    
1693                                    if (orderByComparator != null) {
1694                                            query = new StringBundler(2 +
1695                                                            (orderByComparator.getOrderByFields().length * 3));
1696    
1697                                            query.append(_SQL_SELECT_JOURNALFEED);
1698    
1699                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1700                                                    orderByComparator);
1701    
1702                                            sql = query.toString();
1703                                    }
1704                                    else {
1705                                            sql = _SQL_SELECT_JOURNALFEED.concat(JournalFeedModelImpl.ORDER_BY_JPQL);
1706                                    }
1707    
1708                                    Query q = session.createQuery(sql);
1709    
1710                                    if (orderByComparator == null) {
1711                                            list = (List<JournalFeed>)QueryUtil.list(q, getDialect(),
1712                                                            start, end, false);
1713    
1714                                            Collections.sort(list);
1715                                    }
1716                                    else {
1717                                            list = (List<JournalFeed>)QueryUtil.list(q, getDialect(),
1718                                                            start, end);
1719                                    }
1720                            }
1721                            catch (Exception e) {
1722                                    throw processException(e);
1723                            }
1724                            finally {
1725                                    if (list == null) {
1726                                            list = new ArrayList<JournalFeed>();
1727                                    }
1728    
1729                                    cacheResult(list);
1730    
1731                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1732    
1733                                    closeSession(session);
1734                            }
1735                    }
1736    
1737                    return list;
1738            }
1739    
1740            /**
1741             * Removes all the journal feeds where uuid = &#63; from the database.
1742             *
1743             * @param uuid the uuid to search with
1744             * @throws SystemException if a system exception occurred
1745             */
1746            public void removeByUuid(String uuid) throws SystemException {
1747                    for (JournalFeed journalFeed : findByUuid(uuid)) {
1748                            remove(journalFeed);
1749                    }
1750            }
1751    
1752            /**
1753             * Removes the journal feed where uuid = &#63; and groupId = &#63; from the database.
1754             *
1755             * @param uuid the uuid to search with
1756             * @param groupId the group id to search with
1757             * @throws SystemException if a system exception occurred
1758             */
1759            public void removeByUUID_G(String uuid, long groupId)
1760                    throws NoSuchFeedException, SystemException {
1761                    JournalFeed journalFeed = findByUUID_G(uuid, groupId);
1762    
1763                    remove(journalFeed);
1764            }
1765    
1766            /**
1767             * Removes all the journal feeds where groupId = &#63; from the database.
1768             *
1769             * @param groupId the group id to search with
1770             * @throws SystemException if a system exception occurred
1771             */
1772            public void removeByGroupId(long groupId) throws SystemException {
1773                    for (JournalFeed journalFeed : findByGroupId(groupId)) {
1774                            remove(journalFeed);
1775                    }
1776            }
1777    
1778            /**
1779             * Removes the journal feed where groupId = &#63; and feedId = &#63; from the database.
1780             *
1781             * @param groupId the group id to search with
1782             * @param feedId the feed id to search with
1783             * @throws SystemException if a system exception occurred
1784             */
1785            public void removeByG_F(long groupId, String feedId)
1786                    throws NoSuchFeedException, SystemException {
1787                    JournalFeed journalFeed = findByG_F(groupId, feedId);
1788    
1789                    remove(journalFeed);
1790            }
1791    
1792            /**
1793             * Removes all the journal feeds from the database.
1794             *
1795             * @throws SystemException if a system exception occurred
1796             */
1797            public void removeAll() throws SystemException {
1798                    for (JournalFeed journalFeed : findAll()) {
1799                            remove(journalFeed);
1800                    }
1801            }
1802    
1803            /**
1804             * Counts all the journal feeds where uuid = &#63;.
1805             *
1806             * @param uuid the uuid to search with
1807             * @return the number of matching journal feeds
1808             * @throws SystemException if a system exception occurred
1809             */
1810            public int countByUuid(String uuid) throws SystemException {
1811                    Object[] finderArgs = new Object[] { uuid };
1812    
1813                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
1814                                    finderArgs, this);
1815    
1816                    if (count == null) {
1817                            Session session = null;
1818    
1819                            try {
1820                                    session = openSession();
1821    
1822                                    StringBundler query = new StringBundler(2);
1823    
1824                                    query.append(_SQL_COUNT_JOURNALFEED_WHERE);
1825    
1826                                    if (uuid == null) {
1827                                            query.append(_FINDER_COLUMN_UUID_UUID_1);
1828                                    }
1829                                    else {
1830                                            if (uuid.equals(StringPool.BLANK)) {
1831                                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
1832                                            }
1833                                            else {
1834                                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
1835                                            }
1836                                    }
1837    
1838                                    String sql = query.toString();
1839    
1840                                    Query q = session.createQuery(sql);
1841    
1842                                    QueryPos qPos = QueryPos.getInstance(q);
1843    
1844                                    if (uuid != null) {
1845                                            qPos.add(uuid);
1846                                    }
1847    
1848                                    count = (Long)q.uniqueResult();
1849                            }
1850                            catch (Exception e) {
1851                                    throw processException(e);
1852                            }
1853                            finally {
1854                                    if (count == null) {
1855                                            count = Long.valueOf(0);
1856                                    }
1857    
1858                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
1859                                            finderArgs, count);
1860    
1861                                    closeSession(session);
1862                            }
1863                    }
1864    
1865                    return count.intValue();
1866            }
1867    
1868            /**
1869             * Counts all the journal feeds where uuid = &#63; and groupId = &#63;.
1870             *
1871             * @param uuid the uuid to search with
1872             * @param groupId the group id to search with
1873             * @return the number of matching journal feeds
1874             * @throws SystemException if a system exception occurred
1875             */
1876            public int countByUUID_G(String uuid, long groupId)
1877                    throws SystemException {
1878                    Object[] finderArgs = new Object[] { uuid, groupId };
1879    
1880                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
1881                                    finderArgs, this);
1882    
1883                    if (count == null) {
1884                            Session session = null;
1885    
1886                            try {
1887                                    session = openSession();
1888    
1889                                    StringBundler query = new StringBundler(3);
1890    
1891                                    query.append(_SQL_COUNT_JOURNALFEED_WHERE);
1892    
1893                                    if (uuid == null) {
1894                                            query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1895                                    }
1896                                    else {
1897                                            if (uuid.equals(StringPool.BLANK)) {
1898                                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1899                                            }
1900                                            else {
1901                                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1902                                            }
1903                                    }
1904    
1905                                    query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1906    
1907                                    String sql = query.toString();
1908    
1909                                    Query q = session.createQuery(sql);
1910    
1911                                    QueryPos qPos = QueryPos.getInstance(q);
1912    
1913                                    if (uuid != null) {
1914                                            qPos.add(uuid);
1915                                    }
1916    
1917                                    qPos.add(groupId);
1918    
1919                                    count = (Long)q.uniqueResult();
1920                            }
1921                            catch (Exception e) {
1922                                    throw processException(e);
1923                            }
1924                            finally {
1925                                    if (count == null) {
1926                                            count = Long.valueOf(0);
1927                                    }
1928    
1929                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
1930                                            finderArgs, count);
1931    
1932                                    closeSession(session);
1933                            }
1934                    }
1935    
1936                    return count.intValue();
1937            }
1938    
1939            /**
1940             * Counts all the journal feeds where groupId = &#63;.
1941             *
1942             * @param groupId the group id to search with
1943             * @return the number of matching journal feeds
1944             * @throws SystemException if a system exception occurred
1945             */
1946            public int countByGroupId(long groupId) throws SystemException {
1947                    Object[] finderArgs = new Object[] { groupId };
1948    
1949                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1950                                    finderArgs, this);
1951    
1952                    if (count == null) {
1953                            Session session = null;
1954    
1955                            try {
1956                                    session = openSession();
1957    
1958                                    StringBundler query = new StringBundler(2);
1959    
1960                                    query.append(_SQL_COUNT_JOURNALFEED_WHERE);
1961    
1962                                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1963    
1964                                    String sql = query.toString();
1965    
1966                                    Query q = session.createQuery(sql);
1967    
1968                                    QueryPos qPos = QueryPos.getInstance(q);
1969    
1970                                    qPos.add(groupId);
1971    
1972                                    count = (Long)q.uniqueResult();
1973                            }
1974                            catch (Exception e) {
1975                                    throw processException(e);
1976                            }
1977                            finally {
1978                                    if (count == null) {
1979                                            count = Long.valueOf(0);
1980                                    }
1981    
1982                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1983                                            finderArgs, count);
1984    
1985                                    closeSession(session);
1986                            }
1987                    }
1988    
1989                    return count.intValue();
1990            }
1991    
1992            /**
1993             * Filters by the user's permissions and counts all the journal feeds where groupId = &#63;.
1994             *
1995             * @param groupId the group id to search with
1996             * @return the number of matching journal feeds that the user has permission to view
1997             * @throws SystemException if a system exception occurred
1998             */
1999            public int filterCountByGroupId(long groupId) throws SystemException {
2000                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2001                            return countByGroupId(groupId);
2002                    }
2003    
2004                    Session session = null;
2005    
2006                    try {
2007                            session = openSession();
2008    
2009                            StringBundler query = new StringBundler(2);
2010    
2011                            query.append(_FILTER_SQL_COUNT_JOURNALFEED_WHERE);
2012    
2013                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2014    
2015                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2016                                            JournalFeed.class.getName(), _FILTER_COLUMN_PK,
2017                                            _FILTER_COLUMN_USERID, groupId);
2018    
2019                            SQLQuery q = session.createSQLQuery(sql);
2020    
2021                            q.addScalar(COUNT_COLUMN_NAME,
2022                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2023    
2024                            QueryPos qPos = QueryPos.getInstance(q);
2025    
2026                            qPos.add(groupId);
2027    
2028                            Long count = (Long)q.uniqueResult();
2029    
2030                            return count.intValue();
2031                    }
2032                    catch (Exception e) {
2033                            throw processException(e);
2034                    }
2035                    finally {
2036                            closeSession(session);
2037                    }
2038            }
2039    
2040            /**
2041             * Counts all the journal feeds where groupId = &#63; and feedId = &#63;.
2042             *
2043             * @param groupId the group id to search with
2044             * @param feedId the feed id to search with
2045             * @return the number of matching journal feeds
2046             * @throws SystemException if a system exception occurred
2047             */
2048            public int countByG_F(long groupId, String feedId)
2049                    throws SystemException {
2050                    Object[] finderArgs = new Object[] { groupId, feedId };
2051    
2052                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F,
2053                                    finderArgs, this);
2054    
2055                    if (count == null) {
2056                            Session session = null;
2057    
2058                            try {
2059                                    session = openSession();
2060    
2061                                    StringBundler query = new StringBundler(3);
2062    
2063                                    query.append(_SQL_COUNT_JOURNALFEED_WHERE);
2064    
2065                                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
2066    
2067                                    if (feedId == null) {
2068                                            query.append(_FINDER_COLUMN_G_F_FEEDID_1);
2069                                    }
2070                                    else {
2071                                            if (feedId.equals(StringPool.BLANK)) {
2072                                                    query.append(_FINDER_COLUMN_G_F_FEEDID_3);
2073                                            }
2074                                            else {
2075                                                    query.append(_FINDER_COLUMN_G_F_FEEDID_2);
2076                                            }
2077                                    }
2078    
2079                                    String sql = query.toString();
2080    
2081                                    Query q = session.createQuery(sql);
2082    
2083                                    QueryPos qPos = QueryPos.getInstance(q);
2084    
2085                                    qPos.add(groupId);
2086    
2087                                    if (feedId != null) {
2088                                            qPos.add(feedId);
2089                                    }
2090    
2091                                    count = (Long)q.uniqueResult();
2092                            }
2093                            catch (Exception e) {
2094                                    throw processException(e);
2095                            }
2096                            finally {
2097                                    if (count == null) {
2098                                            count = Long.valueOf(0);
2099                                    }
2100    
2101                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F, finderArgs,
2102                                            count);
2103    
2104                                    closeSession(session);
2105                            }
2106                    }
2107    
2108                    return count.intValue();
2109            }
2110    
2111            /**
2112             * Filters by the user's permissions and counts all the journal feeds where groupId = &#63; and feedId = &#63;.
2113             *
2114             * @param groupId the group id to search with
2115             * @param feedId the feed id to search with
2116             * @return the number of matching journal feeds that the user has permission to view
2117             * @throws SystemException if a system exception occurred
2118             */
2119            public int filterCountByG_F(long groupId, String feedId)
2120                    throws SystemException {
2121                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2122                            return countByG_F(groupId, feedId);
2123                    }
2124    
2125                    Session session = null;
2126    
2127                    try {
2128                            session = openSession();
2129    
2130                            StringBundler query = new StringBundler(3);
2131    
2132                            query.append(_FILTER_SQL_COUNT_JOURNALFEED_WHERE);
2133    
2134                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
2135    
2136                            if (feedId == null) {
2137                                    query.append(_FINDER_COLUMN_G_F_FEEDID_1);
2138                            }
2139                            else {
2140                                    if (feedId.equals(StringPool.BLANK)) {
2141                                            query.append(_FINDER_COLUMN_G_F_FEEDID_3);
2142                                    }
2143                                    else {
2144                                            query.append(_FINDER_COLUMN_G_F_FEEDID_2);
2145                                    }
2146                            }
2147    
2148                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2149                                            JournalFeed.class.getName(), _FILTER_COLUMN_PK,
2150                                            _FILTER_COLUMN_USERID, groupId);
2151    
2152                            SQLQuery q = session.createSQLQuery(sql);
2153    
2154                            q.addScalar(COUNT_COLUMN_NAME,
2155                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2156    
2157                            QueryPos qPos = QueryPos.getInstance(q);
2158    
2159                            qPos.add(groupId);
2160    
2161                            if (feedId != null) {
2162                                    qPos.add(feedId);
2163                            }
2164    
2165                            Long count = (Long)q.uniqueResult();
2166    
2167                            return count.intValue();
2168                    }
2169                    catch (Exception e) {
2170                            throw processException(e);
2171                    }
2172                    finally {
2173                            closeSession(session);
2174                    }
2175            }
2176    
2177            /**
2178             * Counts all the journal feeds.
2179             *
2180             * @return the number of journal feeds
2181             * @throws SystemException if a system exception occurred
2182             */
2183            public int countAll() throws SystemException {
2184                    Object[] finderArgs = new Object[0];
2185    
2186                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2187                                    finderArgs, this);
2188    
2189                    if (count == null) {
2190                            Session session = null;
2191    
2192                            try {
2193                                    session = openSession();
2194    
2195                                    Query q = session.createQuery(_SQL_COUNT_JOURNALFEED);
2196    
2197                                    count = (Long)q.uniqueResult();
2198                            }
2199                            catch (Exception e) {
2200                                    throw processException(e);
2201                            }
2202                            finally {
2203                                    if (count == null) {
2204                                            count = Long.valueOf(0);
2205                                    }
2206    
2207                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
2208                                            count);
2209    
2210                                    closeSession(session);
2211                            }
2212                    }
2213    
2214                    return count.intValue();
2215            }
2216    
2217            /**
2218             * Initializes the journal feed persistence.
2219             */
2220            public void afterPropertiesSet() {
2221                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2222                                            com.liferay.portal.util.PropsUtil.get(
2223                                                    "value.object.listener.com.liferay.portlet.journal.model.JournalFeed")));
2224    
2225                    if (listenerClassNames.length > 0) {
2226                            try {
2227                                    List<ModelListener<JournalFeed>> listenersList = new ArrayList<ModelListener<JournalFeed>>();
2228    
2229                                    for (String listenerClassName : listenerClassNames) {
2230                                            listenersList.add((ModelListener<JournalFeed>)InstanceFactory.newInstance(
2231                                                            listenerClassName));
2232                                    }
2233    
2234                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2235                            }
2236                            catch (Exception e) {
2237                                    _log.error(e);
2238                            }
2239                    }
2240            }
2241    
2242            @BeanReference(type = JournalArticlePersistence.class)
2243            protected JournalArticlePersistence journalArticlePersistence;
2244            @BeanReference(type = JournalArticleImagePersistence.class)
2245            protected JournalArticleImagePersistence journalArticleImagePersistence;
2246            @BeanReference(type = JournalArticleResourcePersistence.class)
2247            protected JournalArticleResourcePersistence journalArticleResourcePersistence;
2248            @BeanReference(type = JournalContentSearchPersistence.class)
2249            protected JournalContentSearchPersistence journalContentSearchPersistence;
2250            @BeanReference(type = JournalFeedPersistence.class)
2251            protected JournalFeedPersistence journalFeedPersistence;
2252            @BeanReference(type = JournalStructurePersistence.class)
2253            protected JournalStructurePersistence journalStructurePersistence;
2254            @BeanReference(type = JournalTemplatePersistence.class)
2255            protected JournalTemplatePersistence journalTemplatePersistence;
2256            @BeanReference(type = ResourcePersistence.class)
2257            protected ResourcePersistence resourcePersistence;
2258            @BeanReference(type = UserPersistence.class)
2259            protected UserPersistence userPersistence;
2260            @BeanReference(type = ExpandoValuePersistence.class)
2261            protected ExpandoValuePersistence expandoValuePersistence;
2262            private static final String _SQL_SELECT_JOURNALFEED = "SELECT journalFeed FROM JournalFeed journalFeed";
2263            private static final String _SQL_SELECT_JOURNALFEED_WHERE = "SELECT journalFeed FROM JournalFeed journalFeed WHERE ";
2264            private static final String _SQL_COUNT_JOURNALFEED = "SELECT COUNT(journalFeed) FROM JournalFeed journalFeed";
2265            private static final String _SQL_COUNT_JOURNALFEED_WHERE = "SELECT COUNT(journalFeed) FROM JournalFeed journalFeed WHERE ";
2266            private static final String _FINDER_COLUMN_UUID_UUID_1 = "journalFeed.uuid IS NULL";
2267            private static final String _FINDER_COLUMN_UUID_UUID_2 = "journalFeed.uuid = ?";
2268            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(journalFeed.uuid IS NULL OR journalFeed.uuid = ?)";
2269            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "journalFeed.uuid IS NULL AND ";
2270            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "journalFeed.uuid = ? AND ";
2271            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(journalFeed.uuid IS NULL OR journalFeed.uuid = ?) AND ";
2272            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "journalFeed.groupId = ?";
2273            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "journalFeed.groupId = ?";
2274            private static final String _FINDER_COLUMN_G_F_GROUPID_2 = "journalFeed.groupId = ? AND ";
2275            private static final String _FINDER_COLUMN_G_F_FEEDID_1 = "journalFeed.feedId IS NULL";
2276            private static final String _FINDER_COLUMN_G_F_FEEDID_2 = "journalFeed.feedId = ?";
2277            private static final String _FINDER_COLUMN_G_F_FEEDID_3 = "(journalFeed.feedId IS NULL OR journalFeed.feedId = ?)";
2278            private static final String _FILTER_SQL_SELECT_JOURNALFEED_WHERE = "SELECT DISTINCT {journalFeed.*} FROM JournalFeed journalFeed WHERE ";
2279            private static final String _FILTER_SQL_COUNT_JOURNALFEED_WHERE = "SELECT COUNT(DISTINCT journalFeed.id) AS COUNT_VALUE FROM JournalFeed journalFeed WHERE ";
2280            private static final String _FILTER_COLUMN_PK = "journalFeed.id";
2281            private static final String _FILTER_COLUMN_USERID = "journalFeed.userId";
2282            private static final String _FILTER_ENTITY_ALIAS = "journalFeed";
2283            private static final String _ORDER_BY_ENTITY_ALIAS = "journalFeed.";
2284            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalFeed exists with the primary key ";
2285            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalFeed exists with the key {";
2286            private static Log _log = LogFactoryUtil.getLog(JournalFeedPersistenceImpl.class);
2287    }