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