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