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