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