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