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.GroupPersistence;
043    import com.liferay.portal.service.persistence.UserPersistence;
044    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
045    
046    import com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence;
047    import com.liferay.portlet.journal.NoSuchFolderException;
048    import com.liferay.portlet.journal.model.JournalFolder;
049    import com.liferay.portlet.journal.model.impl.JournalFolderImpl;
050    import com.liferay.portlet.journal.model.impl.JournalFolderModelImpl;
051    
052    import java.io.Serializable;
053    
054    import java.util.ArrayList;
055    import java.util.Collections;
056    import java.util.List;
057    
058    /**
059     * The persistence implementation for the journal folder service.
060     *
061     * <p>
062     * Caching information and settings can be found in <code>portal.properties</code>
063     * </p>
064     *
065     * @author Brian Wing Shun Chan
066     * @see JournalFolderPersistence
067     * @see JournalFolderUtil
068     * @generated
069     */
070    public class JournalFolderPersistenceImpl extends BasePersistenceImpl<JournalFolder>
071            implements JournalFolderPersistence {
072            /*
073             * NOTE FOR DEVELOPERS:
074             *
075             * Never modify or reference this class directly. Always use {@link JournalFolderUtil} to access the journal folder persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
076             */
077            public static final String FINDER_CLASS_NAME_ENTITY = JournalFolderImpl.class.getName();
078            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
079                    ".List1";
080            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
081                    ".List2";
082            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
083                            JournalFolderModelImpl.FINDER_CACHE_ENABLED,
084                            JournalFolderImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
085                            "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(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
093                            JournalFolderModelImpl.FINDER_CACHE_ENABLED,
094                            JournalFolderImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
095                            "findByUuid", new String[] { String.class.getName() },
096                            JournalFolderModelImpl.UUID_COLUMN_BITMASK);
097            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
098                            JournalFolderModelImpl.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(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
102                            JournalFolderModelImpl.FINDER_CACHE_ENABLED,
103                            JournalFolderImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
104                            new String[] { String.class.getName(), Long.class.getName() },
105                            JournalFolderModelImpl.UUID_COLUMN_BITMASK |
106                            JournalFolderModelImpl.GROUPID_COLUMN_BITMASK);
107            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
108                            JournalFolderModelImpl.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_UUID_C = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
112                            JournalFolderModelImpl.FINDER_CACHE_ENABLED,
113                            JournalFolderImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
114                            "findByUuid_C",
115                            new String[] {
116                                    String.class.getName(), Long.class.getName(),
117                                    
118                            "java.lang.Integer", "java.lang.Integer",
119                                    "com.liferay.portal.kernel.util.OrderByComparator"
120                            });
121            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
122                    new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
123                            JournalFolderModelImpl.FINDER_CACHE_ENABLED,
124                            JournalFolderImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
125                            "findByUuid_C",
126                            new String[] { String.class.getName(), Long.class.getName() },
127                            JournalFolderModelImpl.UUID_COLUMN_BITMASK |
128                            JournalFolderModelImpl.COMPANYID_COLUMN_BITMASK);
129            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
130                            JournalFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
131                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
132                            new String[] { String.class.getName(), Long.class.getName() });
133            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
134                            JournalFolderModelImpl.FINDER_CACHE_ENABLED,
135                            JournalFolderImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
136                            "findByGroupId",
137                            new String[] {
138                                    Long.class.getName(),
139                                    
140                            "java.lang.Integer", "java.lang.Integer",
141                                    "com.liferay.portal.kernel.util.OrderByComparator"
142                            });
143            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
144                    new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
145                            JournalFolderModelImpl.FINDER_CACHE_ENABLED,
146                            JournalFolderImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
147                            "findByGroupId", new String[] { Long.class.getName() },
148                            JournalFolderModelImpl.GROUPID_COLUMN_BITMASK);
149            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
150                            JournalFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
151                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
152                            new String[] { Long.class.getName() });
153            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
154                    new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
155                            JournalFolderModelImpl.FINDER_CACHE_ENABLED,
156                            JournalFolderImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
157                            "findByCompanyId",
158                            new String[] {
159                                    Long.class.getName(),
160                                    
161                            "java.lang.Integer", "java.lang.Integer",
162                                    "com.liferay.portal.kernel.util.OrderByComparator"
163                            });
164            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
165                    new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
166                            JournalFolderModelImpl.FINDER_CACHE_ENABLED,
167                            JournalFolderImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
168                            "findByCompanyId", new String[] { Long.class.getName() },
169                            JournalFolderModelImpl.COMPANYID_COLUMN_BITMASK);
170            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
171                            JournalFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
172                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
173                            new String[] { Long.class.getName() });
174            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
175                            JournalFolderModelImpl.FINDER_CACHE_ENABLED,
176                            JournalFolderImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
177                            "findByG_P",
178                            new String[] {
179                                    Long.class.getName(), Long.class.getName(),
180                                    
181                            "java.lang.Integer", "java.lang.Integer",
182                                    "com.liferay.portal.kernel.util.OrderByComparator"
183                            });
184            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
185                            JournalFolderModelImpl.FINDER_CACHE_ENABLED,
186                            JournalFolderImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
187                            "findByG_P",
188                            new String[] { Long.class.getName(), Long.class.getName() },
189                            JournalFolderModelImpl.GROUPID_COLUMN_BITMASK |
190                            JournalFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK);
191            public static final FinderPath FINDER_PATH_COUNT_BY_G_P = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
192                            JournalFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
193                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P",
194                            new String[] { Long.class.getName(), Long.class.getName() });
195            public static final FinderPath FINDER_PATH_FETCH_BY_G_N = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
196                            JournalFolderModelImpl.FINDER_CACHE_ENABLED,
197                            JournalFolderImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_N",
198                            new String[] { Long.class.getName(), String.class.getName() },
199                            JournalFolderModelImpl.GROUPID_COLUMN_BITMASK |
200                            JournalFolderModelImpl.NAME_COLUMN_BITMASK);
201            public static final FinderPath FINDER_PATH_COUNT_BY_G_N = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
202                            JournalFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
203                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N",
204                            new String[] { Long.class.getName(), String.class.getName() });
205            public static final FinderPath FINDER_PATH_FETCH_BY_G_P_N = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
206                            JournalFolderModelImpl.FINDER_CACHE_ENABLED,
207                            JournalFolderImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_P_N",
208                            new String[] {
209                                    Long.class.getName(), Long.class.getName(),
210                                    String.class.getName()
211                            },
212                            JournalFolderModelImpl.GROUPID_COLUMN_BITMASK |
213                            JournalFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
214                            JournalFolderModelImpl.NAME_COLUMN_BITMASK);
215            public static final FinderPath FINDER_PATH_COUNT_BY_G_P_N = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
216                            JournalFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
217                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_N",
218                            new String[] {
219                                    Long.class.getName(), Long.class.getName(),
220                                    String.class.getName()
221                            });
222            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
223                            JournalFolderModelImpl.FINDER_CACHE_ENABLED,
224                            JournalFolderImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
225                            "findAll", new String[0]);
226            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
227                            JournalFolderModelImpl.FINDER_CACHE_ENABLED,
228                            JournalFolderImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
229                            "findAll", new String[0]);
230            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
231                            JournalFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
232                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
233    
234            /**
235             * Caches the journal folder in the entity cache if it is enabled.
236             *
237             * @param journalFolder the journal folder
238             */
239            public void cacheResult(JournalFolder journalFolder) {
240                    EntityCacheUtil.putResult(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
241                            JournalFolderImpl.class, journalFolder.getPrimaryKey(),
242                            journalFolder);
243    
244                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
245                            new Object[] {
246                                    journalFolder.getUuid(),
247                                    Long.valueOf(journalFolder.getGroupId())
248                            }, journalFolder);
249    
250                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
251                            new Object[] {
252                                    Long.valueOf(journalFolder.getGroupId()),
253                                    
254                            journalFolder.getName()
255                            }, journalFolder);
256    
257                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
258                            new Object[] {
259                                    Long.valueOf(journalFolder.getGroupId()),
260                                    Long.valueOf(journalFolder.getParentFolderId()),
261                                    
262                            journalFolder.getName()
263                            }, journalFolder);
264    
265                    journalFolder.resetOriginalValues();
266            }
267    
268            /**
269             * Caches the journal folders in the entity cache if it is enabled.
270             *
271             * @param journalFolders the journal folders
272             */
273            public void cacheResult(List<JournalFolder> journalFolders) {
274                    for (JournalFolder journalFolder : journalFolders) {
275                            if (EntityCacheUtil.getResult(
276                                                    JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
277                                                    JournalFolderImpl.class, journalFolder.getPrimaryKey()) == null) {
278                                    cacheResult(journalFolder);
279                            }
280                            else {
281                                    journalFolder.resetOriginalValues();
282                            }
283                    }
284            }
285    
286            /**
287             * Clears the cache for all journal folders.
288             *
289             * <p>
290             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
291             * </p>
292             */
293            @Override
294            public void clearCache() {
295                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
296                            CacheRegistryUtil.clear(JournalFolderImpl.class.getName());
297                    }
298    
299                    EntityCacheUtil.clearCache(JournalFolderImpl.class.getName());
300    
301                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
302                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
303                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
304            }
305    
306            /**
307             * Clears the cache for the journal folder.
308             *
309             * <p>
310             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
311             * </p>
312             */
313            @Override
314            public void clearCache(JournalFolder journalFolder) {
315                    EntityCacheUtil.removeResult(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
316                            JournalFolderImpl.class, journalFolder.getPrimaryKey());
317    
318                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
319                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
320    
321                    clearUniqueFindersCache(journalFolder);
322            }
323    
324            @Override
325            public void clearCache(List<JournalFolder> journalFolders) {
326                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
327                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
328    
329                    for (JournalFolder journalFolder : journalFolders) {
330                            EntityCacheUtil.removeResult(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
331                                    JournalFolderImpl.class, journalFolder.getPrimaryKey());
332    
333                            clearUniqueFindersCache(journalFolder);
334                    }
335            }
336    
337            protected void clearUniqueFindersCache(JournalFolder journalFolder) {
338                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
339                            new Object[] {
340                                    journalFolder.getUuid(),
341                                    Long.valueOf(journalFolder.getGroupId())
342                            });
343    
344                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
345                            new Object[] {
346                                    Long.valueOf(journalFolder.getGroupId()),
347                                    
348                            journalFolder.getName()
349                            });
350    
351                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N,
352                            new Object[] {
353                                    Long.valueOf(journalFolder.getGroupId()),
354                                    Long.valueOf(journalFolder.getParentFolderId()),
355                                    
356                            journalFolder.getName()
357                            });
358            }
359    
360            /**
361             * Creates a new journal folder with the primary key. Does not add the journal folder to the database.
362             *
363             * @param folderId the primary key for the new journal folder
364             * @return the new journal folder
365             */
366            public JournalFolder create(long folderId) {
367                    JournalFolder journalFolder = new JournalFolderImpl();
368    
369                    journalFolder.setNew(true);
370                    journalFolder.setPrimaryKey(folderId);
371    
372                    String uuid = PortalUUIDUtil.generate();
373    
374                    journalFolder.setUuid(uuid);
375    
376                    return journalFolder;
377            }
378    
379            /**
380             * Removes the journal folder with the primary key from the database. Also notifies the appropriate model listeners.
381             *
382             * @param folderId the primary key of the journal folder
383             * @return the journal folder that was removed
384             * @throws com.liferay.portlet.journal.NoSuchFolderException if a journal folder with the primary key could not be found
385             * @throws SystemException if a system exception occurred
386             */
387            public JournalFolder remove(long folderId)
388                    throws NoSuchFolderException, SystemException {
389                    return remove(Long.valueOf(folderId));
390            }
391    
392            /**
393             * Removes the journal folder with the primary key from the database. Also notifies the appropriate model listeners.
394             *
395             * @param primaryKey the primary key of the journal folder
396             * @return the journal folder that was removed
397             * @throws com.liferay.portlet.journal.NoSuchFolderException if a journal folder with the primary key could not be found
398             * @throws SystemException if a system exception occurred
399             */
400            @Override
401            public JournalFolder remove(Serializable primaryKey)
402                    throws NoSuchFolderException, SystemException {
403                    Session session = null;
404    
405                    try {
406                            session = openSession();
407    
408                            JournalFolder journalFolder = (JournalFolder)session.get(JournalFolderImpl.class,
409                                            primaryKey);
410    
411                            if (journalFolder == null) {
412                                    if (_log.isWarnEnabled()) {
413                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
414                                    }
415    
416                                    throw new NoSuchFolderException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
417                                            primaryKey);
418                            }
419    
420                            return remove(journalFolder);
421                    }
422                    catch (NoSuchFolderException nsee) {
423                            throw nsee;
424                    }
425                    catch (Exception e) {
426                            throw processException(e);
427                    }
428                    finally {
429                            closeSession(session);
430                    }
431            }
432    
433            @Override
434            protected JournalFolder removeImpl(JournalFolder journalFolder)
435                    throws SystemException {
436                    journalFolder = toUnwrappedModel(journalFolder);
437    
438                    Session session = null;
439    
440                    try {
441                            session = openSession();
442    
443                            if (journalFolder.isCachedModel()) {
444                                    journalFolder = (JournalFolder)session.get(JournalFolderImpl.class,
445                                                    journalFolder.getPrimaryKeyObj());
446                            }
447    
448                            session.delete(journalFolder);
449                    }
450                    catch (Exception e) {
451                            throw processException(e);
452                    }
453                    finally {
454                            closeSession(session);
455                    }
456    
457                    clearCache(journalFolder);
458    
459                    return journalFolder;
460            }
461    
462            @Override
463            public JournalFolder updateImpl(
464                    com.liferay.portlet.journal.model.JournalFolder journalFolder)
465                    throws SystemException {
466                    journalFolder = toUnwrappedModel(journalFolder);
467    
468                    boolean isNew = journalFolder.isNew();
469    
470                    JournalFolderModelImpl journalFolderModelImpl = (JournalFolderModelImpl)journalFolder;
471    
472                    if (Validator.isNull(journalFolder.getUuid())) {
473                            String uuid = PortalUUIDUtil.generate();
474    
475                            journalFolder.setUuid(uuid);
476                    }
477    
478                    Session session = null;
479    
480                    try {
481                            session = openSession();
482    
483                            if (journalFolder.isNew()) {
484                                    session.save(journalFolder);
485    
486                                    journalFolder.setNew(false);
487                            }
488                            else {
489                                    session.merge(journalFolder);
490                            }
491                    }
492                    catch (Exception e) {
493                            throw processException(e);
494                    }
495                    finally {
496                            closeSession(session);
497                    }
498    
499                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
500    
501                    if (isNew || !JournalFolderModelImpl.COLUMN_BITMASK_ENABLED) {
502                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
503                    }
504    
505                    else {
506                            if ((journalFolderModelImpl.getColumnBitmask() &
507                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
508                                    Object[] args = new Object[] {
509                                                    journalFolderModelImpl.getOriginalUuid()
510                                            };
511    
512                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
513                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
514                                            args);
515    
516                                    args = new Object[] { journalFolderModelImpl.getUuid() };
517    
518                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
519                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
520                                            args);
521                            }
522    
523                            if ((journalFolderModelImpl.getColumnBitmask() &
524                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
525                                    Object[] args = new Object[] {
526                                                    journalFolderModelImpl.getOriginalUuid(),
527                                                    Long.valueOf(journalFolderModelImpl.getOriginalCompanyId())
528                                            };
529    
530                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
531                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
532                                            args);
533    
534                                    args = new Object[] {
535                                                    journalFolderModelImpl.getUuid(),
536                                                    Long.valueOf(journalFolderModelImpl.getCompanyId())
537                                            };
538    
539                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
540                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
541                                            args);
542                            }
543    
544                            if ((journalFolderModelImpl.getColumnBitmask() &
545                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
546                                    Object[] args = new Object[] {
547                                                    Long.valueOf(journalFolderModelImpl.getOriginalGroupId())
548                                            };
549    
550                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
551                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
552                                            args);
553    
554                                    args = new Object[] {
555                                                    Long.valueOf(journalFolderModelImpl.getGroupId())
556                                            };
557    
558                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
559                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
560                                            args);
561                            }
562    
563                            if ((journalFolderModelImpl.getColumnBitmask() &
564                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
565                                    Object[] args = new Object[] {
566                                                    Long.valueOf(journalFolderModelImpl.getOriginalCompanyId())
567                                            };
568    
569                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
570                                            args);
571                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
572                                            args);
573    
574                                    args = new Object[] {
575                                                    Long.valueOf(journalFolderModelImpl.getCompanyId())
576                                            };
577    
578                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
579                                            args);
580                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
581                                            args);
582                            }
583    
584                            if ((journalFolderModelImpl.getColumnBitmask() &
585                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P.getColumnBitmask()) != 0) {
586                                    Object[] args = new Object[] {
587                                                    Long.valueOf(journalFolderModelImpl.getOriginalGroupId()),
588                                                    Long.valueOf(journalFolderModelImpl.getOriginalParentFolderId())
589                                            };
590    
591                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
592                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
593                                            args);
594    
595                                    args = new Object[] {
596                                                    Long.valueOf(journalFolderModelImpl.getGroupId()),
597                                                    Long.valueOf(journalFolderModelImpl.getParentFolderId())
598                                            };
599    
600                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
601                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
602                                            args);
603                            }
604                    }
605    
606                    EntityCacheUtil.putResult(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
607                            JournalFolderImpl.class, journalFolder.getPrimaryKey(),
608                            journalFolder);
609    
610                    if (isNew) {
611                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
612                                    new Object[] {
613                                            journalFolder.getUuid(),
614                                            Long.valueOf(journalFolder.getGroupId())
615                                    }, journalFolder);
616    
617                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
618                                    new Object[] {
619                                            Long.valueOf(journalFolder.getGroupId()),
620                                            
621                                    journalFolder.getName()
622                                    }, journalFolder);
623    
624                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
625                                    new Object[] {
626                                            Long.valueOf(journalFolder.getGroupId()),
627                                            Long.valueOf(journalFolder.getParentFolderId()),
628                                            
629                                    journalFolder.getName()
630                                    }, journalFolder);
631                    }
632                    else {
633                            if ((journalFolderModelImpl.getColumnBitmask() &
634                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
635                                    Object[] args = new Object[] {
636                                                    journalFolderModelImpl.getOriginalUuid(),
637                                                    Long.valueOf(journalFolderModelImpl.getOriginalGroupId())
638                                            };
639    
640                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
641    
642                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
643    
644                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
645                                            new Object[] {
646                                                    journalFolder.getUuid(),
647                                                    Long.valueOf(journalFolder.getGroupId())
648                                            }, journalFolder);
649                            }
650    
651                            if ((journalFolderModelImpl.getColumnBitmask() &
652                                            FINDER_PATH_FETCH_BY_G_N.getColumnBitmask()) != 0) {
653                                    Object[] args = new Object[] {
654                                                    Long.valueOf(journalFolderModelImpl.getOriginalGroupId()),
655                                                    
656                                                    journalFolderModelImpl.getOriginalName()
657                                            };
658    
659                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N, args);
660    
661                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N, args);
662    
663                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
664                                            new Object[] {
665                                                    Long.valueOf(journalFolder.getGroupId()),
666                                                    
667                                            journalFolder.getName()
668                                            }, journalFolder);
669                            }
670    
671                            if ((journalFolderModelImpl.getColumnBitmask() &
672                                            FINDER_PATH_FETCH_BY_G_P_N.getColumnBitmask()) != 0) {
673                                    Object[] args = new Object[] {
674                                                    Long.valueOf(journalFolderModelImpl.getOriginalGroupId()),
675                                                    Long.valueOf(journalFolderModelImpl.getOriginalParentFolderId()),
676                                                    
677                                                    journalFolderModelImpl.getOriginalName()
678                                            };
679    
680                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_N, args);
681    
682                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N, args);
683    
684                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
685                                            new Object[] {
686                                                    Long.valueOf(journalFolder.getGroupId()),
687                                                    Long.valueOf(journalFolder.getParentFolderId()),
688                                                    
689                                            journalFolder.getName()
690                                            }, journalFolder);
691                            }
692                    }
693    
694                    return journalFolder;
695            }
696    
697            protected JournalFolder toUnwrappedModel(JournalFolder journalFolder) {
698                    if (journalFolder instanceof JournalFolderImpl) {
699                            return journalFolder;
700                    }
701    
702                    JournalFolderImpl journalFolderImpl = new JournalFolderImpl();
703    
704                    journalFolderImpl.setNew(journalFolder.isNew());
705                    journalFolderImpl.setPrimaryKey(journalFolder.getPrimaryKey());
706    
707                    journalFolderImpl.setUuid(journalFolder.getUuid());
708                    journalFolderImpl.setFolderId(journalFolder.getFolderId());
709                    journalFolderImpl.setGroupId(journalFolder.getGroupId());
710                    journalFolderImpl.setCompanyId(journalFolder.getCompanyId());
711                    journalFolderImpl.setUserId(journalFolder.getUserId());
712                    journalFolderImpl.setUserName(journalFolder.getUserName());
713                    journalFolderImpl.setCreateDate(journalFolder.getCreateDate());
714                    journalFolderImpl.setModifiedDate(journalFolder.getModifiedDate());
715                    journalFolderImpl.setParentFolderId(journalFolder.getParentFolderId());
716                    journalFolderImpl.setName(journalFolder.getName());
717                    journalFolderImpl.setDescription(journalFolder.getDescription());
718    
719                    return journalFolderImpl;
720            }
721    
722            /**
723             * Returns the journal folder with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
724             *
725             * @param primaryKey the primary key of the journal folder
726             * @return the journal folder
727             * @throws com.liferay.portal.NoSuchModelException if a journal folder with the primary key could not be found
728             * @throws SystemException if a system exception occurred
729             */
730            @Override
731            public JournalFolder findByPrimaryKey(Serializable primaryKey)
732                    throws NoSuchModelException, SystemException {
733                    return findByPrimaryKey(((Long)primaryKey).longValue());
734            }
735    
736            /**
737             * Returns the journal folder with the primary key or throws a {@link com.liferay.portlet.journal.NoSuchFolderException} if it could not be found.
738             *
739             * @param folderId the primary key of the journal folder
740             * @return the journal folder
741             * @throws com.liferay.portlet.journal.NoSuchFolderException if a journal folder with the primary key could not be found
742             * @throws SystemException if a system exception occurred
743             */
744            public JournalFolder findByPrimaryKey(long folderId)
745                    throws NoSuchFolderException, SystemException {
746                    JournalFolder journalFolder = fetchByPrimaryKey(folderId);
747    
748                    if (journalFolder == null) {
749                            if (_log.isWarnEnabled()) {
750                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + folderId);
751                            }
752    
753                            throw new NoSuchFolderException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
754                                    folderId);
755                    }
756    
757                    return journalFolder;
758            }
759    
760            /**
761             * Returns the journal folder with the primary key or returns <code>null</code> if it could not be found.
762             *
763             * @param primaryKey the primary key of the journal folder
764             * @return the journal folder, or <code>null</code> if a journal folder with the primary key could not be found
765             * @throws SystemException if a system exception occurred
766             */
767            @Override
768            public JournalFolder fetchByPrimaryKey(Serializable primaryKey)
769                    throws SystemException {
770                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
771            }
772    
773            /**
774             * Returns the journal folder with the primary key or returns <code>null</code> if it could not be found.
775             *
776             * @param folderId the primary key of the journal folder
777             * @return the journal folder, or <code>null</code> if a journal folder with the primary key could not be found
778             * @throws SystemException if a system exception occurred
779             */
780            public JournalFolder fetchByPrimaryKey(long folderId)
781                    throws SystemException {
782                    JournalFolder journalFolder = (JournalFolder)EntityCacheUtil.getResult(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
783                                    JournalFolderImpl.class, folderId);
784    
785                    if (journalFolder == _nullJournalFolder) {
786                            return null;
787                    }
788    
789                    if (journalFolder == null) {
790                            Session session = null;
791    
792                            boolean hasException = false;
793    
794                            try {
795                                    session = openSession();
796    
797                                    journalFolder = (JournalFolder)session.get(JournalFolderImpl.class,
798                                                    Long.valueOf(folderId));
799                            }
800                            catch (Exception e) {
801                                    hasException = true;
802    
803                                    throw processException(e);
804                            }
805                            finally {
806                                    if (journalFolder != null) {
807                                            cacheResult(journalFolder);
808                                    }
809                                    else if (!hasException) {
810                                            EntityCacheUtil.putResult(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
811                                                    JournalFolderImpl.class, folderId, _nullJournalFolder);
812                                    }
813    
814                                    closeSession(session);
815                            }
816                    }
817    
818                    return journalFolder;
819            }
820    
821            /**
822             * Returns all the journal folders where uuid = &#63;.
823             *
824             * @param uuid the uuid
825             * @return the matching journal folders
826             * @throws SystemException if a system exception occurred
827             */
828            public List<JournalFolder> findByUuid(String uuid)
829                    throws SystemException {
830                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
831            }
832    
833            /**
834             * Returns a range of all the journal folders where uuid = &#63;.
835             *
836             * <p>
837             * 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.
838             * </p>
839             *
840             * @param uuid the uuid
841             * @param start the lower bound of the range of journal folders
842             * @param end the upper bound of the range of journal folders (not inclusive)
843             * @return the range of matching journal folders
844             * @throws SystemException if a system exception occurred
845             */
846            public List<JournalFolder> findByUuid(String uuid, int start, int end)
847                    throws SystemException {
848                    return findByUuid(uuid, start, end, null);
849            }
850    
851            /**
852             * Returns an ordered range of all the journal folders where uuid = &#63;.
853             *
854             * <p>
855             * 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.
856             * </p>
857             *
858             * @param uuid the uuid
859             * @param start the lower bound of the range of journal folders
860             * @param end the upper bound of the range of journal folders (not inclusive)
861             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
862             * @return the ordered range of matching journal folders
863             * @throws SystemException if a system exception occurred
864             */
865            public List<JournalFolder> findByUuid(String uuid, int start, int end,
866                    OrderByComparator orderByComparator) throws SystemException {
867                    FinderPath finderPath = null;
868                    Object[] finderArgs = null;
869    
870                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
871                                    (orderByComparator == null)) {
872                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
873                            finderArgs = new Object[] { uuid };
874                    }
875                    else {
876                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
877                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
878                    }
879    
880                    List<JournalFolder> list = (List<JournalFolder>)FinderCacheUtil.getResult(finderPath,
881                                    finderArgs, this);
882    
883                    if ((list != null) && !list.isEmpty()) {
884                            for (JournalFolder journalFolder : list) {
885                                    if (!Validator.equals(uuid, journalFolder.getUuid())) {
886                                            list = null;
887    
888                                            break;
889                                    }
890                            }
891                    }
892    
893                    if (list == null) {
894                            StringBundler query = null;
895    
896                            if (orderByComparator != null) {
897                                    query = new StringBundler(3 +
898                                                    (orderByComparator.getOrderByFields().length * 3));
899                            }
900                            else {
901                                    query = new StringBundler(3);
902                            }
903    
904                            query.append(_SQL_SELECT_JOURNALFOLDER_WHERE);
905    
906                            if (uuid == null) {
907                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
908                            }
909                            else {
910                                    if (uuid.equals(StringPool.BLANK)) {
911                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
912                                    }
913                                    else {
914                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
915                                    }
916                            }
917    
918                            if (orderByComparator != null) {
919                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
920                                            orderByComparator);
921                            }
922    
923                            else {
924                                    query.append(JournalFolderModelImpl.ORDER_BY_JPQL);
925                            }
926    
927                            String sql = query.toString();
928    
929                            Session session = null;
930    
931                            try {
932                                    session = openSession();
933    
934                                    Query q = session.createQuery(sql);
935    
936                                    QueryPos qPos = QueryPos.getInstance(q);
937    
938                                    if (uuid != null) {
939                                            qPos.add(uuid);
940                                    }
941    
942                                    list = (List<JournalFolder>)QueryUtil.list(q, getDialect(),
943                                                    start, end);
944                            }
945                            catch (Exception e) {
946                                    throw processException(e);
947                            }
948                            finally {
949                                    if (list == null) {
950                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
951                                    }
952                                    else {
953                                            cacheResult(list);
954    
955                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
956                                    }
957    
958                                    closeSession(session);
959                            }
960                    }
961    
962                    return list;
963            }
964    
965            /**
966             * Returns the first journal folder in the ordered set where uuid = &#63;.
967             *
968             * @param uuid the uuid
969             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
970             * @return the first matching journal folder
971             * @throws com.liferay.portlet.journal.NoSuchFolderException if a matching journal folder could not be found
972             * @throws SystemException if a system exception occurred
973             */
974            public JournalFolder findByUuid_First(String uuid,
975                    OrderByComparator orderByComparator)
976                    throws NoSuchFolderException, SystemException {
977                    JournalFolder journalFolder = fetchByUuid_First(uuid, orderByComparator);
978    
979                    if (journalFolder != null) {
980                            return journalFolder;
981                    }
982    
983                    StringBundler msg = new StringBundler(4);
984    
985                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
986    
987                    msg.append("uuid=");
988                    msg.append(uuid);
989    
990                    msg.append(StringPool.CLOSE_CURLY_BRACE);
991    
992                    throw new NoSuchFolderException(msg.toString());
993            }
994    
995            /**
996             * Returns the first journal folder in the ordered set where uuid = &#63;.
997             *
998             * @param uuid the uuid
999             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1000             * @return the first matching journal folder, or <code>null</code> if a matching journal folder could not be found
1001             * @throws SystemException if a system exception occurred
1002             */
1003            public JournalFolder fetchByUuid_First(String uuid,
1004                    OrderByComparator orderByComparator) throws SystemException {
1005                    List<JournalFolder> list = findByUuid(uuid, 0, 1, orderByComparator);
1006    
1007                    if (!list.isEmpty()) {
1008                            return list.get(0);
1009                    }
1010    
1011                    return null;
1012            }
1013    
1014            /**
1015             * Returns the last journal folder in the ordered set where uuid = &#63;.
1016             *
1017             * @param uuid the uuid
1018             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1019             * @return the last matching journal folder
1020             * @throws com.liferay.portlet.journal.NoSuchFolderException if a matching journal folder could not be found
1021             * @throws SystemException if a system exception occurred
1022             */
1023            public JournalFolder findByUuid_Last(String uuid,
1024                    OrderByComparator orderByComparator)
1025                    throws NoSuchFolderException, SystemException {
1026                    JournalFolder journalFolder = fetchByUuid_Last(uuid, orderByComparator);
1027    
1028                    if (journalFolder != null) {
1029                            return journalFolder;
1030                    }
1031    
1032                    StringBundler msg = new StringBundler(4);
1033    
1034                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1035    
1036                    msg.append("uuid=");
1037                    msg.append(uuid);
1038    
1039                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1040    
1041                    throw new NoSuchFolderException(msg.toString());
1042            }
1043    
1044            /**
1045             * Returns the last journal folder in the ordered set where uuid = &#63;.
1046             *
1047             * @param uuid the uuid
1048             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1049             * @return the last matching journal folder, or <code>null</code> if a matching journal folder could not be found
1050             * @throws SystemException if a system exception occurred
1051             */
1052            public JournalFolder fetchByUuid_Last(String uuid,
1053                    OrderByComparator orderByComparator) throws SystemException {
1054                    int count = countByUuid(uuid);
1055    
1056                    List<JournalFolder> list = findByUuid(uuid, count - 1, count,
1057                                    orderByComparator);
1058    
1059                    if (!list.isEmpty()) {
1060                            return list.get(0);
1061                    }
1062    
1063                    return null;
1064            }
1065    
1066            /**
1067             * Returns the journal folders before and after the current journal folder in the ordered set where uuid = &#63;.
1068             *
1069             * @param folderId the primary key of the current journal folder
1070             * @param uuid the uuid
1071             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1072             * @return the previous, current, and next journal folder
1073             * @throws com.liferay.portlet.journal.NoSuchFolderException if a journal folder with the primary key could not be found
1074             * @throws SystemException if a system exception occurred
1075             */
1076            public JournalFolder[] findByUuid_PrevAndNext(long folderId, String uuid,
1077                    OrderByComparator orderByComparator)
1078                    throws NoSuchFolderException, SystemException {
1079                    JournalFolder journalFolder = findByPrimaryKey(folderId);
1080    
1081                    Session session = null;
1082    
1083                    try {
1084                            session = openSession();
1085    
1086                            JournalFolder[] array = new JournalFolderImpl[3];
1087    
1088                            array[0] = getByUuid_PrevAndNext(session, journalFolder, uuid,
1089                                            orderByComparator, true);
1090    
1091                            array[1] = journalFolder;
1092    
1093                            array[2] = getByUuid_PrevAndNext(session, journalFolder, uuid,
1094                                            orderByComparator, false);
1095    
1096                            return array;
1097                    }
1098                    catch (Exception e) {
1099                            throw processException(e);
1100                    }
1101                    finally {
1102                            closeSession(session);
1103                    }
1104            }
1105    
1106            protected JournalFolder getByUuid_PrevAndNext(Session session,
1107                    JournalFolder journalFolder, String uuid,
1108                    OrderByComparator orderByComparator, boolean previous) {
1109                    StringBundler query = null;
1110    
1111                    if (orderByComparator != null) {
1112                            query = new StringBundler(6 +
1113                                            (orderByComparator.getOrderByFields().length * 6));
1114                    }
1115                    else {
1116                            query = new StringBundler(3);
1117                    }
1118    
1119                    query.append(_SQL_SELECT_JOURNALFOLDER_WHERE);
1120    
1121                    if (uuid == null) {
1122                            query.append(_FINDER_COLUMN_UUID_UUID_1);
1123                    }
1124                    else {
1125                            if (uuid.equals(StringPool.BLANK)) {
1126                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
1127                            }
1128                            else {
1129                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
1130                            }
1131                    }
1132    
1133                    if (orderByComparator != null) {
1134                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1135    
1136                            if (orderByConditionFields.length > 0) {
1137                                    query.append(WHERE_AND);
1138                            }
1139    
1140                            for (int i = 0; i < orderByConditionFields.length; i++) {
1141                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1142                                    query.append(orderByConditionFields[i]);
1143    
1144                                    if ((i + 1) < orderByConditionFields.length) {
1145                                            if (orderByComparator.isAscending() ^ previous) {
1146                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1147                                            }
1148                                            else {
1149                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1150                                            }
1151                                    }
1152                                    else {
1153                                            if (orderByComparator.isAscending() ^ previous) {
1154                                                    query.append(WHERE_GREATER_THAN);
1155                                            }
1156                                            else {
1157                                                    query.append(WHERE_LESSER_THAN);
1158                                            }
1159                                    }
1160                            }
1161    
1162                            query.append(ORDER_BY_CLAUSE);
1163    
1164                            String[] orderByFields = orderByComparator.getOrderByFields();
1165    
1166                            for (int i = 0; i < orderByFields.length; i++) {
1167                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1168                                    query.append(orderByFields[i]);
1169    
1170                                    if ((i + 1) < orderByFields.length) {
1171                                            if (orderByComparator.isAscending() ^ previous) {
1172                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1173                                            }
1174                                            else {
1175                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1176                                            }
1177                                    }
1178                                    else {
1179                                            if (orderByComparator.isAscending() ^ previous) {
1180                                                    query.append(ORDER_BY_ASC);
1181                                            }
1182                                            else {
1183                                                    query.append(ORDER_BY_DESC);
1184                                            }
1185                                    }
1186                            }
1187                    }
1188    
1189                    else {
1190                            query.append(JournalFolderModelImpl.ORDER_BY_JPQL);
1191                    }
1192    
1193                    String sql = query.toString();
1194    
1195                    Query q = session.createQuery(sql);
1196    
1197                    q.setFirstResult(0);
1198                    q.setMaxResults(2);
1199    
1200                    QueryPos qPos = QueryPos.getInstance(q);
1201    
1202                    if (uuid != null) {
1203                            qPos.add(uuid);
1204                    }
1205    
1206                    if (orderByComparator != null) {
1207                            Object[] values = orderByComparator.getOrderByConditionValues(journalFolder);
1208    
1209                            for (Object value : values) {
1210                                    qPos.add(value);
1211                            }
1212                    }
1213    
1214                    List<JournalFolder> list = q.list();
1215    
1216                    if (list.size() == 2) {
1217                            return list.get(1);
1218                    }
1219                    else {
1220                            return null;
1221                    }
1222            }
1223    
1224            /**
1225             * Returns the journal folder where uuid = &#63; and groupId = &#63; or throws a {@link com.liferay.portlet.journal.NoSuchFolderException} if it could not be found.
1226             *
1227             * @param uuid the uuid
1228             * @param groupId the group ID
1229             * @return the matching journal folder
1230             * @throws com.liferay.portlet.journal.NoSuchFolderException if a matching journal folder could not be found
1231             * @throws SystemException if a system exception occurred
1232             */
1233            public JournalFolder findByUUID_G(String uuid, long groupId)
1234                    throws NoSuchFolderException, SystemException {
1235                    JournalFolder journalFolder = fetchByUUID_G(uuid, groupId);
1236    
1237                    if (journalFolder == null) {
1238                            StringBundler msg = new StringBundler(6);
1239    
1240                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1241    
1242                            msg.append("uuid=");
1243                            msg.append(uuid);
1244    
1245                            msg.append(", groupId=");
1246                            msg.append(groupId);
1247    
1248                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1249    
1250                            if (_log.isWarnEnabled()) {
1251                                    _log.warn(msg.toString());
1252                            }
1253    
1254                            throw new NoSuchFolderException(msg.toString());
1255                    }
1256    
1257                    return journalFolder;
1258            }
1259    
1260            /**
1261             * Returns the journal folder where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1262             *
1263             * @param uuid the uuid
1264             * @param groupId the group ID
1265             * @return the matching journal folder, or <code>null</code> if a matching journal folder could not be found
1266             * @throws SystemException if a system exception occurred
1267             */
1268            public JournalFolder fetchByUUID_G(String uuid, long groupId)
1269                    throws SystemException {
1270                    return fetchByUUID_G(uuid, groupId, true);
1271            }
1272    
1273            /**
1274             * Returns the journal folder where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1275             *
1276             * @param uuid the uuid
1277             * @param groupId the group ID
1278             * @param retrieveFromCache whether to use the finder cache
1279             * @return the matching journal folder, or <code>null</code> if a matching journal folder could not be found
1280             * @throws SystemException if a system exception occurred
1281             */
1282            public JournalFolder fetchByUUID_G(String uuid, long groupId,
1283                    boolean retrieveFromCache) throws SystemException {
1284                    Object[] finderArgs = new Object[] { uuid, groupId };
1285    
1286                    Object result = null;
1287    
1288                    if (retrieveFromCache) {
1289                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1290                                            finderArgs, this);
1291                    }
1292    
1293                    if (result instanceof JournalFolder) {
1294                            JournalFolder journalFolder = (JournalFolder)result;
1295    
1296                            if (!Validator.equals(uuid, journalFolder.getUuid()) ||
1297                                            (groupId != journalFolder.getGroupId())) {
1298                                    result = null;
1299                            }
1300                    }
1301    
1302                    if (result == null) {
1303                            StringBundler query = new StringBundler(4);
1304    
1305                            query.append(_SQL_SELECT_JOURNALFOLDER_WHERE);
1306    
1307                            if (uuid == null) {
1308                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1309                            }
1310                            else {
1311                                    if (uuid.equals(StringPool.BLANK)) {
1312                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1313                                    }
1314                                    else {
1315                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1316                                    }
1317                            }
1318    
1319                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1320    
1321                            query.append(JournalFolderModelImpl.ORDER_BY_JPQL);
1322    
1323                            String sql = query.toString();
1324    
1325                            Session session = null;
1326    
1327                            try {
1328                                    session = openSession();
1329    
1330                                    Query q = session.createQuery(sql);
1331    
1332                                    QueryPos qPos = QueryPos.getInstance(q);
1333    
1334                                    if (uuid != null) {
1335                                            qPos.add(uuid);
1336                                    }
1337    
1338                                    qPos.add(groupId);
1339    
1340                                    List<JournalFolder> list = q.list();
1341    
1342                                    result = list;
1343    
1344                                    JournalFolder journalFolder = null;
1345    
1346                                    if (list.isEmpty()) {
1347                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1348                                                    finderArgs, list);
1349                                    }
1350                                    else {
1351                                            journalFolder = list.get(0);
1352    
1353                                            cacheResult(journalFolder);
1354    
1355                                            if ((journalFolder.getUuid() == null) ||
1356                                                            !journalFolder.getUuid().equals(uuid) ||
1357                                                            (journalFolder.getGroupId() != groupId)) {
1358                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1359                                                            finderArgs, journalFolder);
1360                                            }
1361                                    }
1362    
1363                                    return journalFolder;
1364                            }
1365                            catch (Exception e) {
1366                                    throw processException(e);
1367                            }
1368                            finally {
1369                                    if (result == null) {
1370                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1371                                                    finderArgs);
1372                                    }
1373    
1374                                    closeSession(session);
1375                            }
1376                    }
1377                    else {
1378                            if (result instanceof List<?>) {
1379                                    return null;
1380                            }
1381                            else {
1382                                    return (JournalFolder)result;
1383                            }
1384                    }
1385            }
1386    
1387            /**
1388             * Returns all the journal folders where uuid = &#63; and companyId = &#63;.
1389             *
1390             * @param uuid the uuid
1391             * @param companyId the company ID
1392             * @return the matching journal folders
1393             * @throws SystemException if a system exception occurred
1394             */
1395            public List<JournalFolder> findByUuid_C(String uuid, long companyId)
1396                    throws SystemException {
1397                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1398                            QueryUtil.ALL_POS, null);
1399            }
1400    
1401            /**
1402             * Returns a range of all the journal folders where uuid = &#63; and companyId = &#63;.
1403             *
1404             * <p>
1405             * 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.
1406             * </p>
1407             *
1408             * @param uuid the uuid
1409             * @param companyId the company ID
1410             * @param start the lower bound of the range of journal folders
1411             * @param end the upper bound of the range of journal folders (not inclusive)
1412             * @return the range of matching journal folders
1413             * @throws SystemException if a system exception occurred
1414             */
1415            public List<JournalFolder> findByUuid_C(String uuid, long companyId,
1416                    int start, int end) throws SystemException {
1417                    return findByUuid_C(uuid, companyId, start, end, null);
1418            }
1419    
1420            /**
1421             * Returns an ordered range of all the journal folders where uuid = &#63; and companyId = &#63;.
1422             *
1423             * <p>
1424             * 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.
1425             * </p>
1426             *
1427             * @param uuid the uuid
1428             * @param companyId the company ID
1429             * @param start the lower bound of the range of journal folders
1430             * @param end the upper bound of the range of journal folders (not inclusive)
1431             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1432             * @return the ordered range of matching journal folders
1433             * @throws SystemException if a system exception occurred
1434             */
1435            public List<JournalFolder> findByUuid_C(String uuid, long companyId,
1436                    int start, int end, OrderByComparator orderByComparator)
1437                    throws SystemException {
1438                    FinderPath finderPath = null;
1439                    Object[] finderArgs = null;
1440    
1441                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1442                                    (orderByComparator == null)) {
1443                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1444                            finderArgs = new Object[] { uuid, companyId };
1445                    }
1446                    else {
1447                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1448                            finderArgs = new Object[] {
1449                                            uuid, companyId,
1450                                            
1451                                            start, end, orderByComparator
1452                                    };
1453                    }
1454    
1455                    List<JournalFolder> list = (List<JournalFolder>)FinderCacheUtil.getResult(finderPath,
1456                                    finderArgs, this);
1457    
1458                    if ((list != null) && !list.isEmpty()) {
1459                            for (JournalFolder journalFolder : list) {
1460                                    if (!Validator.equals(uuid, journalFolder.getUuid()) ||
1461                                                    (companyId != journalFolder.getCompanyId())) {
1462                                            list = null;
1463    
1464                                            break;
1465                                    }
1466                            }
1467                    }
1468    
1469                    if (list == null) {
1470                            StringBundler query = null;
1471    
1472                            if (orderByComparator != null) {
1473                                    query = new StringBundler(4 +
1474                                                    (orderByComparator.getOrderByFields().length * 3));
1475                            }
1476                            else {
1477                                    query = new StringBundler(4);
1478                            }
1479    
1480                            query.append(_SQL_SELECT_JOURNALFOLDER_WHERE);
1481    
1482                            if (uuid == null) {
1483                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1484                            }
1485                            else {
1486                                    if (uuid.equals(StringPool.BLANK)) {
1487                                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1488                                    }
1489                                    else {
1490                                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1491                                    }
1492                            }
1493    
1494                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1495    
1496                            if (orderByComparator != null) {
1497                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1498                                            orderByComparator);
1499                            }
1500    
1501                            else {
1502                                    query.append(JournalFolderModelImpl.ORDER_BY_JPQL);
1503                            }
1504    
1505                            String sql = query.toString();
1506    
1507                            Session session = null;
1508    
1509                            try {
1510                                    session = openSession();
1511    
1512                                    Query q = session.createQuery(sql);
1513    
1514                                    QueryPos qPos = QueryPos.getInstance(q);
1515    
1516                                    if (uuid != null) {
1517                                            qPos.add(uuid);
1518                                    }
1519    
1520                                    qPos.add(companyId);
1521    
1522                                    list = (List<JournalFolder>)QueryUtil.list(q, getDialect(),
1523                                                    start, end);
1524                            }
1525                            catch (Exception e) {
1526                                    throw processException(e);
1527                            }
1528                            finally {
1529                                    if (list == null) {
1530                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1531                                    }
1532                                    else {
1533                                            cacheResult(list);
1534    
1535                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1536                                    }
1537    
1538                                    closeSession(session);
1539                            }
1540                    }
1541    
1542                    return list;
1543            }
1544    
1545            /**
1546             * Returns the first journal folder in the ordered set where uuid = &#63; and companyId = &#63;.
1547             *
1548             * @param uuid the uuid
1549             * @param companyId the company ID
1550             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1551             * @return the first matching journal folder
1552             * @throws com.liferay.portlet.journal.NoSuchFolderException if a matching journal folder could not be found
1553             * @throws SystemException if a system exception occurred
1554             */
1555            public JournalFolder findByUuid_C_First(String uuid, long companyId,
1556                    OrderByComparator orderByComparator)
1557                    throws NoSuchFolderException, SystemException {
1558                    JournalFolder journalFolder = fetchByUuid_C_First(uuid, companyId,
1559                                    orderByComparator);
1560    
1561                    if (journalFolder != null) {
1562                            return journalFolder;
1563                    }
1564    
1565                    StringBundler msg = new StringBundler(6);
1566    
1567                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1568    
1569                    msg.append("uuid=");
1570                    msg.append(uuid);
1571    
1572                    msg.append(", companyId=");
1573                    msg.append(companyId);
1574    
1575                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1576    
1577                    throw new NoSuchFolderException(msg.toString());
1578            }
1579    
1580            /**
1581             * Returns the first journal folder in the ordered set where uuid = &#63; and companyId = &#63;.
1582             *
1583             * @param uuid the uuid
1584             * @param companyId the company ID
1585             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1586             * @return the first matching journal folder, or <code>null</code> if a matching journal folder could not be found
1587             * @throws SystemException if a system exception occurred
1588             */
1589            public JournalFolder fetchByUuid_C_First(String uuid, long companyId,
1590                    OrderByComparator orderByComparator) throws SystemException {
1591                    List<JournalFolder> list = findByUuid_C(uuid, companyId, 0, 1,
1592                                    orderByComparator);
1593    
1594                    if (!list.isEmpty()) {
1595                            return list.get(0);
1596                    }
1597    
1598                    return null;
1599            }
1600    
1601            /**
1602             * Returns the last journal folder in the ordered set where uuid = &#63; and companyId = &#63;.
1603             *
1604             * @param uuid the uuid
1605             * @param companyId the company ID
1606             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1607             * @return the last matching journal folder
1608             * @throws com.liferay.portlet.journal.NoSuchFolderException if a matching journal folder could not be found
1609             * @throws SystemException if a system exception occurred
1610             */
1611            public JournalFolder findByUuid_C_Last(String uuid, long companyId,
1612                    OrderByComparator orderByComparator)
1613                    throws NoSuchFolderException, SystemException {
1614                    JournalFolder journalFolder = fetchByUuid_C_Last(uuid, companyId,
1615                                    orderByComparator);
1616    
1617                    if (journalFolder != null) {
1618                            return journalFolder;
1619                    }
1620    
1621                    StringBundler msg = new StringBundler(6);
1622    
1623                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1624    
1625                    msg.append("uuid=");
1626                    msg.append(uuid);
1627    
1628                    msg.append(", companyId=");
1629                    msg.append(companyId);
1630    
1631                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1632    
1633                    throw new NoSuchFolderException(msg.toString());
1634            }
1635    
1636            /**
1637             * Returns the last journal folder in the ordered set where uuid = &#63; and companyId = &#63;.
1638             *
1639             * @param uuid the uuid
1640             * @param companyId the company ID
1641             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1642             * @return the last matching journal folder, or <code>null</code> if a matching journal folder could not be found
1643             * @throws SystemException if a system exception occurred
1644             */
1645            public JournalFolder fetchByUuid_C_Last(String uuid, long companyId,
1646                    OrderByComparator orderByComparator) throws SystemException {
1647                    int count = countByUuid_C(uuid, companyId);
1648    
1649                    List<JournalFolder> list = findByUuid_C(uuid, companyId, count - 1,
1650                                    count, orderByComparator);
1651    
1652                    if (!list.isEmpty()) {
1653                            return list.get(0);
1654                    }
1655    
1656                    return null;
1657            }
1658    
1659            /**
1660             * Returns the journal folders before and after the current journal folder in the ordered set where uuid = &#63; and companyId = &#63;.
1661             *
1662             * @param folderId the primary key of the current journal folder
1663             * @param uuid the uuid
1664             * @param companyId the company ID
1665             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1666             * @return the previous, current, and next journal folder
1667             * @throws com.liferay.portlet.journal.NoSuchFolderException if a journal folder with the primary key could not be found
1668             * @throws SystemException if a system exception occurred
1669             */
1670            public JournalFolder[] findByUuid_C_PrevAndNext(long folderId, String uuid,
1671                    long companyId, OrderByComparator orderByComparator)
1672                    throws NoSuchFolderException, SystemException {
1673                    JournalFolder journalFolder = findByPrimaryKey(folderId);
1674    
1675                    Session session = null;
1676    
1677                    try {
1678                            session = openSession();
1679    
1680                            JournalFolder[] array = new JournalFolderImpl[3];
1681    
1682                            array[0] = getByUuid_C_PrevAndNext(session, journalFolder, uuid,
1683                                            companyId, orderByComparator, true);
1684    
1685                            array[1] = journalFolder;
1686    
1687                            array[2] = getByUuid_C_PrevAndNext(session, journalFolder, uuid,
1688                                            companyId, orderByComparator, false);
1689    
1690                            return array;
1691                    }
1692                    catch (Exception e) {
1693                            throw processException(e);
1694                    }
1695                    finally {
1696                            closeSession(session);
1697                    }
1698            }
1699    
1700            protected JournalFolder getByUuid_C_PrevAndNext(Session session,
1701                    JournalFolder journalFolder, String uuid, long companyId,
1702                    OrderByComparator orderByComparator, boolean previous) {
1703                    StringBundler query = null;
1704    
1705                    if (orderByComparator != null) {
1706                            query = new StringBundler(6 +
1707                                            (orderByComparator.getOrderByFields().length * 6));
1708                    }
1709                    else {
1710                            query = new StringBundler(3);
1711                    }
1712    
1713                    query.append(_SQL_SELECT_JOURNALFOLDER_WHERE);
1714    
1715                    if (uuid == null) {
1716                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1717                    }
1718                    else {
1719                            if (uuid.equals(StringPool.BLANK)) {
1720                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1721                            }
1722                            else {
1723                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1724                            }
1725                    }
1726    
1727                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1728    
1729                    if (orderByComparator != null) {
1730                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1731    
1732                            if (orderByConditionFields.length > 0) {
1733                                    query.append(WHERE_AND);
1734                            }
1735    
1736                            for (int i = 0; i < orderByConditionFields.length; i++) {
1737                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1738                                    query.append(orderByConditionFields[i]);
1739    
1740                                    if ((i + 1) < orderByConditionFields.length) {
1741                                            if (orderByComparator.isAscending() ^ previous) {
1742                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1743                                            }
1744                                            else {
1745                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1746                                            }
1747                                    }
1748                                    else {
1749                                            if (orderByComparator.isAscending() ^ previous) {
1750                                                    query.append(WHERE_GREATER_THAN);
1751                                            }
1752                                            else {
1753                                                    query.append(WHERE_LESSER_THAN);
1754                                            }
1755                                    }
1756                            }
1757    
1758                            query.append(ORDER_BY_CLAUSE);
1759    
1760                            String[] orderByFields = orderByComparator.getOrderByFields();
1761    
1762                            for (int i = 0; i < orderByFields.length; i++) {
1763                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1764                                    query.append(orderByFields[i]);
1765    
1766                                    if ((i + 1) < orderByFields.length) {
1767                                            if (orderByComparator.isAscending() ^ previous) {
1768                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1769                                            }
1770                                            else {
1771                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1772                                            }
1773                                    }
1774                                    else {
1775                                            if (orderByComparator.isAscending() ^ previous) {
1776                                                    query.append(ORDER_BY_ASC);
1777                                            }
1778                                            else {
1779                                                    query.append(ORDER_BY_DESC);
1780                                            }
1781                                    }
1782                            }
1783                    }
1784    
1785                    else {
1786                            query.append(JournalFolderModelImpl.ORDER_BY_JPQL);
1787                    }
1788    
1789                    String sql = query.toString();
1790    
1791                    Query q = session.createQuery(sql);
1792    
1793                    q.setFirstResult(0);
1794                    q.setMaxResults(2);
1795    
1796                    QueryPos qPos = QueryPos.getInstance(q);
1797    
1798                    if (uuid != null) {
1799                            qPos.add(uuid);
1800                    }
1801    
1802                    qPos.add(companyId);
1803    
1804                    if (orderByComparator != null) {
1805                            Object[] values = orderByComparator.getOrderByConditionValues(journalFolder);
1806    
1807                            for (Object value : values) {
1808                                    qPos.add(value);
1809                            }
1810                    }
1811    
1812                    List<JournalFolder> list = q.list();
1813    
1814                    if (list.size() == 2) {
1815                            return list.get(1);
1816                    }
1817                    else {
1818                            return null;
1819                    }
1820            }
1821    
1822            /**
1823             * Returns all the journal folders where groupId = &#63;.
1824             *
1825             * @param groupId the group ID
1826             * @return the matching journal folders
1827             * @throws SystemException if a system exception occurred
1828             */
1829            public List<JournalFolder> findByGroupId(long groupId)
1830                    throws SystemException {
1831                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1832            }
1833    
1834            /**
1835             * Returns a range of all the journal folders where groupId = &#63;.
1836             *
1837             * <p>
1838             * 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.
1839             * </p>
1840             *
1841             * @param groupId the group ID
1842             * @param start the lower bound of the range of journal folders
1843             * @param end the upper bound of the range of journal folders (not inclusive)
1844             * @return the range of matching journal folders
1845             * @throws SystemException if a system exception occurred
1846             */
1847            public List<JournalFolder> findByGroupId(long groupId, int start, int end)
1848                    throws SystemException {
1849                    return findByGroupId(groupId, start, end, null);
1850            }
1851    
1852            /**
1853             * Returns an ordered range of all the journal folders where groupId = &#63;.
1854             *
1855             * <p>
1856             * 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.
1857             * </p>
1858             *
1859             * @param groupId the group ID
1860             * @param start the lower bound of the range of journal folders
1861             * @param end the upper bound of the range of journal folders (not inclusive)
1862             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1863             * @return the ordered range of matching journal folders
1864             * @throws SystemException if a system exception occurred
1865             */
1866            public List<JournalFolder> findByGroupId(long groupId, int start, int end,
1867                    OrderByComparator orderByComparator) throws SystemException {
1868                    FinderPath finderPath = null;
1869                    Object[] finderArgs = null;
1870    
1871                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1872                                    (orderByComparator == null)) {
1873                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1874                            finderArgs = new Object[] { groupId };
1875                    }
1876                    else {
1877                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1878                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1879                    }
1880    
1881                    List<JournalFolder> list = (List<JournalFolder>)FinderCacheUtil.getResult(finderPath,
1882                                    finderArgs, this);
1883    
1884                    if ((list != null) && !list.isEmpty()) {
1885                            for (JournalFolder journalFolder : list) {
1886                                    if ((groupId != journalFolder.getGroupId())) {
1887                                            list = null;
1888    
1889                                            break;
1890                                    }
1891                            }
1892                    }
1893    
1894                    if (list == null) {
1895                            StringBundler query = null;
1896    
1897                            if (orderByComparator != null) {
1898                                    query = new StringBundler(3 +
1899                                                    (orderByComparator.getOrderByFields().length * 3));
1900                            }
1901                            else {
1902                                    query = new StringBundler(3);
1903                            }
1904    
1905                            query.append(_SQL_SELECT_JOURNALFOLDER_WHERE);
1906    
1907                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1908    
1909                            if (orderByComparator != null) {
1910                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1911                                            orderByComparator);
1912                            }
1913    
1914                            else {
1915                                    query.append(JournalFolderModelImpl.ORDER_BY_JPQL);
1916                            }
1917    
1918                            String sql = query.toString();
1919    
1920                            Session session = null;
1921    
1922                            try {
1923                                    session = openSession();
1924    
1925                                    Query q = session.createQuery(sql);
1926    
1927                                    QueryPos qPos = QueryPos.getInstance(q);
1928    
1929                                    qPos.add(groupId);
1930    
1931                                    list = (List<JournalFolder>)QueryUtil.list(q, getDialect(),
1932                                                    start, end);
1933                            }
1934                            catch (Exception e) {
1935                                    throw processException(e);
1936                            }
1937                            finally {
1938                                    if (list == null) {
1939                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1940                                    }
1941                                    else {
1942                                            cacheResult(list);
1943    
1944                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1945                                    }
1946    
1947                                    closeSession(session);
1948                            }
1949                    }
1950    
1951                    return list;
1952            }
1953    
1954            /**
1955             * Returns the first journal folder in the ordered set where groupId = &#63;.
1956             *
1957             * @param groupId the group ID
1958             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1959             * @return the first matching journal folder
1960             * @throws com.liferay.portlet.journal.NoSuchFolderException if a matching journal folder could not be found
1961             * @throws SystemException if a system exception occurred
1962             */
1963            public JournalFolder findByGroupId_First(long groupId,
1964                    OrderByComparator orderByComparator)
1965                    throws NoSuchFolderException, SystemException {
1966                    JournalFolder journalFolder = fetchByGroupId_First(groupId,
1967                                    orderByComparator);
1968    
1969                    if (journalFolder != null) {
1970                            return journalFolder;
1971                    }
1972    
1973                    StringBundler msg = new StringBundler(4);
1974    
1975                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1976    
1977                    msg.append("groupId=");
1978                    msg.append(groupId);
1979    
1980                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1981    
1982                    throw new NoSuchFolderException(msg.toString());
1983            }
1984    
1985            /**
1986             * Returns the first journal folder in the ordered set where groupId = &#63;.
1987             *
1988             * @param groupId the group ID
1989             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1990             * @return the first matching journal folder, or <code>null</code> if a matching journal folder could not be found
1991             * @throws SystemException if a system exception occurred
1992             */
1993            public JournalFolder fetchByGroupId_First(long groupId,
1994                    OrderByComparator orderByComparator) throws SystemException {
1995                    List<JournalFolder> list = findByGroupId(groupId, 0, 1,
1996                                    orderByComparator);
1997    
1998                    if (!list.isEmpty()) {
1999                            return list.get(0);
2000                    }
2001    
2002                    return null;
2003            }
2004    
2005            /**
2006             * Returns the last journal folder in the ordered set where groupId = &#63;.
2007             *
2008             * @param groupId the group ID
2009             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2010             * @return the last matching journal folder
2011             * @throws com.liferay.portlet.journal.NoSuchFolderException if a matching journal folder could not be found
2012             * @throws SystemException if a system exception occurred
2013             */
2014            public JournalFolder findByGroupId_Last(long groupId,
2015                    OrderByComparator orderByComparator)
2016                    throws NoSuchFolderException, SystemException {
2017                    JournalFolder journalFolder = fetchByGroupId_Last(groupId,
2018                                    orderByComparator);
2019    
2020                    if (journalFolder != null) {
2021                            return journalFolder;
2022                    }
2023    
2024                    StringBundler msg = new StringBundler(4);
2025    
2026                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2027    
2028                    msg.append("groupId=");
2029                    msg.append(groupId);
2030    
2031                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2032    
2033                    throw new NoSuchFolderException(msg.toString());
2034            }
2035    
2036            /**
2037             * Returns the last journal folder in the ordered set where groupId = &#63;.
2038             *
2039             * @param groupId the group ID
2040             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2041             * @return the last matching journal folder, or <code>null</code> if a matching journal folder could not be found
2042             * @throws SystemException if a system exception occurred
2043             */
2044            public JournalFolder fetchByGroupId_Last(long groupId,
2045                    OrderByComparator orderByComparator) throws SystemException {
2046                    int count = countByGroupId(groupId);
2047    
2048                    List<JournalFolder> list = findByGroupId(groupId, count - 1, count,
2049                                    orderByComparator);
2050    
2051                    if (!list.isEmpty()) {
2052                            return list.get(0);
2053                    }
2054    
2055                    return null;
2056            }
2057    
2058            /**
2059             * Returns the journal folders before and after the current journal folder in the ordered set where groupId = &#63;.
2060             *
2061             * @param folderId the primary key of the current journal folder
2062             * @param groupId the group ID
2063             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2064             * @return the previous, current, and next journal folder
2065             * @throws com.liferay.portlet.journal.NoSuchFolderException if a journal folder with the primary key could not be found
2066             * @throws SystemException if a system exception occurred
2067             */
2068            public JournalFolder[] findByGroupId_PrevAndNext(long folderId,
2069                    long groupId, OrderByComparator orderByComparator)
2070                    throws NoSuchFolderException, SystemException {
2071                    JournalFolder journalFolder = findByPrimaryKey(folderId);
2072    
2073                    Session session = null;
2074    
2075                    try {
2076                            session = openSession();
2077    
2078                            JournalFolder[] array = new JournalFolderImpl[3];
2079    
2080                            array[0] = getByGroupId_PrevAndNext(session, journalFolder,
2081                                            groupId, orderByComparator, true);
2082    
2083                            array[1] = journalFolder;
2084    
2085                            array[2] = getByGroupId_PrevAndNext(session, journalFolder,
2086                                            groupId, orderByComparator, false);
2087    
2088                            return array;
2089                    }
2090                    catch (Exception e) {
2091                            throw processException(e);
2092                    }
2093                    finally {
2094                            closeSession(session);
2095                    }
2096            }
2097    
2098            protected JournalFolder getByGroupId_PrevAndNext(Session session,
2099                    JournalFolder journalFolder, long groupId,
2100                    OrderByComparator orderByComparator, boolean previous) {
2101                    StringBundler query = null;
2102    
2103                    if (orderByComparator != null) {
2104                            query = new StringBundler(6 +
2105                                            (orderByComparator.getOrderByFields().length * 6));
2106                    }
2107                    else {
2108                            query = new StringBundler(3);
2109                    }
2110    
2111                    query.append(_SQL_SELECT_JOURNALFOLDER_WHERE);
2112    
2113                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2114    
2115                    if (orderByComparator != null) {
2116                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2117    
2118                            if (orderByConditionFields.length > 0) {
2119                                    query.append(WHERE_AND);
2120                            }
2121    
2122                            for (int i = 0; i < orderByConditionFields.length; i++) {
2123                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2124                                    query.append(orderByConditionFields[i]);
2125    
2126                                    if ((i + 1) < orderByConditionFields.length) {
2127                                            if (orderByComparator.isAscending() ^ previous) {
2128                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2129                                            }
2130                                            else {
2131                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2132                                            }
2133                                    }
2134                                    else {
2135                                            if (orderByComparator.isAscending() ^ previous) {
2136                                                    query.append(WHERE_GREATER_THAN);
2137                                            }
2138                                            else {
2139                                                    query.append(WHERE_LESSER_THAN);
2140                                            }
2141                                    }
2142                            }
2143    
2144                            query.append(ORDER_BY_CLAUSE);
2145    
2146                            String[] orderByFields = orderByComparator.getOrderByFields();
2147    
2148                            for (int i = 0; i < orderByFields.length; i++) {
2149                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2150                                    query.append(orderByFields[i]);
2151    
2152                                    if ((i + 1) < orderByFields.length) {
2153                                            if (orderByComparator.isAscending() ^ previous) {
2154                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2155                                            }
2156                                            else {
2157                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2158                                            }
2159                                    }
2160                                    else {
2161                                            if (orderByComparator.isAscending() ^ previous) {
2162                                                    query.append(ORDER_BY_ASC);
2163                                            }
2164                                            else {
2165                                                    query.append(ORDER_BY_DESC);
2166                                            }
2167                                    }
2168                            }
2169                    }
2170    
2171                    else {
2172                            query.append(JournalFolderModelImpl.ORDER_BY_JPQL);
2173                    }
2174    
2175                    String sql = query.toString();
2176    
2177                    Query q = session.createQuery(sql);
2178    
2179                    q.setFirstResult(0);
2180                    q.setMaxResults(2);
2181    
2182                    QueryPos qPos = QueryPos.getInstance(q);
2183    
2184                    qPos.add(groupId);
2185    
2186                    if (orderByComparator != null) {
2187                            Object[] values = orderByComparator.getOrderByConditionValues(journalFolder);
2188    
2189                            for (Object value : values) {
2190                                    qPos.add(value);
2191                            }
2192                    }
2193    
2194                    List<JournalFolder> list = q.list();
2195    
2196                    if (list.size() == 2) {
2197                            return list.get(1);
2198                    }
2199                    else {
2200                            return null;
2201                    }
2202            }
2203    
2204            /**
2205             * Returns all the journal folders that the user has permission to view where groupId = &#63;.
2206             *
2207             * @param groupId the group ID
2208             * @return the matching journal folders that the user has permission to view
2209             * @throws SystemException if a system exception occurred
2210             */
2211            public List<JournalFolder> filterFindByGroupId(long groupId)
2212                    throws SystemException {
2213                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
2214                            QueryUtil.ALL_POS, null);
2215            }
2216    
2217            /**
2218             * Returns a range of all the journal folders that the user has permission to view where groupId = &#63;.
2219             *
2220             * <p>
2221             * 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.
2222             * </p>
2223             *
2224             * @param groupId the group ID
2225             * @param start the lower bound of the range of journal folders
2226             * @param end the upper bound of the range of journal folders (not inclusive)
2227             * @return the range of matching journal folders that the user has permission to view
2228             * @throws SystemException if a system exception occurred
2229             */
2230            public List<JournalFolder> filterFindByGroupId(long groupId, int start,
2231                    int end) throws SystemException {
2232                    return filterFindByGroupId(groupId, start, end, null);
2233            }
2234    
2235            /**
2236             * Returns an ordered range of all the journal folders that the user has permissions to view where groupId = &#63;.
2237             *
2238             * <p>
2239             * 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.
2240             * </p>
2241             *
2242             * @param groupId the group ID
2243             * @param start the lower bound of the range of journal folders
2244             * @param end the upper bound of the range of journal folders (not inclusive)
2245             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2246             * @return the ordered range of matching journal folders that the user has permission to view
2247             * @throws SystemException if a system exception occurred
2248             */
2249            public List<JournalFolder> filterFindByGroupId(long groupId, int start,
2250                    int end, OrderByComparator orderByComparator) throws SystemException {
2251                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2252                            return findByGroupId(groupId, start, end, orderByComparator);
2253                    }
2254    
2255                    StringBundler query = null;
2256    
2257                    if (orderByComparator != null) {
2258                            query = new StringBundler(3 +
2259                                            (orderByComparator.getOrderByFields().length * 3));
2260                    }
2261                    else {
2262                            query = new StringBundler(3);
2263                    }
2264    
2265                    if (getDB().isSupportsInlineDistinct()) {
2266                            query.append(_FILTER_SQL_SELECT_JOURNALFOLDER_WHERE);
2267                    }
2268                    else {
2269                            query.append(_FILTER_SQL_SELECT_JOURNALFOLDER_NO_INLINE_DISTINCT_WHERE_1);
2270                    }
2271    
2272                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2273    
2274                    if (!getDB().isSupportsInlineDistinct()) {
2275                            query.append(_FILTER_SQL_SELECT_JOURNALFOLDER_NO_INLINE_DISTINCT_WHERE_2);
2276                    }
2277    
2278                    if (orderByComparator != null) {
2279                            if (getDB().isSupportsInlineDistinct()) {
2280                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2281                                            orderByComparator);
2282                            }
2283                            else {
2284                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2285                                            orderByComparator);
2286                            }
2287                    }
2288    
2289                    else {
2290                            if (getDB().isSupportsInlineDistinct()) {
2291                                    query.append(JournalFolderModelImpl.ORDER_BY_JPQL);
2292                            }
2293                            else {
2294                                    query.append(JournalFolderModelImpl.ORDER_BY_SQL);
2295                            }
2296                    }
2297    
2298                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2299                                    JournalFolder.class.getName(),
2300                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2301    
2302                    Session session = null;
2303    
2304                    try {
2305                            session = openSession();
2306    
2307                            SQLQuery q = session.createSQLQuery(sql);
2308    
2309                            if (getDB().isSupportsInlineDistinct()) {
2310                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalFolderImpl.class);
2311                            }
2312                            else {
2313                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalFolderImpl.class);
2314                            }
2315    
2316                            QueryPos qPos = QueryPos.getInstance(q);
2317    
2318                            qPos.add(groupId);
2319    
2320                            return (List<JournalFolder>)QueryUtil.list(q, getDialect(), start,
2321                                    end);
2322                    }
2323                    catch (Exception e) {
2324                            throw processException(e);
2325                    }
2326                    finally {
2327                            closeSession(session);
2328                    }
2329            }
2330    
2331            /**
2332             * Returns the journal folders before and after the current journal folder in the ordered set of journal folders that the user has permission to view where groupId = &#63;.
2333             *
2334             * @param folderId the primary key of the current journal folder
2335             * @param groupId the group ID
2336             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2337             * @return the previous, current, and next journal folder
2338             * @throws com.liferay.portlet.journal.NoSuchFolderException if a journal folder with the primary key could not be found
2339             * @throws SystemException if a system exception occurred
2340             */
2341            public JournalFolder[] filterFindByGroupId_PrevAndNext(long folderId,
2342                    long groupId, OrderByComparator orderByComparator)
2343                    throws NoSuchFolderException, SystemException {
2344                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2345                            return findByGroupId_PrevAndNext(folderId, groupId,
2346                                    orderByComparator);
2347                    }
2348    
2349                    JournalFolder journalFolder = findByPrimaryKey(folderId);
2350    
2351                    Session session = null;
2352    
2353                    try {
2354                            session = openSession();
2355    
2356                            JournalFolder[] array = new JournalFolderImpl[3];
2357    
2358                            array[0] = filterGetByGroupId_PrevAndNext(session, journalFolder,
2359                                            groupId, orderByComparator, true);
2360    
2361                            array[1] = journalFolder;
2362    
2363                            array[2] = filterGetByGroupId_PrevAndNext(session, journalFolder,
2364                                            groupId, orderByComparator, false);
2365    
2366                            return array;
2367                    }
2368                    catch (Exception e) {
2369                            throw processException(e);
2370                    }
2371                    finally {
2372                            closeSession(session);
2373                    }
2374            }
2375    
2376            protected JournalFolder filterGetByGroupId_PrevAndNext(Session session,
2377                    JournalFolder journalFolder, long groupId,
2378                    OrderByComparator orderByComparator, boolean previous) {
2379                    StringBundler query = null;
2380    
2381                    if (orderByComparator != null) {
2382                            query = new StringBundler(6 +
2383                                            (orderByComparator.getOrderByFields().length * 6));
2384                    }
2385                    else {
2386                            query = new StringBundler(3);
2387                    }
2388    
2389                    if (getDB().isSupportsInlineDistinct()) {
2390                            query.append(_FILTER_SQL_SELECT_JOURNALFOLDER_WHERE);
2391                    }
2392                    else {
2393                            query.append(_FILTER_SQL_SELECT_JOURNALFOLDER_NO_INLINE_DISTINCT_WHERE_1);
2394                    }
2395    
2396                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2397    
2398                    if (!getDB().isSupportsInlineDistinct()) {
2399                            query.append(_FILTER_SQL_SELECT_JOURNALFOLDER_NO_INLINE_DISTINCT_WHERE_2);
2400                    }
2401    
2402                    if (orderByComparator != null) {
2403                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2404    
2405                            if (orderByConditionFields.length > 0) {
2406                                    query.append(WHERE_AND);
2407                            }
2408    
2409                            for (int i = 0; i < orderByConditionFields.length; i++) {
2410                                    if (getDB().isSupportsInlineDistinct()) {
2411                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2412                                    }
2413                                    else {
2414                                            query.append(_ORDER_BY_ENTITY_TABLE);
2415                                    }
2416    
2417                                    query.append(orderByConditionFields[i]);
2418    
2419                                    if ((i + 1) < orderByConditionFields.length) {
2420                                            if (orderByComparator.isAscending() ^ previous) {
2421                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2422                                            }
2423                                            else {
2424                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2425                                            }
2426                                    }
2427                                    else {
2428                                            if (orderByComparator.isAscending() ^ previous) {
2429                                                    query.append(WHERE_GREATER_THAN);
2430                                            }
2431                                            else {
2432                                                    query.append(WHERE_LESSER_THAN);
2433                                            }
2434                                    }
2435                            }
2436    
2437                            query.append(ORDER_BY_CLAUSE);
2438    
2439                            String[] orderByFields = orderByComparator.getOrderByFields();
2440    
2441                            for (int i = 0; i < orderByFields.length; i++) {
2442                                    if (getDB().isSupportsInlineDistinct()) {
2443                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2444                                    }
2445                                    else {
2446                                            query.append(_ORDER_BY_ENTITY_TABLE);
2447                                    }
2448    
2449                                    query.append(orderByFields[i]);
2450    
2451                                    if ((i + 1) < orderByFields.length) {
2452                                            if (orderByComparator.isAscending() ^ previous) {
2453                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2454                                            }
2455                                            else {
2456                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2457                                            }
2458                                    }
2459                                    else {
2460                                            if (orderByComparator.isAscending() ^ previous) {
2461                                                    query.append(ORDER_BY_ASC);
2462                                            }
2463                                            else {
2464                                                    query.append(ORDER_BY_DESC);
2465                                            }
2466                                    }
2467                            }
2468                    }
2469    
2470                    else {
2471                            if (getDB().isSupportsInlineDistinct()) {
2472                                    query.append(JournalFolderModelImpl.ORDER_BY_JPQL);
2473                            }
2474                            else {
2475                                    query.append(JournalFolderModelImpl.ORDER_BY_SQL);
2476                            }
2477                    }
2478    
2479                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2480                                    JournalFolder.class.getName(),
2481                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2482    
2483                    SQLQuery q = session.createSQLQuery(sql);
2484    
2485                    q.setFirstResult(0);
2486                    q.setMaxResults(2);
2487    
2488                    if (getDB().isSupportsInlineDistinct()) {
2489                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalFolderImpl.class);
2490                    }
2491                    else {
2492                            q.addEntity(_FILTER_ENTITY_TABLE, JournalFolderImpl.class);
2493                    }
2494    
2495                    QueryPos qPos = QueryPos.getInstance(q);
2496    
2497                    qPos.add(groupId);
2498    
2499                    if (orderByComparator != null) {
2500                            Object[] values = orderByComparator.getOrderByConditionValues(journalFolder);
2501    
2502                            for (Object value : values) {
2503                                    qPos.add(value);
2504                            }
2505                    }
2506    
2507                    List<JournalFolder> list = q.list();
2508    
2509                    if (list.size() == 2) {
2510                            return list.get(1);
2511                    }
2512                    else {
2513                            return null;
2514                    }
2515            }
2516    
2517            /**
2518             * Returns all the journal folders where companyId = &#63;.
2519             *
2520             * @param companyId the company ID
2521             * @return the matching journal folders
2522             * @throws SystemException if a system exception occurred
2523             */
2524            public List<JournalFolder> findByCompanyId(long companyId)
2525                    throws SystemException {
2526                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2527                            null);
2528            }
2529    
2530            /**
2531             * Returns a range of all the journal folders where companyId = &#63;.
2532             *
2533             * <p>
2534             * 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.
2535             * </p>
2536             *
2537             * @param companyId the company ID
2538             * @param start the lower bound of the range of journal folders
2539             * @param end the upper bound of the range of journal folders (not inclusive)
2540             * @return the range of matching journal folders
2541             * @throws SystemException if a system exception occurred
2542             */
2543            public List<JournalFolder> findByCompanyId(long companyId, int start,
2544                    int end) throws SystemException {
2545                    return findByCompanyId(companyId, start, end, null);
2546            }
2547    
2548            /**
2549             * Returns an ordered range of all the journal folders where companyId = &#63;.
2550             *
2551             * <p>
2552             * 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.
2553             * </p>
2554             *
2555             * @param companyId the company ID
2556             * @param start the lower bound of the range of journal folders
2557             * @param end the upper bound of the range of journal folders (not inclusive)
2558             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2559             * @return the ordered range of matching journal folders
2560             * @throws SystemException if a system exception occurred
2561             */
2562            public List<JournalFolder> findByCompanyId(long companyId, int start,
2563                    int end, OrderByComparator orderByComparator) throws SystemException {
2564                    FinderPath finderPath = null;
2565                    Object[] finderArgs = null;
2566    
2567                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2568                                    (orderByComparator == null)) {
2569                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2570                            finderArgs = new Object[] { companyId };
2571                    }
2572                    else {
2573                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2574                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
2575                    }
2576    
2577                    List<JournalFolder> list = (List<JournalFolder>)FinderCacheUtil.getResult(finderPath,
2578                                    finderArgs, this);
2579    
2580                    if ((list != null) && !list.isEmpty()) {
2581                            for (JournalFolder journalFolder : list) {
2582                                    if ((companyId != journalFolder.getCompanyId())) {
2583                                            list = null;
2584    
2585                                            break;
2586                                    }
2587                            }
2588                    }
2589    
2590                    if (list == null) {
2591                            StringBundler query = null;
2592    
2593                            if (orderByComparator != null) {
2594                                    query = new StringBundler(3 +
2595                                                    (orderByComparator.getOrderByFields().length * 3));
2596                            }
2597                            else {
2598                                    query = new StringBundler(3);
2599                            }
2600    
2601                            query.append(_SQL_SELECT_JOURNALFOLDER_WHERE);
2602    
2603                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2604    
2605                            if (orderByComparator != null) {
2606                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2607                                            orderByComparator);
2608                            }
2609    
2610                            else {
2611                                    query.append(JournalFolderModelImpl.ORDER_BY_JPQL);
2612                            }
2613    
2614                            String sql = query.toString();
2615    
2616                            Session session = null;
2617    
2618                            try {
2619                                    session = openSession();
2620    
2621                                    Query q = session.createQuery(sql);
2622    
2623                                    QueryPos qPos = QueryPos.getInstance(q);
2624    
2625                                    qPos.add(companyId);
2626    
2627                                    list = (List<JournalFolder>)QueryUtil.list(q, getDialect(),
2628                                                    start, end);
2629                            }
2630                            catch (Exception e) {
2631                                    throw processException(e);
2632                            }
2633                            finally {
2634                                    if (list == null) {
2635                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2636                                    }
2637                                    else {
2638                                            cacheResult(list);
2639    
2640                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2641                                    }
2642    
2643                                    closeSession(session);
2644                            }
2645                    }
2646    
2647                    return list;
2648            }
2649    
2650            /**
2651             * Returns the first journal folder in the ordered set where companyId = &#63;.
2652             *
2653             * @param companyId the company ID
2654             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2655             * @return the first matching journal folder
2656             * @throws com.liferay.portlet.journal.NoSuchFolderException if a matching journal folder could not be found
2657             * @throws SystemException if a system exception occurred
2658             */
2659            public JournalFolder findByCompanyId_First(long companyId,
2660                    OrderByComparator orderByComparator)
2661                    throws NoSuchFolderException, SystemException {
2662                    JournalFolder journalFolder = fetchByCompanyId_First(companyId,
2663                                    orderByComparator);
2664    
2665                    if (journalFolder != null) {
2666                            return journalFolder;
2667                    }
2668    
2669                    StringBundler msg = new StringBundler(4);
2670    
2671                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2672    
2673                    msg.append("companyId=");
2674                    msg.append(companyId);
2675    
2676                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2677    
2678                    throw new NoSuchFolderException(msg.toString());
2679            }
2680    
2681            /**
2682             * Returns the first journal folder in the ordered set where companyId = &#63;.
2683             *
2684             * @param companyId the company ID
2685             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2686             * @return the first matching journal folder, or <code>null</code> if a matching journal folder could not be found
2687             * @throws SystemException if a system exception occurred
2688             */
2689            public JournalFolder fetchByCompanyId_First(long companyId,
2690                    OrderByComparator orderByComparator) throws SystemException {
2691                    List<JournalFolder> list = findByCompanyId(companyId, 0, 1,
2692                                    orderByComparator);
2693    
2694                    if (!list.isEmpty()) {
2695                            return list.get(0);
2696                    }
2697    
2698                    return null;
2699            }
2700    
2701            /**
2702             * Returns the last journal folder in the ordered set where companyId = &#63;.
2703             *
2704             * @param companyId the company ID
2705             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2706             * @return the last matching journal folder
2707             * @throws com.liferay.portlet.journal.NoSuchFolderException if a matching journal folder could not be found
2708             * @throws SystemException if a system exception occurred
2709             */
2710            public JournalFolder findByCompanyId_Last(long companyId,
2711                    OrderByComparator orderByComparator)
2712                    throws NoSuchFolderException, SystemException {
2713                    JournalFolder journalFolder = fetchByCompanyId_Last(companyId,
2714                                    orderByComparator);
2715    
2716                    if (journalFolder != null) {
2717                            return journalFolder;
2718                    }
2719    
2720                    StringBundler msg = new StringBundler(4);
2721    
2722                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2723    
2724                    msg.append("companyId=");
2725                    msg.append(companyId);
2726    
2727                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2728    
2729                    throw new NoSuchFolderException(msg.toString());
2730            }
2731    
2732            /**
2733             * Returns the last journal folder in the ordered set where companyId = &#63;.
2734             *
2735             * @param companyId the company ID
2736             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2737             * @return the last matching journal folder, or <code>null</code> if a matching journal folder could not be found
2738             * @throws SystemException if a system exception occurred
2739             */
2740            public JournalFolder fetchByCompanyId_Last(long companyId,
2741                    OrderByComparator orderByComparator) throws SystemException {
2742                    int count = countByCompanyId(companyId);
2743    
2744                    List<JournalFolder> list = findByCompanyId(companyId, count - 1, count,
2745                                    orderByComparator);
2746    
2747                    if (!list.isEmpty()) {
2748                            return list.get(0);
2749                    }
2750    
2751                    return null;
2752            }
2753    
2754            /**
2755             * Returns the journal folders before and after the current journal folder in the ordered set where companyId = &#63;.
2756             *
2757             * @param folderId the primary key of the current journal folder
2758             * @param companyId the company ID
2759             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2760             * @return the previous, current, and next journal folder
2761             * @throws com.liferay.portlet.journal.NoSuchFolderException if a journal folder with the primary key could not be found
2762             * @throws SystemException if a system exception occurred
2763             */
2764            public JournalFolder[] findByCompanyId_PrevAndNext(long folderId,
2765                    long companyId, OrderByComparator orderByComparator)
2766                    throws NoSuchFolderException, SystemException {
2767                    JournalFolder journalFolder = findByPrimaryKey(folderId);
2768    
2769                    Session session = null;
2770    
2771                    try {
2772                            session = openSession();
2773    
2774                            JournalFolder[] array = new JournalFolderImpl[3];
2775    
2776                            array[0] = getByCompanyId_PrevAndNext(session, journalFolder,
2777                                            companyId, orderByComparator, true);
2778    
2779                            array[1] = journalFolder;
2780    
2781                            array[2] = getByCompanyId_PrevAndNext(session, journalFolder,
2782                                            companyId, orderByComparator, false);
2783    
2784                            return array;
2785                    }
2786                    catch (Exception e) {
2787                            throw processException(e);
2788                    }
2789                    finally {
2790                            closeSession(session);
2791                    }
2792            }
2793    
2794            protected JournalFolder getByCompanyId_PrevAndNext(Session session,
2795                    JournalFolder journalFolder, long companyId,
2796                    OrderByComparator orderByComparator, boolean previous) {
2797                    StringBundler query = null;
2798    
2799                    if (orderByComparator != null) {
2800                            query = new StringBundler(6 +
2801                                            (orderByComparator.getOrderByFields().length * 6));
2802                    }
2803                    else {
2804                            query = new StringBundler(3);
2805                    }
2806    
2807                    query.append(_SQL_SELECT_JOURNALFOLDER_WHERE);
2808    
2809                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2810    
2811                    if (orderByComparator != null) {
2812                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2813    
2814                            if (orderByConditionFields.length > 0) {
2815                                    query.append(WHERE_AND);
2816                            }
2817    
2818                            for (int i = 0; i < orderByConditionFields.length; i++) {
2819                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2820                                    query.append(orderByConditionFields[i]);
2821    
2822                                    if ((i + 1) < orderByConditionFields.length) {
2823                                            if (orderByComparator.isAscending() ^ previous) {
2824                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2825                                            }
2826                                            else {
2827                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2828                                            }
2829                                    }
2830                                    else {
2831                                            if (orderByComparator.isAscending() ^ previous) {
2832                                                    query.append(WHERE_GREATER_THAN);
2833                                            }
2834                                            else {
2835                                                    query.append(WHERE_LESSER_THAN);
2836                                            }
2837                                    }
2838                            }
2839    
2840                            query.append(ORDER_BY_CLAUSE);
2841    
2842                            String[] orderByFields = orderByComparator.getOrderByFields();
2843    
2844                            for (int i = 0; i < orderByFields.length; i++) {
2845                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2846                                    query.append(orderByFields[i]);
2847    
2848                                    if ((i + 1) < orderByFields.length) {
2849                                            if (orderByComparator.isAscending() ^ previous) {
2850                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2851                                            }
2852                                            else {
2853                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2854                                            }
2855                                    }
2856                                    else {
2857                                            if (orderByComparator.isAscending() ^ previous) {
2858                                                    query.append(ORDER_BY_ASC);
2859                                            }
2860                                            else {
2861                                                    query.append(ORDER_BY_DESC);
2862                                            }
2863                                    }
2864                            }
2865                    }
2866    
2867                    else {
2868                            query.append(JournalFolderModelImpl.ORDER_BY_JPQL);
2869                    }
2870    
2871                    String sql = query.toString();
2872    
2873                    Query q = session.createQuery(sql);
2874    
2875                    q.setFirstResult(0);
2876                    q.setMaxResults(2);
2877    
2878                    QueryPos qPos = QueryPos.getInstance(q);
2879    
2880                    qPos.add(companyId);
2881    
2882                    if (orderByComparator != null) {
2883                            Object[] values = orderByComparator.getOrderByConditionValues(journalFolder);
2884    
2885                            for (Object value : values) {
2886                                    qPos.add(value);
2887                            }
2888                    }
2889    
2890                    List<JournalFolder> list = q.list();
2891    
2892                    if (list.size() == 2) {
2893                            return list.get(1);
2894                    }
2895                    else {
2896                            return null;
2897                    }
2898            }
2899    
2900            /**
2901             * Returns all the journal folders where groupId = &#63; and parentFolderId = &#63;.
2902             *
2903             * @param groupId the group ID
2904             * @param parentFolderId the parent folder ID
2905             * @return the matching journal folders
2906             * @throws SystemException if a system exception occurred
2907             */
2908            public List<JournalFolder> findByG_P(long groupId, long parentFolderId)
2909                    throws SystemException {
2910                    return findByG_P(groupId, parentFolderId, QueryUtil.ALL_POS,
2911                            QueryUtil.ALL_POS, null);
2912            }
2913    
2914            /**
2915             * Returns a range of all the journal folders where groupId = &#63; and parentFolderId = &#63;.
2916             *
2917             * <p>
2918             * 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.
2919             * </p>
2920             *
2921             * @param groupId the group ID
2922             * @param parentFolderId the parent folder ID
2923             * @param start the lower bound of the range of journal folders
2924             * @param end the upper bound of the range of journal folders (not inclusive)
2925             * @return the range of matching journal folders
2926             * @throws SystemException if a system exception occurred
2927             */
2928            public List<JournalFolder> findByG_P(long groupId, long parentFolderId,
2929                    int start, int end) throws SystemException {
2930                    return findByG_P(groupId, parentFolderId, start, end, null);
2931            }
2932    
2933            /**
2934             * Returns an ordered range of all the journal folders where groupId = &#63; and parentFolderId = &#63;.
2935             *
2936             * <p>
2937             * 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.
2938             * </p>
2939             *
2940             * @param groupId the group ID
2941             * @param parentFolderId the parent folder ID
2942             * @param start the lower bound of the range of journal folders
2943             * @param end the upper bound of the range of journal folders (not inclusive)
2944             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2945             * @return the ordered range of matching journal folders
2946             * @throws SystemException if a system exception occurred
2947             */
2948            public List<JournalFolder> findByG_P(long groupId, long parentFolderId,
2949                    int start, int end, OrderByComparator orderByComparator)
2950                    throws SystemException {
2951                    FinderPath finderPath = null;
2952                    Object[] finderArgs = null;
2953    
2954                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2955                                    (orderByComparator == null)) {
2956                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P;
2957                            finderArgs = new Object[] { groupId, parentFolderId };
2958                    }
2959                    else {
2960                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P;
2961                            finderArgs = new Object[] {
2962                                            groupId, parentFolderId,
2963                                            
2964                                            start, end, orderByComparator
2965                                    };
2966                    }
2967    
2968                    List<JournalFolder> list = (List<JournalFolder>)FinderCacheUtil.getResult(finderPath,
2969                                    finderArgs, this);
2970    
2971                    if ((list != null) && !list.isEmpty()) {
2972                            for (JournalFolder journalFolder : list) {
2973                                    if ((groupId != journalFolder.getGroupId()) ||
2974                                                    (parentFolderId != journalFolder.getParentFolderId())) {
2975                                            list = null;
2976    
2977                                            break;
2978                                    }
2979                            }
2980                    }
2981    
2982                    if (list == null) {
2983                            StringBundler query = null;
2984    
2985                            if (orderByComparator != null) {
2986                                    query = new StringBundler(4 +
2987                                                    (orderByComparator.getOrderByFields().length * 3));
2988                            }
2989                            else {
2990                                    query = new StringBundler(4);
2991                            }
2992    
2993                            query.append(_SQL_SELECT_JOURNALFOLDER_WHERE);
2994    
2995                            query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2996    
2997                            query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
2998    
2999                            if (orderByComparator != null) {
3000                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3001                                            orderByComparator);
3002                            }
3003    
3004                            else {
3005                                    query.append(JournalFolderModelImpl.ORDER_BY_JPQL);
3006                            }
3007    
3008                            String sql = query.toString();
3009    
3010                            Session session = null;
3011    
3012                            try {
3013                                    session = openSession();
3014    
3015                                    Query q = session.createQuery(sql);
3016    
3017                                    QueryPos qPos = QueryPos.getInstance(q);
3018    
3019                                    qPos.add(groupId);
3020    
3021                                    qPos.add(parentFolderId);
3022    
3023                                    list = (List<JournalFolder>)QueryUtil.list(q, getDialect(),
3024                                                    start, end);
3025                            }
3026                            catch (Exception e) {
3027                                    throw processException(e);
3028                            }
3029                            finally {
3030                                    if (list == null) {
3031                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3032                                    }
3033                                    else {
3034                                            cacheResult(list);
3035    
3036                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3037                                    }
3038    
3039                                    closeSession(session);
3040                            }
3041                    }
3042    
3043                    return list;
3044            }
3045    
3046            /**
3047             * Returns the first journal folder in the ordered set where groupId = &#63; and parentFolderId = &#63;.
3048             *
3049             * @param groupId the group ID
3050             * @param parentFolderId the parent folder ID
3051             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3052             * @return the first matching journal folder
3053             * @throws com.liferay.portlet.journal.NoSuchFolderException if a matching journal folder could not be found
3054             * @throws SystemException if a system exception occurred
3055             */
3056            public JournalFolder findByG_P_First(long groupId, long parentFolderId,
3057                    OrderByComparator orderByComparator)
3058                    throws NoSuchFolderException, SystemException {
3059                    JournalFolder journalFolder = fetchByG_P_First(groupId, parentFolderId,
3060                                    orderByComparator);
3061    
3062                    if (journalFolder != null) {
3063                            return journalFolder;
3064                    }
3065    
3066                    StringBundler msg = new StringBundler(6);
3067    
3068                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3069    
3070                    msg.append("groupId=");
3071                    msg.append(groupId);
3072    
3073                    msg.append(", parentFolderId=");
3074                    msg.append(parentFolderId);
3075    
3076                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3077    
3078                    throw new NoSuchFolderException(msg.toString());
3079            }
3080    
3081            /**
3082             * Returns the first journal folder in the ordered set where groupId = &#63; and parentFolderId = &#63;.
3083             *
3084             * @param groupId the group ID
3085             * @param parentFolderId the parent folder ID
3086             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3087             * @return the first matching journal folder, or <code>null</code> if a matching journal folder could not be found
3088             * @throws SystemException if a system exception occurred
3089             */
3090            public JournalFolder fetchByG_P_First(long groupId, long parentFolderId,
3091                    OrderByComparator orderByComparator) throws SystemException {
3092                    List<JournalFolder> list = findByG_P(groupId, parentFolderId, 0, 1,
3093                                    orderByComparator);
3094    
3095                    if (!list.isEmpty()) {
3096                            return list.get(0);
3097                    }
3098    
3099                    return null;
3100            }
3101    
3102            /**
3103             * Returns the last journal folder in the ordered set where groupId = &#63; and parentFolderId = &#63;.
3104             *
3105             * @param groupId the group ID
3106             * @param parentFolderId the parent folder ID
3107             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3108             * @return the last matching journal folder
3109             * @throws com.liferay.portlet.journal.NoSuchFolderException if a matching journal folder could not be found
3110             * @throws SystemException if a system exception occurred
3111             */
3112            public JournalFolder findByG_P_Last(long groupId, long parentFolderId,
3113                    OrderByComparator orderByComparator)
3114                    throws NoSuchFolderException, SystemException {
3115                    JournalFolder journalFolder = fetchByG_P_Last(groupId, parentFolderId,
3116                                    orderByComparator);
3117    
3118                    if (journalFolder != null) {
3119                            return journalFolder;
3120                    }
3121    
3122                    StringBundler msg = new StringBundler(6);
3123    
3124                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3125    
3126                    msg.append("groupId=");
3127                    msg.append(groupId);
3128    
3129                    msg.append(", parentFolderId=");
3130                    msg.append(parentFolderId);
3131    
3132                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3133    
3134                    throw new NoSuchFolderException(msg.toString());
3135            }
3136    
3137            /**
3138             * Returns the last journal folder in the ordered set where groupId = &#63; and parentFolderId = &#63;.
3139             *
3140             * @param groupId the group ID
3141             * @param parentFolderId the parent folder ID
3142             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3143             * @return the last matching journal folder, or <code>null</code> if a matching journal folder could not be found
3144             * @throws SystemException if a system exception occurred
3145             */
3146            public JournalFolder fetchByG_P_Last(long groupId, long parentFolderId,
3147                    OrderByComparator orderByComparator) throws SystemException {
3148                    int count = countByG_P(groupId, parentFolderId);
3149    
3150                    List<JournalFolder> list = findByG_P(groupId, parentFolderId,
3151                                    count - 1, count, orderByComparator);
3152    
3153                    if (!list.isEmpty()) {
3154                            return list.get(0);
3155                    }
3156    
3157                    return null;
3158            }
3159    
3160            /**
3161             * Returns the journal folders before and after the current journal folder in the ordered set where groupId = &#63; and parentFolderId = &#63;.
3162             *
3163             * @param folderId the primary key of the current journal folder
3164             * @param groupId the group ID
3165             * @param parentFolderId the parent folder ID
3166             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3167             * @return the previous, current, and next journal folder
3168             * @throws com.liferay.portlet.journal.NoSuchFolderException if a journal folder with the primary key could not be found
3169             * @throws SystemException if a system exception occurred
3170             */
3171            public JournalFolder[] findByG_P_PrevAndNext(long folderId, long groupId,
3172                    long parentFolderId, OrderByComparator orderByComparator)
3173                    throws NoSuchFolderException, SystemException {
3174                    JournalFolder journalFolder = findByPrimaryKey(folderId);
3175    
3176                    Session session = null;
3177    
3178                    try {
3179                            session = openSession();
3180    
3181                            JournalFolder[] array = new JournalFolderImpl[3];
3182    
3183                            array[0] = getByG_P_PrevAndNext(session, journalFolder, groupId,
3184                                            parentFolderId, orderByComparator, true);
3185    
3186                            array[1] = journalFolder;
3187    
3188                            array[2] = getByG_P_PrevAndNext(session, journalFolder, groupId,
3189                                            parentFolderId, orderByComparator, false);
3190    
3191                            return array;
3192                    }
3193                    catch (Exception e) {
3194                            throw processException(e);
3195                    }
3196                    finally {
3197                            closeSession(session);
3198                    }
3199            }
3200    
3201            protected JournalFolder getByG_P_PrevAndNext(Session session,
3202                    JournalFolder journalFolder, long groupId, long parentFolderId,
3203                    OrderByComparator orderByComparator, boolean previous) {
3204                    StringBundler query = null;
3205    
3206                    if (orderByComparator != null) {
3207                            query = new StringBundler(6 +
3208                                            (orderByComparator.getOrderByFields().length * 6));
3209                    }
3210                    else {
3211                            query = new StringBundler(3);
3212                    }
3213    
3214                    query.append(_SQL_SELECT_JOURNALFOLDER_WHERE);
3215    
3216                    query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3217    
3218                    query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
3219    
3220                    if (orderByComparator != null) {
3221                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3222    
3223                            if (orderByConditionFields.length > 0) {
3224                                    query.append(WHERE_AND);
3225                            }
3226    
3227                            for (int i = 0; i < orderByConditionFields.length; i++) {
3228                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3229                                    query.append(orderByConditionFields[i]);
3230    
3231                                    if ((i + 1) < orderByConditionFields.length) {
3232                                            if (orderByComparator.isAscending() ^ previous) {
3233                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3234                                            }
3235                                            else {
3236                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3237                                            }
3238                                    }
3239                                    else {
3240                                            if (orderByComparator.isAscending() ^ previous) {
3241                                                    query.append(WHERE_GREATER_THAN);
3242                                            }
3243                                            else {
3244                                                    query.append(WHERE_LESSER_THAN);
3245                                            }
3246                                    }
3247                            }
3248    
3249                            query.append(ORDER_BY_CLAUSE);
3250    
3251                            String[] orderByFields = orderByComparator.getOrderByFields();
3252    
3253                            for (int i = 0; i < orderByFields.length; i++) {
3254                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3255                                    query.append(orderByFields[i]);
3256    
3257                                    if ((i + 1) < orderByFields.length) {
3258                                            if (orderByComparator.isAscending() ^ previous) {
3259                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3260                                            }
3261                                            else {
3262                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3263                                            }
3264                                    }
3265                                    else {
3266                                            if (orderByComparator.isAscending() ^ previous) {
3267                                                    query.append(ORDER_BY_ASC);
3268                                            }
3269                                            else {
3270                                                    query.append(ORDER_BY_DESC);
3271                                            }
3272                                    }
3273                            }
3274                    }
3275    
3276                    else {
3277                            query.append(JournalFolderModelImpl.ORDER_BY_JPQL);
3278                    }
3279    
3280                    String sql = query.toString();
3281    
3282                    Query q = session.createQuery(sql);
3283    
3284                    q.setFirstResult(0);
3285                    q.setMaxResults(2);
3286    
3287                    QueryPos qPos = QueryPos.getInstance(q);
3288    
3289                    qPos.add(groupId);
3290    
3291                    qPos.add(parentFolderId);
3292    
3293                    if (orderByComparator != null) {
3294                            Object[] values = orderByComparator.getOrderByConditionValues(journalFolder);
3295    
3296                            for (Object value : values) {
3297                                    qPos.add(value);
3298                            }
3299                    }
3300    
3301                    List<JournalFolder> list = q.list();
3302    
3303                    if (list.size() == 2) {
3304                            return list.get(1);
3305                    }
3306                    else {
3307                            return null;
3308                    }
3309            }
3310    
3311            /**
3312             * Returns all the journal folders that the user has permission to view where groupId = &#63; and parentFolderId = &#63;.
3313             *
3314             * @param groupId the group ID
3315             * @param parentFolderId the parent folder ID
3316             * @return the matching journal folders that the user has permission to view
3317             * @throws SystemException if a system exception occurred
3318             */
3319            public List<JournalFolder> filterFindByG_P(long groupId, long parentFolderId)
3320                    throws SystemException {
3321                    return filterFindByG_P(groupId, parentFolderId, QueryUtil.ALL_POS,
3322                            QueryUtil.ALL_POS, null);
3323            }
3324    
3325            /**
3326             * Returns a range of all the journal folders that the user has permission to view where groupId = &#63; and parentFolderId = &#63;.
3327             *
3328             * <p>
3329             * 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.
3330             * </p>
3331             *
3332             * @param groupId the group ID
3333             * @param parentFolderId the parent folder ID
3334             * @param start the lower bound of the range of journal folders
3335             * @param end the upper bound of the range of journal folders (not inclusive)
3336             * @return the range of matching journal folders that the user has permission to view
3337             * @throws SystemException if a system exception occurred
3338             */
3339            public List<JournalFolder> filterFindByG_P(long groupId,
3340                    long parentFolderId, int start, int end) throws SystemException {
3341                    return filterFindByG_P(groupId, parentFolderId, start, end, null);
3342            }
3343    
3344            /**
3345             * Returns an ordered range of all the journal folders that the user has permissions to view where groupId = &#63; and parentFolderId = &#63;.
3346             *
3347             * <p>
3348             * 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.
3349             * </p>
3350             *
3351             * @param groupId the group ID
3352             * @param parentFolderId the parent folder ID
3353             * @param start the lower bound of the range of journal folders
3354             * @param end the upper bound of the range of journal folders (not inclusive)
3355             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3356             * @return the ordered range of matching journal folders that the user has permission to view
3357             * @throws SystemException if a system exception occurred
3358             */
3359            public List<JournalFolder> filterFindByG_P(long groupId,
3360                    long parentFolderId, int start, int end,
3361                    OrderByComparator orderByComparator) throws SystemException {
3362                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3363                            return findByG_P(groupId, parentFolderId, start, end,
3364                                    orderByComparator);
3365                    }
3366    
3367                    StringBundler query = null;
3368    
3369                    if (orderByComparator != null) {
3370                            query = new StringBundler(4 +
3371                                            (orderByComparator.getOrderByFields().length * 3));
3372                    }
3373                    else {
3374                            query = new StringBundler(4);
3375                    }
3376    
3377                    if (getDB().isSupportsInlineDistinct()) {
3378                            query.append(_FILTER_SQL_SELECT_JOURNALFOLDER_WHERE);
3379                    }
3380                    else {
3381                            query.append(_FILTER_SQL_SELECT_JOURNALFOLDER_NO_INLINE_DISTINCT_WHERE_1);
3382                    }
3383    
3384                    query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3385    
3386                    query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
3387    
3388                    if (!getDB().isSupportsInlineDistinct()) {
3389                            query.append(_FILTER_SQL_SELECT_JOURNALFOLDER_NO_INLINE_DISTINCT_WHERE_2);
3390                    }
3391    
3392                    if (orderByComparator != null) {
3393                            if (getDB().isSupportsInlineDistinct()) {
3394                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3395                                            orderByComparator);
3396                            }
3397                            else {
3398                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3399                                            orderByComparator);
3400                            }
3401                    }
3402    
3403                    else {
3404                            if (getDB().isSupportsInlineDistinct()) {
3405                                    query.append(JournalFolderModelImpl.ORDER_BY_JPQL);
3406                            }
3407                            else {
3408                                    query.append(JournalFolderModelImpl.ORDER_BY_SQL);
3409                            }
3410                    }
3411    
3412                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3413                                    JournalFolder.class.getName(),
3414                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3415    
3416                    Session session = null;
3417    
3418                    try {
3419                            session = openSession();
3420    
3421                            SQLQuery q = session.createSQLQuery(sql);
3422    
3423                            if (getDB().isSupportsInlineDistinct()) {
3424                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalFolderImpl.class);
3425                            }
3426                            else {
3427                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalFolderImpl.class);
3428                            }
3429    
3430                            QueryPos qPos = QueryPos.getInstance(q);
3431    
3432                            qPos.add(groupId);
3433    
3434                            qPos.add(parentFolderId);
3435    
3436                            return (List<JournalFolder>)QueryUtil.list(q, getDialect(), start,
3437                                    end);
3438                    }
3439                    catch (Exception e) {
3440                            throw processException(e);
3441                    }
3442                    finally {
3443                            closeSession(session);
3444                    }
3445            }
3446    
3447            /**
3448             * Returns the journal folders before and after the current journal folder in the ordered set of journal folders that the user has permission to view where groupId = &#63; and parentFolderId = &#63;.
3449             *
3450             * @param folderId the primary key of the current journal folder
3451             * @param groupId the group ID
3452             * @param parentFolderId the parent folder ID
3453             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3454             * @return the previous, current, and next journal folder
3455             * @throws com.liferay.portlet.journal.NoSuchFolderException if a journal folder with the primary key could not be found
3456             * @throws SystemException if a system exception occurred
3457             */
3458            public JournalFolder[] filterFindByG_P_PrevAndNext(long folderId,
3459                    long groupId, long parentFolderId, OrderByComparator orderByComparator)
3460                    throws NoSuchFolderException, SystemException {
3461                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3462                            return findByG_P_PrevAndNext(folderId, groupId, parentFolderId,
3463                                    orderByComparator);
3464                    }
3465    
3466                    JournalFolder journalFolder = findByPrimaryKey(folderId);
3467    
3468                    Session session = null;
3469    
3470                    try {
3471                            session = openSession();
3472    
3473                            JournalFolder[] array = new JournalFolderImpl[3];
3474    
3475                            array[0] = filterGetByG_P_PrevAndNext(session, journalFolder,
3476                                            groupId, parentFolderId, orderByComparator, true);
3477    
3478                            array[1] = journalFolder;
3479    
3480                            array[2] = filterGetByG_P_PrevAndNext(session, journalFolder,
3481                                            groupId, parentFolderId, orderByComparator, false);
3482    
3483                            return array;
3484                    }
3485                    catch (Exception e) {
3486                            throw processException(e);
3487                    }
3488                    finally {
3489                            closeSession(session);
3490                    }
3491            }
3492    
3493            protected JournalFolder filterGetByG_P_PrevAndNext(Session session,
3494                    JournalFolder journalFolder, long groupId, long parentFolderId,
3495                    OrderByComparator orderByComparator, boolean previous) {
3496                    StringBundler query = null;
3497    
3498                    if (orderByComparator != null) {
3499                            query = new StringBundler(6 +
3500                                            (orderByComparator.getOrderByFields().length * 6));
3501                    }
3502                    else {
3503                            query = new StringBundler(3);
3504                    }
3505    
3506                    if (getDB().isSupportsInlineDistinct()) {
3507                            query.append(_FILTER_SQL_SELECT_JOURNALFOLDER_WHERE);
3508                    }
3509                    else {
3510                            query.append(_FILTER_SQL_SELECT_JOURNALFOLDER_NO_INLINE_DISTINCT_WHERE_1);
3511                    }
3512    
3513                    query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3514    
3515                    query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
3516    
3517                    if (!getDB().isSupportsInlineDistinct()) {
3518                            query.append(_FILTER_SQL_SELECT_JOURNALFOLDER_NO_INLINE_DISTINCT_WHERE_2);
3519                    }
3520    
3521                    if (orderByComparator != null) {
3522                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3523    
3524                            if (orderByConditionFields.length > 0) {
3525                                    query.append(WHERE_AND);
3526                            }
3527    
3528                            for (int i = 0; i < orderByConditionFields.length; i++) {
3529                                    if (getDB().isSupportsInlineDistinct()) {
3530                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3531                                    }
3532                                    else {
3533                                            query.append(_ORDER_BY_ENTITY_TABLE);
3534                                    }
3535    
3536                                    query.append(orderByConditionFields[i]);
3537    
3538                                    if ((i + 1) < orderByConditionFields.length) {
3539                                            if (orderByComparator.isAscending() ^ previous) {
3540                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3541                                            }
3542                                            else {
3543                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3544                                            }
3545                                    }
3546                                    else {
3547                                            if (orderByComparator.isAscending() ^ previous) {
3548                                                    query.append(WHERE_GREATER_THAN);
3549                                            }
3550                                            else {
3551                                                    query.append(WHERE_LESSER_THAN);
3552                                            }
3553                                    }
3554                            }
3555    
3556                            query.append(ORDER_BY_CLAUSE);
3557    
3558                            String[] orderByFields = orderByComparator.getOrderByFields();
3559    
3560                            for (int i = 0; i < orderByFields.length; i++) {
3561                                    if (getDB().isSupportsInlineDistinct()) {
3562                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3563                                    }
3564                                    else {
3565                                            query.append(_ORDER_BY_ENTITY_TABLE);
3566                                    }
3567    
3568                                    query.append(orderByFields[i]);
3569    
3570                                    if ((i + 1) < orderByFields.length) {
3571                                            if (orderByComparator.isAscending() ^ previous) {
3572                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3573                                            }
3574                                            else {
3575                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3576                                            }
3577                                    }
3578                                    else {
3579                                            if (orderByComparator.isAscending() ^ previous) {
3580                                                    query.append(ORDER_BY_ASC);
3581                                            }
3582                                            else {
3583                                                    query.append(ORDER_BY_DESC);
3584                                            }
3585                                    }
3586                            }
3587                    }
3588    
3589                    else {
3590                            if (getDB().isSupportsInlineDistinct()) {
3591                                    query.append(JournalFolderModelImpl.ORDER_BY_JPQL);
3592                            }
3593                            else {
3594                                    query.append(JournalFolderModelImpl.ORDER_BY_SQL);
3595                            }
3596                    }
3597    
3598                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3599                                    JournalFolder.class.getName(),
3600                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3601    
3602                    SQLQuery q = session.createSQLQuery(sql);
3603    
3604                    q.setFirstResult(0);
3605                    q.setMaxResults(2);
3606    
3607                    if (getDB().isSupportsInlineDistinct()) {
3608                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalFolderImpl.class);
3609                    }
3610                    else {
3611                            q.addEntity(_FILTER_ENTITY_TABLE, JournalFolderImpl.class);
3612                    }
3613    
3614                    QueryPos qPos = QueryPos.getInstance(q);
3615    
3616                    qPos.add(groupId);
3617    
3618                    qPos.add(parentFolderId);
3619    
3620                    if (orderByComparator != null) {
3621                            Object[] values = orderByComparator.getOrderByConditionValues(journalFolder);
3622    
3623                            for (Object value : values) {
3624                                    qPos.add(value);
3625                            }
3626                    }
3627    
3628                    List<JournalFolder> list = q.list();
3629    
3630                    if (list.size() == 2) {
3631                            return list.get(1);
3632                    }
3633                    else {
3634                            return null;
3635                    }
3636            }
3637    
3638            /**
3639             * Returns the journal folder where groupId = &#63; and name = &#63; or throws a {@link com.liferay.portlet.journal.NoSuchFolderException} if it could not be found.
3640             *
3641             * @param groupId the group ID
3642             * @param name the name
3643             * @return the matching journal folder
3644             * @throws com.liferay.portlet.journal.NoSuchFolderException if a matching journal folder could not be found
3645             * @throws SystemException if a system exception occurred
3646             */
3647            public JournalFolder findByG_N(long groupId, String name)
3648                    throws NoSuchFolderException, SystemException {
3649                    JournalFolder journalFolder = fetchByG_N(groupId, name);
3650    
3651                    if (journalFolder == null) {
3652                            StringBundler msg = new StringBundler(6);
3653    
3654                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3655    
3656                            msg.append("groupId=");
3657                            msg.append(groupId);
3658    
3659                            msg.append(", name=");
3660                            msg.append(name);
3661    
3662                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3663    
3664                            if (_log.isWarnEnabled()) {
3665                                    _log.warn(msg.toString());
3666                            }
3667    
3668                            throw new NoSuchFolderException(msg.toString());
3669                    }
3670    
3671                    return journalFolder;
3672            }
3673    
3674            /**
3675             * Returns the journal folder where groupId = &#63; and name = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
3676             *
3677             * @param groupId the group ID
3678             * @param name the name
3679             * @return the matching journal folder, or <code>null</code> if a matching journal folder could not be found
3680             * @throws SystemException if a system exception occurred
3681             */
3682            public JournalFolder fetchByG_N(long groupId, String name)
3683                    throws SystemException {
3684                    return fetchByG_N(groupId, name, true);
3685            }
3686    
3687            /**
3688             * Returns the journal folder where groupId = &#63; and name = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
3689             *
3690             * @param groupId the group ID
3691             * @param name the name
3692             * @param retrieveFromCache whether to use the finder cache
3693             * @return the matching journal folder, or <code>null</code> if a matching journal folder could not be found
3694             * @throws SystemException if a system exception occurred
3695             */
3696            public JournalFolder fetchByG_N(long groupId, String name,
3697                    boolean retrieveFromCache) throws SystemException {
3698                    Object[] finderArgs = new Object[] { groupId, name };
3699    
3700                    Object result = null;
3701    
3702                    if (retrieveFromCache) {
3703                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_N,
3704                                            finderArgs, this);
3705                    }
3706    
3707                    if (result instanceof JournalFolder) {
3708                            JournalFolder journalFolder = (JournalFolder)result;
3709    
3710                            if ((groupId != journalFolder.getGroupId()) ||
3711                                            !Validator.equals(name, journalFolder.getName())) {
3712                                    result = null;
3713                            }
3714                    }
3715    
3716                    if (result == null) {
3717                            StringBundler query = new StringBundler(4);
3718    
3719                            query.append(_SQL_SELECT_JOURNALFOLDER_WHERE);
3720    
3721                            query.append(_FINDER_COLUMN_G_N_GROUPID_2);
3722    
3723                            if (name == null) {
3724                                    query.append(_FINDER_COLUMN_G_N_NAME_1);
3725                            }
3726                            else {
3727                                    if (name.equals(StringPool.BLANK)) {
3728                                            query.append(_FINDER_COLUMN_G_N_NAME_3);
3729                                    }
3730                                    else {
3731                                            query.append(_FINDER_COLUMN_G_N_NAME_2);
3732                                    }
3733                            }
3734    
3735                            query.append(JournalFolderModelImpl.ORDER_BY_JPQL);
3736    
3737                            String sql = query.toString();
3738    
3739                            Session session = null;
3740    
3741                            try {
3742                                    session = openSession();
3743    
3744                                    Query q = session.createQuery(sql);
3745    
3746                                    QueryPos qPos = QueryPos.getInstance(q);
3747    
3748                                    qPos.add(groupId);
3749    
3750                                    if (name != null) {
3751                                            qPos.add(name);
3752                                    }
3753    
3754                                    List<JournalFolder> list = q.list();
3755    
3756                                    result = list;
3757    
3758                                    JournalFolder journalFolder = null;
3759    
3760                                    if (list.isEmpty()) {
3761                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
3762                                                    finderArgs, list);
3763                                    }
3764                                    else {
3765                                            journalFolder = list.get(0);
3766    
3767                                            cacheResult(journalFolder);
3768    
3769                                            if ((journalFolder.getGroupId() != groupId) ||
3770                                                            (journalFolder.getName() == null) ||
3771                                                            !journalFolder.getName().equals(name)) {
3772                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
3773                                                            finderArgs, journalFolder);
3774                                            }
3775                                    }
3776    
3777                                    return journalFolder;
3778                            }
3779                            catch (Exception e) {
3780                                    throw processException(e);
3781                            }
3782                            finally {
3783                                    if (result == null) {
3784                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
3785                                                    finderArgs);
3786                                    }
3787    
3788                                    closeSession(session);
3789                            }
3790                    }
3791                    else {
3792                            if (result instanceof List<?>) {
3793                                    return null;
3794                            }
3795                            else {
3796                                    return (JournalFolder)result;
3797                            }
3798                    }
3799            }
3800    
3801            /**
3802             * Returns the journal folder where groupId = &#63; and parentFolderId = &#63; and name = &#63; or throws a {@link com.liferay.portlet.journal.NoSuchFolderException} if it could not be found.
3803             *
3804             * @param groupId the group ID
3805             * @param parentFolderId the parent folder ID
3806             * @param name the name
3807             * @return the matching journal folder
3808             * @throws com.liferay.portlet.journal.NoSuchFolderException if a matching journal folder could not be found
3809             * @throws SystemException if a system exception occurred
3810             */
3811            public JournalFolder findByG_P_N(long groupId, long parentFolderId,
3812                    String name) throws NoSuchFolderException, SystemException {
3813                    JournalFolder journalFolder = fetchByG_P_N(groupId, parentFolderId, name);
3814    
3815                    if (journalFolder == null) {
3816                            StringBundler msg = new StringBundler(8);
3817    
3818                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3819    
3820                            msg.append("groupId=");
3821                            msg.append(groupId);
3822    
3823                            msg.append(", parentFolderId=");
3824                            msg.append(parentFolderId);
3825    
3826                            msg.append(", name=");
3827                            msg.append(name);
3828    
3829                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3830    
3831                            if (_log.isWarnEnabled()) {
3832                                    _log.warn(msg.toString());
3833                            }
3834    
3835                            throw new NoSuchFolderException(msg.toString());
3836                    }
3837    
3838                    return journalFolder;
3839            }
3840    
3841            /**
3842             * Returns the journal folder where groupId = &#63; and parentFolderId = &#63; and name = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
3843             *
3844             * @param groupId the group ID
3845             * @param parentFolderId the parent folder ID
3846             * @param name the name
3847             * @return the matching journal folder, or <code>null</code> if a matching journal folder could not be found
3848             * @throws SystemException if a system exception occurred
3849             */
3850            public JournalFolder fetchByG_P_N(long groupId, long parentFolderId,
3851                    String name) throws SystemException {
3852                    return fetchByG_P_N(groupId, parentFolderId, name, true);
3853            }
3854    
3855            /**
3856             * Returns the journal folder where groupId = &#63; and parentFolderId = &#63; and name = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
3857             *
3858             * @param groupId the group ID
3859             * @param parentFolderId the parent folder ID
3860             * @param name the name
3861             * @param retrieveFromCache whether to use the finder cache
3862             * @return the matching journal folder, or <code>null</code> if a matching journal folder could not be found
3863             * @throws SystemException if a system exception occurred
3864             */
3865            public JournalFolder fetchByG_P_N(long groupId, long parentFolderId,
3866                    String name, boolean retrieveFromCache) throws SystemException {
3867                    Object[] finderArgs = new Object[] { groupId, parentFolderId, name };
3868    
3869                    Object result = null;
3870    
3871                    if (retrieveFromCache) {
3872                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_P_N,
3873                                            finderArgs, this);
3874                    }
3875    
3876                    if (result instanceof JournalFolder) {
3877                            JournalFolder journalFolder = (JournalFolder)result;
3878    
3879                            if ((groupId != journalFolder.getGroupId()) ||
3880                                            (parentFolderId != journalFolder.getParentFolderId()) ||
3881                                            !Validator.equals(name, journalFolder.getName())) {
3882                                    result = null;
3883                            }
3884                    }
3885    
3886                    if (result == null) {
3887                            StringBundler query = new StringBundler(5);
3888    
3889                            query.append(_SQL_SELECT_JOURNALFOLDER_WHERE);
3890    
3891                            query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
3892    
3893                            query.append(_FINDER_COLUMN_G_P_N_PARENTFOLDERID_2);
3894    
3895                            if (name == null) {
3896                                    query.append(_FINDER_COLUMN_G_P_N_NAME_1);
3897                            }
3898                            else {
3899                                    if (name.equals(StringPool.BLANK)) {
3900                                            query.append(_FINDER_COLUMN_G_P_N_NAME_3);
3901                                    }
3902                                    else {
3903                                            query.append(_FINDER_COLUMN_G_P_N_NAME_2);
3904                                    }
3905                            }
3906    
3907                            query.append(JournalFolderModelImpl.ORDER_BY_JPQL);
3908    
3909                            String sql = query.toString();
3910    
3911                            Session session = null;
3912    
3913                            try {
3914                                    session = openSession();
3915    
3916                                    Query q = session.createQuery(sql);
3917    
3918                                    QueryPos qPos = QueryPos.getInstance(q);
3919    
3920                                    qPos.add(groupId);
3921    
3922                                    qPos.add(parentFolderId);
3923    
3924                                    if (name != null) {
3925                                            qPos.add(name);
3926                                    }
3927    
3928                                    List<JournalFolder> list = q.list();
3929    
3930                                    result = list;
3931    
3932                                    JournalFolder journalFolder = null;
3933    
3934                                    if (list.isEmpty()) {
3935                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
3936                                                    finderArgs, list);
3937                                    }
3938                                    else {
3939                                            journalFolder = list.get(0);
3940    
3941                                            cacheResult(journalFolder);
3942    
3943                                            if ((journalFolder.getGroupId() != groupId) ||
3944                                                            (journalFolder.getParentFolderId() != parentFolderId) ||
3945                                                            (journalFolder.getName() == null) ||
3946                                                            !journalFolder.getName().equals(name)) {
3947                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
3948                                                            finderArgs, journalFolder);
3949                                            }
3950                                    }
3951    
3952                                    return journalFolder;
3953                            }
3954                            catch (Exception e) {
3955                                    throw processException(e);
3956                            }
3957                            finally {
3958                                    if (result == null) {
3959                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N,
3960                                                    finderArgs);
3961                                    }
3962    
3963                                    closeSession(session);
3964                            }
3965                    }
3966                    else {
3967                            if (result instanceof List<?>) {
3968                                    return null;
3969                            }
3970                            else {
3971                                    return (JournalFolder)result;
3972                            }
3973                    }
3974            }
3975    
3976            /**
3977             * Returns all the journal folders.
3978             *
3979             * @return the journal folders
3980             * @throws SystemException if a system exception occurred
3981             */
3982            public List<JournalFolder> findAll() throws SystemException {
3983                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3984            }
3985    
3986            /**
3987             * Returns a range of all the journal folders.
3988             *
3989             * <p>
3990             * 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.
3991             * </p>
3992             *
3993             * @param start the lower bound of the range of journal folders
3994             * @param end the upper bound of the range of journal folders (not inclusive)
3995             * @return the range of journal folders
3996             * @throws SystemException if a system exception occurred
3997             */
3998            public List<JournalFolder> findAll(int start, int end)
3999                    throws SystemException {
4000                    return findAll(start, end, null);
4001            }
4002    
4003            /**
4004             * Returns an ordered range of all the journal folders.
4005             *
4006             * <p>
4007             * 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.
4008             * </p>
4009             *
4010             * @param start the lower bound of the range of journal folders
4011             * @param end the upper bound of the range of journal folders (not inclusive)
4012             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4013             * @return the ordered range of journal folders
4014             * @throws SystemException if a system exception occurred
4015             */
4016            public List<JournalFolder> findAll(int start, int end,
4017                    OrderByComparator orderByComparator) throws SystemException {
4018                    FinderPath finderPath = null;
4019                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
4020    
4021                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4022                                    (orderByComparator == null)) {
4023                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
4024                            finderArgs = FINDER_ARGS_EMPTY;
4025                    }
4026                    else {
4027                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
4028                            finderArgs = new Object[] { start, end, orderByComparator };
4029                    }
4030    
4031                    List<JournalFolder> list = (List<JournalFolder>)FinderCacheUtil.getResult(finderPath,
4032                                    finderArgs, this);
4033    
4034                    if (list == null) {
4035                            StringBundler query = null;
4036                            String sql = null;
4037    
4038                            if (orderByComparator != null) {
4039                                    query = new StringBundler(2 +
4040                                                    (orderByComparator.getOrderByFields().length * 3));
4041    
4042                                    query.append(_SQL_SELECT_JOURNALFOLDER);
4043    
4044                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4045                                            orderByComparator);
4046    
4047                                    sql = query.toString();
4048                            }
4049                            else {
4050                                    sql = _SQL_SELECT_JOURNALFOLDER.concat(JournalFolderModelImpl.ORDER_BY_JPQL);
4051                            }
4052    
4053                            Session session = null;
4054    
4055                            try {
4056                                    session = openSession();
4057    
4058                                    Query q = session.createQuery(sql);
4059    
4060                                    if (orderByComparator == null) {
4061                                            list = (List<JournalFolder>)QueryUtil.list(q, getDialect(),
4062                                                            start, end, false);
4063    
4064                                            Collections.sort(list);
4065                                    }
4066                                    else {
4067                                            list = (List<JournalFolder>)QueryUtil.list(q, getDialect(),
4068                                                            start, end);
4069                                    }
4070                            }
4071                            catch (Exception e) {
4072                                    throw processException(e);
4073                            }
4074                            finally {
4075                                    if (list == null) {
4076                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
4077                                    }
4078                                    else {
4079                                            cacheResult(list);
4080    
4081                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
4082                                    }
4083    
4084                                    closeSession(session);
4085                            }
4086                    }
4087    
4088                    return list;
4089            }
4090    
4091            /**
4092             * Removes all the journal folders where uuid = &#63; from the database.
4093             *
4094             * @param uuid the uuid
4095             * @throws SystemException if a system exception occurred
4096             */
4097            public void removeByUuid(String uuid) throws SystemException {
4098                    for (JournalFolder journalFolder : findByUuid(uuid)) {
4099                            remove(journalFolder);
4100                    }
4101            }
4102    
4103            /**
4104             * Removes the journal folder where uuid = &#63; and groupId = &#63; from the database.
4105             *
4106             * @param uuid the uuid
4107             * @param groupId the group ID
4108             * @return the journal folder that was removed
4109             * @throws SystemException if a system exception occurred
4110             */
4111            public JournalFolder removeByUUID_G(String uuid, long groupId)
4112                    throws NoSuchFolderException, SystemException {
4113                    JournalFolder journalFolder = findByUUID_G(uuid, groupId);
4114    
4115                    return remove(journalFolder);
4116            }
4117    
4118            /**
4119             * Removes all the journal folders where uuid = &#63; and companyId = &#63; from the database.
4120             *
4121             * @param uuid the uuid
4122             * @param companyId the company ID
4123             * @throws SystemException if a system exception occurred
4124             */
4125            public void removeByUuid_C(String uuid, long companyId)
4126                    throws SystemException {
4127                    for (JournalFolder journalFolder : findByUuid_C(uuid, companyId)) {
4128                            remove(journalFolder);
4129                    }
4130            }
4131    
4132            /**
4133             * Removes all the journal folders where groupId = &#63; from the database.
4134             *
4135             * @param groupId the group ID
4136             * @throws SystemException if a system exception occurred
4137             */
4138            public void removeByGroupId(long groupId) throws SystemException {
4139                    for (JournalFolder journalFolder : findByGroupId(groupId)) {
4140                            remove(journalFolder);
4141                    }
4142            }
4143    
4144            /**
4145             * Removes all the journal folders where companyId = &#63; from the database.
4146             *
4147             * @param companyId the company ID
4148             * @throws SystemException if a system exception occurred
4149             */
4150            public void removeByCompanyId(long companyId) throws SystemException {
4151                    for (JournalFolder journalFolder : findByCompanyId(companyId)) {
4152                            remove(journalFolder);
4153                    }
4154            }
4155    
4156            /**
4157             * Removes all the journal folders where groupId = &#63; and parentFolderId = &#63; from the database.
4158             *
4159             * @param groupId the group ID
4160             * @param parentFolderId the parent folder ID
4161             * @throws SystemException if a system exception occurred
4162             */
4163            public void removeByG_P(long groupId, long parentFolderId)
4164                    throws SystemException {
4165                    for (JournalFolder journalFolder : findByG_P(groupId, parentFolderId)) {
4166                            remove(journalFolder);
4167                    }
4168            }
4169    
4170            /**
4171             * Removes the journal folder where groupId = &#63; and name = &#63; from the database.
4172             *
4173             * @param groupId the group ID
4174             * @param name the name
4175             * @return the journal folder that was removed
4176             * @throws SystemException if a system exception occurred
4177             */
4178            public JournalFolder removeByG_N(long groupId, String name)
4179                    throws NoSuchFolderException, SystemException {
4180                    JournalFolder journalFolder = findByG_N(groupId, name);
4181    
4182                    return remove(journalFolder);
4183            }
4184    
4185            /**
4186             * Removes the journal folder where groupId = &#63; and parentFolderId = &#63; and name = &#63; from the database.
4187             *
4188             * @param groupId the group ID
4189             * @param parentFolderId the parent folder ID
4190             * @param name the name
4191             * @return the journal folder that was removed
4192             * @throws SystemException if a system exception occurred
4193             */
4194            public JournalFolder removeByG_P_N(long groupId, long parentFolderId,
4195                    String name) throws NoSuchFolderException, SystemException {
4196                    JournalFolder journalFolder = findByG_P_N(groupId, parentFolderId, name);
4197    
4198                    return remove(journalFolder);
4199            }
4200    
4201            /**
4202             * Removes all the journal folders from the database.
4203             *
4204             * @throws SystemException if a system exception occurred
4205             */
4206            public void removeAll() throws SystemException {
4207                    for (JournalFolder journalFolder : findAll()) {
4208                            remove(journalFolder);
4209                    }
4210            }
4211    
4212            /**
4213             * Returns the number of journal folders where uuid = &#63;.
4214             *
4215             * @param uuid the uuid
4216             * @return the number of matching journal folders
4217             * @throws SystemException if a system exception occurred
4218             */
4219            public int countByUuid(String uuid) throws SystemException {
4220                    Object[] finderArgs = new Object[] { uuid };
4221    
4222                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
4223                                    finderArgs, this);
4224    
4225                    if (count == null) {
4226                            StringBundler query = new StringBundler(2);
4227    
4228                            query.append(_SQL_COUNT_JOURNALFOLDER_WHERE);
4229    
4230                            if (uuid == null) {
4231                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
4232                            }
4233                            else {
4234                                    if (uuid.equals(StringPool.BLANK)) {
4235                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
4236                                    }
4237                                    else {
4238                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
4239                                    }
4240                            }
4241    
4242                            String sql = query.toString();
4243    
4244                            Session session = null;
4245    
4246                            try {
4247                                    session = openSession();
4248    
4249                                    Query q = session.createQuery(sql);
4250    
4251                                    QueryPos qPos = QueryPos.getInstance(q);
4252    
4253                                    if (uuid != null) {
4254                                            qPos.add(uuid);
4255                                    }
4256    
4257                                    count = (Long)q.uniqueResult();
4258                            }
4259                            catch (Exception e) {
4260                                    throw processException(e);
4261                            }
4262                            finally {
4263                                    if (count == null) {
4264                                            count = Long.valueOf(0);
4265                                    }
4266    
4267                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
4268                                            finderArgs, count);
4269    
4270                                    closeSession(session);
4271                            }
4272                    }
4273    
4274                    return count.intValue();
4275            }
4276    
4277            /**
4278             * Returns the number of journal folders where uuid = &#63; and groupId = &#63;.
4279             *
4280             * @param uuid the uuid
4281             * @param groupId the group ID
4282             * @return the number of matching journal folders
4283             * @throws SystemException if a system exception occurred
4284             */
4285            public int countByUUID_G(String uuid, long groupId)
4286                    throws SystemException {
4287                    Object[] finderArgs = new Object[] { uuid, groupId };
4288    
4289                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
4290                                    finderArgs, this);
4291    
4292                    if (count == null) {
4293                            StringBundler query = new StringBundler(3);
4294    
4295                            query.append(_SQL_COUNT_JOURNALFOLDER_WHERE);
4296    
4297                            if (uuid == null) {
4298                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
4299                            }
4300                            else {
4301                                    if (uuid.equals(StringPool.BLANK)) {
4302                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
4303                                    }
4304                                    else {
4305                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
4306                                    }
4307                            }
4308    
4309                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
4310    
4311                            String sql = query.toString();
4312    
4313                            Session session = null;
4314    
4315                            try {
4316                                    session = openSession();
4317    
4318                                    Query q = session.createQuery(sql);
4319    
4320                                    QueryPos qPos = QueryPos.getInstance(q);
4321    
4322                                    if (uuid != null) {
4323                                            qPos.add(uuid);
4324                                    }
4325    
4326                                    qPos.add(groupId);
4327    
4328                                    count = (Long)q.uniqueResult();
4329                            }
4330                            catch (Exception e) {
4331                                    throw processException(e);
4332                            }
4333                            finally {
4334                                    if (count == null) {
4335                                            count = Long.valueOf(0);
4336                                    }
4337    
4338                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
4339                                            finderArgs, count);
4340    
4341                                    closeSession(session);
4342                            }
4343                    }
4344    
4345                    return count.intValue();
4346            }
4347    
4348            /**
4349             * Returns the number of journal folders where uuid = &#63; and companyId = &#63;.
4350             *
4351             * @param uuid the uuid
4352             * @param companyId the company ID
4353             * @return the number of matching journal folders
4354             * @throws SystemException if a system exception occurred
4355             */
4356            public int countByUuid_C(String uuid, long companyId)
4357                    throws SystemException {
4358                    Object[] finderArgs = new Object[] { uuid, companyId };
4359    
4360                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_C,
4361                                    finderArgs, this);
4362    
4363                    if (count == null) {
4364                            StringBundler query = new StringBundler(3);
4365    
4366                            query.append(_SQL_COUNT_JOURNALFOLDER_WHERE);
4367    
4368                            if (uuid == null) {
4369                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
4370                            }
4371                            else {
4372                                    if (uuid.equals(StringPool.BLANK)) {
4373                                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
4374                                    }
4375                                    else {
4376                                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
4377                                    }
4378                            }
4379    
4380                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
4381    
4382                            String sql = query.toString();
4383    
4384                            Session session = null;
4385    
4386                            try {
4387                                    session = openSession();
4388    
4389                                    Query q = session.createQuery(sql);
4390    
4391                                    QueryPos qPos = QueryPos.getInstance(q);
4392    
4393                                    if (uuid != null) {
4394                                            qPos.add(uuid);
4395                                    }
4396    
4397                                    qPos.add(companyId);
4398    
4399                                    count = (Long)q.uniqueResult();
4400                            }
4401                            catch (Exception e) {
4402                                    throw processException(e);
4403                            }
4404                            finally {
4405                                    if (count == null) {
4406                                            count = Long.valueOf(0);
4407                                    }
4408    
4409                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_C,
4410                                            finderArgs, count);
4411    
4412                                    closeSession(session);
4413                            }
4414                    }
4415    
4416                    return count.intValue();
4417            }
4418    
4419            /**
4420             * Returns the number of journal folders where groupId = &#63;.
4421             *
4422             * @param groupId the group ID
4423             * @return the number of matching journal folders
4424             * @throws SystemException if a system exception occurred
4425             */
4426            public int countByGroupId(long groupId) throws SystemException {
4427                    Object[] finderArgs = new Object[] { groupId };
4428    
4429                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
4430                                    finderArgs, this);
4431    
4432                    if (count == null) {
4433                            StringBundler query = new StringBundler(2);
4434    
4435                            query.append(_SQL_COUNT_JOURNALFOLDER_WHERE);
4436    
4437                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
4438    
4439                            String sql = query.toString();
4440    
4441                            Session session = null;
4442    
4443                            try {
4444                                    session = openSession();
4445    
4446                                    Query q = session.createQuery(sql);
4447    
4448                                    QueryPos qPos = QueryPos.getInstance(q);
4449    
4450                                    qPos.add(groupId);
4451    
4452                                    count = (Long)q.uniqueResult();
4453                            }
4454                            catch (Exception e) {
4455                                    throw processException(e);
4456                            }
4457                            finally {
4458                                    if (count == null) {
4459                                            count = Long.valueOf(0);
4460                                    }
4461    
4462                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
4463                                            finderArgs, count);
4464    
4465                                    closeSession(session);
4466                            }
4467                    }
4468    
4469                    return count.intValue();
4470            }
4471    
4472            /**
4473             * Returns the number of journal folders that the user has permission to view where groupId = &#63;.
4474             *
4475             * @param groupId the group ID
4476             * @return the number of matching journal folders that the user has permission to view
4477             * @throws SystemException if a system exception occurred
4478             */
4479            public int filterCountByGroupId(long groupId) throws SystemException {
4480                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4481                            return countByGroupId(groupId);
4482                    }
4483    
4484                    StringBundler query = new StringBundler(2);
4485    
4486                    query.append(_FILTER_SQL_COUNT_JOURNALFOLDER_WHERE);
4487    
4488                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
4489    
4490                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4491                                    JournalFolder.class.getName(),
4492                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4493    
4494                    Session session = null;
4495    
4496                    try {
4497                            session = openSession();
4498    
4499                            SQLQuery q = session.createSQLQuery(sql);
4500    
4501                            q.addScalar(COUNT_COLUMN_NAME,
4502                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
4503    
4504                            QueryPos qPos = QueryPos.getInstance(q);
4505    
4506                            qPos.add(groupId);
4507    
4508                            Long count = (Long)q.uniqueResult();
4509    
4510                            return count.intValue();
4511                    }
4512                    catch (Exception e) {
4513                            throw processException(e);
4514                    }
4515                    finally {
4516                            closeSession(session);
4517                    }
4518            }
4519    
4520            /**
4521             * Returns the number of journal folders where companyId = &#63;.
4522             *
4523             * @param companyId the company ID
4524             * @return the number of matching journal folders
4525             * @throws SystemException if a system exception occurred
4526             */
4527            public int countByCompanyId(long companyId) throws SystemException {
4528                    Object[] finderArgs = new Object[] { companyId };
4529    
4530                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
4531                                    finderArgs, this);
4532    
4533                    if (count == null) {
4534                            StringBundler query = new StringBundler(2);
4535    
4536                            query.append(_SQL_COUNT_JOURNALFOLDER_WHERE);
4537    
4538                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
4539    
4540                            String sql = query.toString();
4541    
4542                            Session session = null;
4543    
4544                            try {
4545                                    session = openSession();
4546    
4547                                    Query q = session.createQuery(sql);
4548    
4549                                    QueryPos qPos = QueryPos.getInstance(q);
4550    
4551                                    qPos.add(companyId);
4552    
4553                                    count = (Long)q.uniqueResult();
4554                            }
4555                            catch (Exception e) {
4556                                    throw processException(e);
4557                            }
4558                            finally {
4559                                    if (count == null) {
4560                                            count = Long.valueOf(0);
4561                                    }
4562    
4563                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
4564                                            finderArgs, count);
4565    
4566                                    closeSession(session);
4567                            }
4568                    }
4569    
4570                    return count.intValue();
4571            }
4572    
4573            /**
4574             * Returns the number of journal folders where groupId = &#63; and parentFolderId = &#63;.
4575             *
4576             * @param groupId the group ID
4577             * @param parentFolderId the parent folder ID
4578             * @return the number of matching journal folders
4579             * @throws SystemException if a system exception occurred
4580             */
4581            public int countByG_P(long groupId, long parentFolderId)
4582                    throws SystemException {
4583                    Object[] finderArgs = new Object[] { groupId, parentFolderId };
4584    
4585                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P,
4586                                    finderArgs, this);
4587    
4588                    if (count == null) {
4589                            StringBundler query = new StringBundler(3);
4590    
4591                            query.append(_SQL_COUNT_JOURNALFOLDER_WHERE);
4592    
4593                            query.append(_FINDER_COLUMN_G_P_GROUPID_2);
4594    
4595                            query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
4596    
4597                            String sql = query.toString();
4598    
4599                            Session session = null;
4600    
4601                            try {
4602                                    session = openSession();
4603    
4604                                    Query q = session.createQuery(sql);
4605    
4606                                    QueryPos qPos = QueryPos.getInstance(q);
4607    
4608                                    qPos.add(groupId);
4609    
4610                                    qPos.add(parentFolderId);
4611    
4612                                    count = (Long)q.uniqueResult();
4613                            }
4614                            catch (Exception e) {
4615                                    throw processException(e);
4616                            }
4617                            finally {
4618                                    if (count == null) {
4619                                            count = Long.valueOf(0);
4620                                    }
4621    
4622                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P, finderArgs,
4623                                            count);
4624    
4625                                    closeSession(session);
4626                            }
4627                    }
4628    
4629                    return count.intValue();
4630            }
4631    
4632            /**
4633             * Returns the number of journal folders that the user has permission to view where groupId = &#63; and parentFolderId = &#63;.
4634             *
4635             * @param groupId the group ID
4636             * @param parentFolderId the parent folder ID
4637             * @return the number of matching journal folders that the user has permission to view
4638             * @throws SystemException if a system exception occurred
4639             */
4640            public int filterCountByG_P(long groupId, long parentFolderId)
4641                    throws SystemException {
4642                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4643                            return countByG_P(groupId, parentFolderId);
4644                    }
4645    
4646                    StringBundler query = new StringBundler(3);
4647    
4648                    query.append(_FILTER_SQL_COUNT_JOURNALFOLDER_WHERE);
4649    
4650                    query.append(_FINDER_COLUMN_G_P_GROUPID_2);
4651    
4652                    query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
4653    
4654                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4655                                    JournalFolder.class.getName(),
4656                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4657    
4658                    Session session = null;
4659    
4660                    try {
4661                            session = openSession();
4662    
4663                            SQLQuery q = session.createSQLQuery(sql);
4664    
4665                            q.addScalar(COUNT_COLUMN_NAME,
4666                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
4667    
4668                            QueryPos qPos = QueryPos.getInstance(q);
4669    
4670                            qPos.add(groupId);
4671    
4672                            qPos.add(parentFolderId);
4673    
4674                            Long count = (Long)q.uniqueResult();
4675    
4676                            return count.intValue();
4677                    }
4678                    catch (Exception e) {
4679                            throw processException(e);
4680                    }
4681                    finally {
4682                            closeSession(session);
4683                    }
4684            }
4685    
4686            /**
4687             * Returns the number of journal folders where groupId = &#63; and name = &#63;.
4688             *
4689             * @param groupId the group ID
4690             * @param name the name
4691             * @return the number of matching journal folders
4692             * @throws SystemException if a system exception occurred
4693             */
4694            public int countByG_N(long groupId, String name) throws SystemException {
4695                    Object[] finderArgs = new Object[] { groupId, name };
4696    
4697                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_N,
4698                                    finderArgs, this);
4699    
4700                    if (count == null) {
4701                            StringBundler query = new StringBundler(3);
4702    
4703                            query.append(_SQL_COUNT_JOURNALFOLDER_WHERE);
4704    
4705                            query.append(_FINDER_COLUMN_G_N_GROUPID_2);
4706    
4707                            if (name == null) {
4708                                    query.append(_FINDER_COLUMN_G_N_NAME_1);
4709                            }
4710                            else {
4711                                    if (name.equals(StringPool.BLANK)) {
4712                                            query.append(_FINDER_COLUMN_G_N_NAME_3);
4713                                    }
4714                                    else {
4715                                            query.append(_FINDER_COLUMN_G_N_NAME_2);
4716                                    }
4717                            }
4718    
4719                            String sql = query.toString();
4720    
4721                            Session session = null;
4722    
4723                            try {
4724                                    session = openSession();
4725    
4726                                    Query q = session.createQuery(sql);
4727    
4728                                    QueryPos qPos = QueryPos.getInstance(q);
4729    
4730                                    qPos.add(groupId);
4731    
4732                                    if (name != null) {
4733                                            qPos.add(name);
4734                                    }
4735    
4736                                    count = (Long)q.uniqueResult();
4737                            }
4738                            catch (Exception e) {
4739                                    throw processException(e);
4740                            }
4741                            finally {
4742                                    if (count == null) {
4743                                            count = Long.valueOf(0);
4744                                    }
4745    
4746                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, finderArgs,
4747                                            count);
4748    
4749                                    closeSession(session);
4750                            }
4751                    }
4752    
4753                    return count.intValue();
4754            }
4755    
4756            /**
4757             * Returns the number of journal folders where groupId = &#63; and parentFolderId = &#63; and name = &#63;.
4758             *
4759             * @param groupId the group ID
4760             * @param parentFolderId the parent folder ID
4761             * @param name the name
4762             * @return the number of matching journal folders
4763             * @throws SystemException if a system exception occurred
4764             */
4765            public int countByG_P_N(long groupId, long parentFolderId, String name)
4766                    throws SystemException {
4767                    Object[] finderArgs = new Object[] { groupId, parentFolderId, name };
4768    
4769                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_N,
4770                                    finderArgs, this);
4771    
4772                    if (count == null) {
4773                            StringBundler query = new StringBundler(4);
4774    
4775                            query.append(_SQL_COUNT_JOURNALFOLDER_WHERE);
4776    
4777                            query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
4778    
4779                            query.append(_FINDER_COLUMN_G_P_N_PARENTFOLDERID_2);
4780    
4781                            if (name == null) {
4782                                    query.append(_FINDER_COLUMN_G_P_N_NAME_1);
4783                            }
4784                            else {
4785                                    if (name.equals(StringPool.BLANK)) {
4786                                            query.append(_FINDER_COLUMN_G_P_N_NAME_3);
4787                                    }
4788                                    else {
4789                                            query.append(_FINDER_COLUMN_G_P_N_NAME_2);
4790                                    }
4791                            }
4792    
4793                            String sql = query.toString();
4794    
4795                            Session session = null;
4796    
4797                            try {
4798                                    session = openSession();
4799    
4800                                    Query q = session.createQuery(sql);
4801    
4802                                    QueryPos qPos = QueryPos.getInstance(q);
4803    
4804                                    qPos.add(groupId);
4805    
4806                                    qPos.add(parentFolderId);
4807    
4808                                    if (name != null) {
4809                                            qPos.add(name);
4810                                    }
4811    
4812                                    count = (Long)q.uniqueResult();
4813                            }
4814                            catch (Exception e) {
4815                                    throw processException(e);
4816                            }
4817                            finally {
4818                                    if (count == null) {
4819                                            count = Long.valueOf(0);
4820                                    }
4821    
4822                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_N,
4823                                            finderArgs, count);
4824    
4825                                    closeSession(session);
4826                            }
4827                    }
4828    
4829                    return count.intValue();
4830            }
4831    
4832            /**
4833             * Returns the number of journal folders.
4834             *
4835             * @return the number of journal folders
4836             * @throws SystemException if a system exception occurred
4837             */
4838            public int countAll() throws SystemException {
4839                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
4840                                    FINDER_ARGS_EMPTY, this);
4841    
4842                    if (count == null) {
4843                            Session session = null;
4844    
4845                            try {
4846                                    session = openSession();
4847    
4848                                    Query q = session.createQuery(_SQL_COUNT_JOURNALFOLDER);
4849    
4850                                    count = (Long)q.uniqueResult();
4851                            }
4852                            catch (Exception e) {
4853                                    throw processException(e);
4854                            }
4855                            finally {
4856                                    if (count == null) {
4857                                            count = Long.valueOf(0);
4858                                    }
4859    
4860                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
4861                                            FINDER_ARGS_EMPTY, count);
4862    
4863                                    closeSession(session);
4864                            }
4865                    }
4866    
4867                    return count.intValue();
4868            }
4869    
4870            /**
4871             * Initializes the journal folder persistence.
4872             */
4873            public void afterPropertiesSet() {
4874                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
4875                                            com.liferay.portal.util.PropsUtil.get(
4876                                                    "value.object.listener.com.liferay.portlet.journal.model.JournalFolder")));
4877    
4878                    if (listenerClassNames.length > 0) {
4879                            try {
4880                                    List<ModelListener<JournalFolder>> listenersList = new ArrayList<ModelListener<JournalFolder>>();
4881    
4882                                    for (String listenerClassName : listenerClassNames) {
4883                                            listenersList.add((ModelListener<JournalFolder>)InstanceFactory.newInstance(
4884                                                            listenerClassName));
4885                                    }
4886    
4887                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
4888                            }
4889                            catch (Exception e) {
4890                                    _log.error(e);
4891                            }
4892                    }
4893            }
4894    
4895            public void destroy() {
4896                    EntityCacheUtil.removeCache(JournalFolderImpl.class.getName());
4897                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
4898                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4899            }
4900    
4901            @BeanReference(type = JournalArticlePersistence.class)
4902            protected JournalArticlePersistence journalArticlePersistence;
4903            @BeanReference(type = JournalArticleImagePersistence.class)
4904            protected JournalArticleImagePersistence journalArticleImagePersistence;
4905            @BeanReference(type = JournalArticleResourcePersistence.class)
4906            protected JournalArticleResourcePersistence journalArticleResourcePersistence;
4907            @BeanReference(type = JournalContentSearchPersistence.class)
4908            protected JournalContentSearchPersistence journalContentSearchPersistence;
4909            @BeanReference(type = JournalFeedPersistence.class)
4910            protected JournalFeedPersistence journalFeedPersistence;
4911            @BeanReference(type = JournalFolderPersistence.class)
4912            protected JournalFolderPersistence journalFolderPersistence;
4913            @BeanReference(type = JournalStructurePersistence.class)
4914            protected JournalStructurePersistence journalStructurePersistence;
4915            @BeanReference(type = JournalTemplatePersistence.class)
4916            protected JournalTemplatePersistence journalTemplatePersistence;
4917            @BeanReference(type = GroupPersistence.class)
4918            protected GroupPersistence groupPersistence;
4919            @BeanReference(type = UserPersistence.class)
4920            protected UserPersistence userPersistence;
4921            @BeanReference(type = ExpandoValuePersistence.class)
4922            protected ExpandoValuePersistence expandoValuePersistence;
4923            private static final String _SQL_SELECT_JOURNALFOLDER = "SELECT journalFolder FROM JournalFolder journalFolder";
4924            private static final String _SQL_SELECT_JOURNALFOLDER_WHERE = "SELECT journalFolder FROM JournalFolder journalFolder WHERE ";
4925            private static final String _SQL_COUNT_JOURNALFOLDER = "SELECT COUNT(journalFolder) FROM JournalFolder journalFolder";
4926            private static final String _SQL_COUNT_JOURNALFOLDER_WHERE = "SELECT COUNT(journalFolder) FROM JournalFolder journalFolder WHERE ";
4927            private static final String _FINDER_COLUMN_UUID_UUID_1 = "journalFolder.uuid IS NULL";
4928            private static final String _FINDER_COLUMN_UUID_UUID_2 = "journalFolder.uuid = ?";
4929            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(journalFolder.uuid IS NULL OR journalFolder.uuid = ?)";
4930            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "journalFolder.uuid IS NULL AND ";
4931            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "journalFolder.uuid = ? AND ";
4932            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(journalFolder.uuid IS NULL OR journalFolder.uuid = ?) AND ";
4933            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "journalFolder.groupId = ?";
4934            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "journalFolder.uuid IS NULL AND ";
4935            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "journalFolder.uuid = ? AND ";
4936            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(journalFolder.uuid IS NULL OR journalFolder.uuid = ?) AND ";
4937            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "journalFolder.companyId = ?";
4938            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "journalFolder.groupId = ?";
4939            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "journalFolder.companyId = ?";
4940            private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "journalFolder.groupId = ? AND ";
4941            private static final String _FINDER_COLUMN_G_P_PARENTFOLDERID_2 = "journalFolder.parentFolderId = ?";
4942            private static final String _FINDER_COLUMN_G_N_GROUPID_2 = "journalFolder.groupId = ? AND ";
4943            private static final String _FINDER_COLUMN_G_N_NAME_1 = "journalFolder.name IS NULL";
4944            private static final String _FINDER_COLUMN_G_N_NAME_2 = "journalFolder.name = ?";
4945            private static final String _FINDER_COLUMN_G_N_NAME_3 = "(journalFolder.name IS NULL OR journalFolder.name = ?)";
4946            private static final String _FINDER_COLUMN_G_P_N_GROUPID_2 = "journalFolder.groupId = ? AND ";
4947            private static final String _FINDER_COLUMN_G_P_N_PARENTFOLDERID_2 = "journalFolder.parentFolderId = ? AND ";
4948            private static final String _FINDER_COLUMN_G_P_N_NAME_1 = "journalFolder.name IS NULL";
4949            private static final String _FINDER_COLUMN_G_P_N_NAME_2 = "journalFolder.name = ?";
4950            private static final String _FINDER_COLUMN_G_P_N_NAME_3 = "(journalFolder.name IS NULL OR journalFolder.name = ?)";
4951            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "journalFolder.folderId";
4952            private static final String _FILTER_SQL_SELECT_JOURNALFOLDER_WHERE = "SELECT DISTINCT {journalFolder.*} FROM JournalFolder journalFolder WHERE ";
4953            private static final String _FILTER_SQL_SELECT_JOURNALFOLDER_NO_INLINE_DISTINCT_WHERE_1 =
4954                    "SELECT {JournalFolder.*} FROM (SELECT DISTINCT journalFolder.folderId FROM JournalFolder journalFolder WHERE ";
4955            private static final String _FILTER_SQL_SELECT_JOURNALFOLDER_NO_INLINE_DISTINCT_WHERE_2 =
4956                    ") TEMP_TABLE INNER JOIN JournalFolder ON TEMP_TABLE.folderId = JournalFolder.folderId";
4957            private static final String _FILTER_SQL_COUNT_JOURNALFOLDER_WHERE = "SELECT COUNT(DISTINCT journalFolder.folderId) AS COUNT_VALUE FROM JournalFolder journalFolder WHERE ";
4958            private static final String _FILTER_ENTITY_ALIAS = "journalFolder";
4959            private static final String _FILTER_ENTITY_TABLE = "JournalFolder";
4960            private static final String _ORDER_BY_ENTITY_ALIAS = "journalFolder.";
4961            private static final String _ORDER_BY_ENTITY_TABLE = "JournalFolder.";
4962            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalFolder exists with the primary key ";
4963            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalFolder exists with the key {";
4964            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
4965            private static Log _log = LogFactoryUtil.getLog(JournalFolderPersistenceImpl.class);
4966            private static JournalFolder _nullJournalFolder = new JournalFolderImpl() {
4967                            @Override
4968                            public Object clone() {
4969                                    return this;
4970                            }
4971    
4972                            @Override
4973                            public CacheModel<JournalFolder> toCacheModel() {
4974                                    return _nullJournalFolderCacheModel;
4975                            }
4976                    };
4977    
4978            private static CacheModel<JournalFolder> _nullJournalFolderCacheModel = new CacheModel<JournalFolder>() {
4979                            public JournalFolder toEntityModel() {
4980                                    return _nullJournalFolder;
4981                            }
4982                    };
4983    }