001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.journal.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
019    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
020    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderPath;
022    import com.liferay.portal.kernel.dao.orm.Query;
023    import com.liferay.portal.kernel.dao.orm.QueryPos;
024    import com.liferay.portal.kernel.dao.orm.QueryUtil;
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.GetterUtil;
030    import com.liferay.portal.kernel.util.InstanceFactory;
031    import com.liferay.portal.kernel.util.OrderByComparator;
032    import com.liferay.portal.kernel.util.StringBundler;
033    import com.liferay.portal.kernel.util.StringPool;
034    import com.liferay.portal.kernel.util.StringUtil;
035    import com.liferay.portal.kernel.util.UnmodifiableList;
036    import com.liferay.portal.kernel.util.Validator;
037    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
038    import com.liferay.portal.model.CacheModel;
039    import com.liferay.portal.model.ModelListener;
040    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
041    
042    import com.liferay.portlet.journal.NoSuchArticleResourceException;
043    import com.liferay.portlet.journal.model.JournalArticleResource;
044    import com.liferay.portlet.journal.model.impl.JournalArticleResourceImpl;
045    import com.liferay.portlet.journal.model.impl.JournalArticleResourceModelImpl;
046    
047    import java.io.Serializable;
048    
049    import java.util.ArrayList;
050    import java.util.Collections;
051    import java.util.List;
052    
053    /**
054     * The persistence implementation for the journal article resource service.
055     *
056     * <p>
057     * Caching information and settings can be found in <code>portal.properties</code>
058     * </p>
059     *
060     * @author Brian Wing Shun Chan
061     * @see JournalArticleResourcePersistence
062     * @see JournalArticleResourceUtil
063     * @generated
064     */
065    public class JournalArticleResourcePersistenceImpl extends BasePersistenceImpl<JournalArticleResource>
066            implements JournalArticleResourcePersistence {
067            /*
068             * NOTE FOR DEVELOPERS:
069             *
070             * Never modify or reference this class directly. Always use {@link JournalArticleResourceUtil} to access the journal article resource persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
071             */
072            public static final String FINDER_CLASS_NAME_ENTITY = JournalArticleResourceImpl.class.getName();
073            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
074                    ".List1";
075            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
076                    ".List2";
077            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
078                            JournalArticleResourceModelImpl.FINDER_CACHE_ENABLED,
079                            JournalArticleResourceImpl.class,
080                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
081            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
082                            JournalArticleResourceModelImpl.FINDER_CACHE_ENABLED,
083                            JournalArticleResourceImpl.class,
084                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
085            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
086                            JournalArticleResourceModelImpl.FINDER_CACHE_ENABLED, Long.class,
087                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
088            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
089                            JournalArticleResourceModelImpl.FINDER_CACHE_ENABLED,
090                            JournalArticleResourceImpl.class,
091                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
092                            new String[] {
093                                    String.class.getName(),
094                                    
095                            Integer.class.getName(), Integer.class.getName(),
096                                    OrderByComparator.class.getName()
097                            });
098            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
099                            JournalArticleResourceModelImpl.FINDER_CACHE_ENABLED,
100                            JournalArticleResourceImpl.class,
101                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
102                            new String[] { String.class.getName() },
103                            JournalArticleResourceModelImpl.UUID_COLUMN_BITMASK);
104            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
105                            JournalArticleResourceModelImpl.FINDER_CACHE_ENABLED, Long.class,
106                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
107                            new String[] { String.class.getName() });
108    
109            /**
110             * Returns all the journal article resources where uuid = &#63;.
111             *
112             * @param uuid the uuid
113             * @return the matching journal article resources
114             * @throws SystemException if a system exception occurred
115             */
116            public List<JournalArticleResource> findByUuid(String uuid)
117                    throws SystemException {
118                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
119            }
120    
121            /**
122             * Returns a range of all the journal article resources where uuid = &#63;.
123             *
124             * <p>
125             * 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.JournalArticleResourceModelImpl}. 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.
126             * </p>
127             *
128             * @param uuid the uuid
129             * @param start the lower bound of the range of journal article resources
130             * @param end the upper bound of the range of journal article resources (not inclusive)
131             * @return the range of matching journal article resources
132             * @throws SystemException if a system exception occurred
133             */
134            public List<JournalArticleResource> findByUuid(String uuid, int start,
135                    int end) throws SystemException {
136                    return findByUuid(uuid, start, end, null);
137            }
138    
139            /**
140             * Returns an ordered range of all the journal article resources where uuid = &#63;.
141             *
142             * <p>
143             * 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.JournalArticleResourceModelImpl}. 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.
144             * </p>
145             *
146             * @param uuid the uuid
147             * @param start the lower bound of the range of journal article resources
148             * @param end the upper bound of the range of journal article resources (not inclusive)
149             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
150             * @return the ordered range of matching journal article resources
151             * @throws SystemException if a system exception occurred
152             */
153            public List<JournalArticleResource> findByUuid(String uuid, int start,
154                    int end, OrderByComparator orderByComparator) throws SystemException {
155                    boolean pagination = true;
156                    FinderPath finderPath = null;
157                    Object[] finderArgs = null;
158    
159                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
160                                    (orderByComparator == null)) {
161                            pagination = false;
162                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
163                            finderArgs = new Object[] { uuid };
164                    }
165                    else {
166                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
167                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
168                    }
169    
170                    List<JournalArticleResource> list = (List<JournalArticleResource>)FinderCacheUtil.getResult(finderPath,
171                                    finderArgs, this);
172    
173                    if ((list != null) && !list.isEmpty()) {
174                            for (JournalArticleResource journalArticleResource : list) {
175                                    if (!Validator.equals(uuid, journalArticleResource.getUuid())) {
176                                            list = null;
177    
178                                            break;
179                                    }
180                            }
181                    }
182    
183                    if (list == null) {
184                            StringBundler query = null;
185    
186                            if (orderByComparator != null) {
187                                    query = new StringBundler(3 +
188                                                    (orderByComparator.getOrderByFields().length * 3));
189                            }
190                            else {
191                                    query = new StringBundler(3);
192                            }
193    
194                            query.append(_SQL_SELECT_JOURNALARTICLERESOURCE_WHERE);
195    
196                            if (uuid == null) {
197                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
198                            }
199                            else {
200                                    if (uuid.equals(StringPool.BLANK)) {
201                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
202                                    }
203                                    else {
204                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
205                                    }
206                            }
207    
208                            if (orderByComparator != null) {
209                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
210                                            orderByComparator);
211                            }
212                            else
213                             if (pagination) {
214                                    query.append(JournalArticleResourceModelImpl.ORDER_BY_JPQL);
215                            }
216    
217                            String sql = query.toString();
218    
219                            Session session = null;
220    
221                            try {
222                                    session = openSession();
223    
224                                    Query q = session.createQuery(sql);
225    
226                                    QueryPos qPos = QueryPos.getInstance(q);
227    
228                                    if (uuid != null) {
229                                            qPos.add(uuid);
230                                    }
231    
232                                    if (!pagination) {
233                                            list = (List<JournalArticleResource>)QueryUtil.list(q,
234                                                            getDialect(), start, end, false);
235    
236                                            Collections.sort(list);
237    
238                                            list = new UnmodifiableList<JournalArticleResource>(list);
239                                    }
240                                    else {
241                                            list = (List<JournalArticleResource>)QueryUtil.list(q,
242                                                            getDialect(), start, end);
243                                    }
244    
245                                    cacheResult(list);
246    
247                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
248                            }
249                            catch (Exception e) {
250                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
251    
252                                    throw processException(e);
253                            }
254                            finally {
255                                    closeSession(session);
256                            }
257                    }
258    
259                    return list;
260            }
261    
262            /**
263             * Returns the first journal article resource in the ordered set where uuid = &#63;.
264             *
265             * @param uuid the uuid
266             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
267             * @return the first matching journal article resource
268             * @throws com.liferay.portlet.journal.NoSuchArticleResourceException if a matching journal article resource could not be found
269             * @throws SystemException if a system exception occurred
270             */
271            public JournalArticleResource findByUuid_First(String uuid,
272                    OrderByComparator orderByComparator)
273                    throws NoSuchArticleResourceException, SystemException {
274                    JournalArticleResource journalArticleResource = fetchByUuid_First(uuid,
275                                    orderByComparator);
276    
277                    if (journalArticleResource != null) {
278                            return journalArticleResource;
279                    }
280    
281                    StringBundler msg = new StringBundler(4);
282    
283                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
284    
285                    msg.append("uuid=");
286                    msg.append(uuid);
287    
288                    msg.append(StringPool.CLOSE_CURLY_BRACE);
289    
290                    throw new NoSuchArticleResourceException(msg.toString());
291            }
292    
293            /**
294             * Returns the first journal article resource in the ordered set where uuid = &#63;.
295             *
296             * @param uuid the uuid
297             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
298             * @return the first matching journal article resource, or <code>null</code> if a matching journal article resource could not be found
299             * @throws SystemException if a system exception occurred
300             */
301            public JournalArticleResource fetchByUuid_First(String uuid,
302                    OrderByComparator orderByComparator) throws SystemException {
303                    List<JournalArticleResource> list = findByUuid(uuid, 0, 1,
304                                    orderByComparator);
305    
306                    if (!list.isEmpty()) {
307                            return list.get(0);
308                    }
309    
310                    return null;
311            }
312    
313            /**
314             * Returns the last journal article resource in the ordered set where uuid = &#63;.
315             *
316             * @param uuid the uuid
317             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
318             * @return the last matching journal article resource
319             * @throws com.liferay.portlet.journal.NoSuchArticleResourceException if a matching journal article resource could not be found
320             * @throws SystemException if a system exception occurred
321             */
322            public JournalArticleResource findByUuid_Last(String uuid,
323                    OrderByComparator orderByComparator)
324                    throws NoSuchArticleResourceException, SystemException {
325                    JournalArticleResource journalArticleResource = fetchByUuid_Last(uuid,
326                                    orderByComparator);
327    
328                    if (journalArticleResource != null) {
329                            return journalArticleResource;
330                    }
331    
332                    StringBundler msg = new StringBundler(4);
333    
334                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
335    
336                    msg.append("uuid=");
337                    msg.append(uuid);
338    
339                    msg.append(StringPool.CLOSE_CURLY_BRACE);
340    
341                    throw new NoSuchArticleResourceException(msg.toString());
342            }
343    
344            /**
345             * Returns the last journal article resource in the ordered set where uuid = &#63;.
346             *
347             * @param uuid the uuid
348             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
349             * @return the last matching journal article resource, or <code>null</code> if a matching journal article resource could not be found
350             * @throws SystemException if a system exception occurred
351             */
352            public JournalArticleResource fetchByUuid_Last(String uuid,
353                    OrderByComparator orderByComparator) throws SystemException {
354                    int count = countByUuid(uuid);
355    
356                    List<JournalArticleResource> list = findByUuid(uuid, count - 1, count,
357                                    orderByComparator);
358    
359                    if (!list.isEmpty()) {
360                            return list.get(0);
361                    }
362    
363                    return null;
364            }
365    
366            /**
367             * Returns the journal article resources before and after the current journal article resource in the ordered set where uuid = &#63;.
368             *
369             * @param resourcePrimKey the primary key of the current journal article resource
370             * @param uuid the uuid
371             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
372             * @return the previous, current, and next journal article resource
373             * @throws com.liferay.portlet.journal.NoSuchArticleResourceException if a journal article resource with the primary key could not be found
374             * @throws SystemException if a system exception occurred
375             */
376            public JournalArticleResource[] findByUuid_PrevAndNext(
377                    long resourcePrimKey, String uuid, OrderByComparator orderByComparator)
378                    throws NoSuchArticleResourceException, SystemException {
379                    JournalArticleResource journalArticleResource = findByPrimaryKey(resourcePrimKey);
380    
381                    Session session = null;
382    
383                    try {
384                            session = openSession();
385    
386                            JournalArticleResource[] array = new JournalArticleResourceImpl[3];
387    
388                            array[0] = getByUuid_PrevAndNext(session, journalArticleResource,
389                                            uuid, orderByComparator, true);
390    
391                            array[1] = journalArticleResource;
392    
393                            array[2] = getByUuid_PrevAndNext(session, journalArticleResource,
394                                            uuid, orderByComparator, false);
395    
396                            return array;
397                    }
398                    catch (Exception e) {
399                            throw processException(e);
400                    }
401                    finally {
402                            closeSession(session);
403                    }
404            }
405    
406            protected JournalArticleResource getByUuid_PrevAndNext(Session session,
407                    JournalArticleResource journalArticleResource, String uuid,
408                    OrderByComparator orderByComparator, boolean previous) {
409                    StringBundler query = null;
410    
411                    if (orderByComparator != null) {
412                            query = new StringBundler(6 +
413                                            (orderByComparator.getOrderByFields().length * 6));
414                    }
415                    else {
416                            query = new StringBundler(3);
417                    }
418    
419                    query.append(_SQL_SELECT_JOURNALARTICLERESOURCE_WHERE);
420    
421                    if (uuid == null) {
422                            query.append(_FINDER_COLUMN_UUID_UUID_1);
423                    }
424                    else {
425                            if (uuid.equals(StringPool.BLANK)) {
426                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
427                            }
428                            else {
429                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
430                            }
431                    }
432    
433                    if (orderByComparator != null) {
434                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
435    
436                            if (orderByConditionFields.length > 0) {
437                                    query.append(WHERE_AND);
438                            }
439    
440                            for (int i = 0; i < orderByConditionFields.length; i++) {
441                                    query.append(_ORDER_BY_ENTITY_ALIAS);
442                                    query.append(orderByConditionFields[i]);
443    
444                                    if ((i + 1) < orderByConditionFields.length) {
445                                            if (orderByComparator.isAscending() ^ previous) {
446                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
447                                            }
448                                            else {
449                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
450                                            }
451                                    }
452                                    else {
453                                            if (orderByComparator.isAscending() ^ previous) {
454                                                    query.append(WHERE_GREATER_THAN);
455                                            }
456                                            else {
457                                                    query.append(WHERE_LESSER_THAN);
458                                            }
459                                    }
460                            }
461    
462                            query.append(ORDER_BY_CLAUSE);
463    
464                            String[] orderByFields = orderByComparator.getOrderByFields();
465    
466                            for (int i = 0; i < orderByFields.length; i++) {
467                                    query.append(_ORDER_BY_ENTITY_ALIAS);
468                                    query.append(orderByFields[i]);
469    
470                                    if ((i + 1) < orderByFields.length) {
471                                            if (orderByComparator.isAscending() ^ previous) {
472                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
473                                            }
474                                            else {
475                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
476                                            }
477                                    }
478                                    else {
479                                            if (orderByComparator.isAscending() ^ previous) {
480                                                    query.append(ORDER_BY_ASC);
481                                            }
482                                            else {
483                                                    query.append(ORDER_BY_DESC);
484                                            }
485                                    }
486                            }
487                    }
488                    else {
489                            query.append(JournalArticleResourceModelImpl.ORDER_BY_JPQL);
490                    }
491    
492                    String sql = query.toString();
493    
494                    Query q = session.createQuery(sql);
495    
496                    q.setFirstResult(0);
497                    q.setMaxResults(2);
498    
499                    QueryPos qPos = QueryPos.getInstance(q);
500    
501                    if (uuid != null) {
502                            qPos.add(uuid);
503                    }
504    
505                    if (orderByComparator != null) {
506                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticleResource);
507    
508                            for (Object value : values) {
509                                    qPos.add(value);
510                            }
511                    }
512    
513                    List<JournalArticleResource> list = q.list();
514    
515                    if (list.size() == 2) {
516                            return list.get(1);
517                    }
518                    else {
519                            return null;
520                    }
521            }
522    
523            /**
524             * Removes all the journal article resources where uuid = &#63; from the database.
525             *
526             * @param uuid the uuid
527             * @throws SystemException if a system exception occurred
528             */
529            public void removeByUuid(String uuid) throws SystemException {
530                    for (JournalArticleResource journalArticleResource : findByUuid(uuid,
531                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
532                            remove(journalArticleResource);
533                    }
534            }
535    
536            /**
537             * Returns the number of journal article resources where uuid = &#63;.
538             *
539             * @param uuid the uuid
540             * @return the number of matching journal article resources
541             * @throws SystemException if a system exception occurred
542             */
543            public int countByUuid(String uuid) throws SystemException {
544                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
545    
546                    Object[] finderArgs = new Object[] { uuid };
547    
548                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
549                                    this);
550    
551                    if (count == null) {
552                            StringBundler query = new StringBundler(2);
553    
554                            query.append(_SQL_COUNT_JOURNALARTICLERESOURCE_WHERE);
555    
556                            if (uuid == null) {
557                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
558                            }
559                            else {
560                                    if (uuid.equals(StringPool.BLANK)) {
561                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
562                                    }
563                                    else {
564                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
565                                    }
566                            }
567    
568                            String sql = query.toString();
569    
570                            Session session = null;
571    
572                            try {
573                                    session = openSession();
574    
575                                    Query q = session.createQuery(sql);
576    
577                                    QueryPos qPos = QueryPos.getInstance(q);
578    
579                                    if (uuid != null) {
580                                            qPos.add(uuid);
581                                    }
582    
583                                    count = (Long)q.uniqueResult();
584    
585                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
586                            }
587                            catch (Exception e) {
588                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
589    
590                                    throw processException(e);
591                            }
592                            finally {
593                                    closeSession(session);
594                            }
595                    }
596    
597                    return count.intValue();
598            }
599    
600            private static final String _FINDER_COLUMN_UUID_UUID_1 = "journalArticleResource.uuid IS NULL";
601            private static final String _FINDER_COLUMN_UUID_UUID_2 = "journalArticleResource.uuid = ?";
602            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(journalArticleResource.uuid IS NULL OR journalArticleResource.uuid = ?)";
603            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
604                            JournalArticleResourceModelImpl.FINDER_CACHE_ENABLED,
605                            JournalArticleResourceImpl.class, FINDER_CLASS_NAME_ENTITY,
606                            "fetchByUUID_G",
607                            new String[] { String.class.getName(), Long.class.getName() },
608                            JournalArticleResourceModelImpl.UUID_COLUMN_BITMASK |
609                            JournalArticleResourceModelImpl.GROUPID_COLUMN_BITMASK);
610            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
611                            JournalArticleResourceModelImpl.FINDER_CACHE_ENABLED, Long.class,
612                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
613                            new String[] { String.class.getName(), Long.class.getName() });
614    
615            /**
616             * Returns the journal article resource where uuid = &#63; and groupId = &#63; or throws a {@link com.liferay.portlet.journal.NoSuchArticleResourceException} if it could not be found.
617             *
618             * @param uuid the uuid
619             * @param groupId the group ID
620             * @return the matching journal article resource
621             * @throws com.liferay.portlet.journal.NoSuchArticleResourceException if a matching journal article resource could not be found
622             * @throws SystemException if a system exception occurred
623             */
624            public JournalArticleResource findByUUID_G(String uuid, long groupId)
625                    throws NoSuchArticleResourceException, SystemException {
626                    JournalArticleResource journalArticleResource = fetchByUUID_G(uuid,
627                                    groupId);
628    
629                    if (journalArticleResource == null) {
630                            StringBundler msg = new StringBundler(6);
631    
632                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
633    
634                            msg.append("uuid=");
635                            msg.append(uuid);
636    
637                            msg.append(", groupId=");
638                            msg.append(groupId);
639    
640                            msg.append(StringPool.CLOSE_CURLY_BRACE);
641    
642                            if (_log.isWarnEnabled()) {
643                                    _log.warn(msg.toString());
644                            }
645    
646                            throw new NoSuchArticleResourceException(msg.toString());
647                    }
648    
649                    return journalArticleResource;
650            }
651    
652            /**
653             * Returns the journal article resource where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
654             *
655             * @param uuid the uuid
656             * @param groupId the group ID
657             * @return the matching journal article resource, or <code>null</code> if a matching journal article resource could not be found
658             * @throws SystemException if a system exception occurred
659             */
660            public JournalArticleResource fetchByUUID_G(String uuid, long groupId)
661                    throws SystemException {
662                    return fetchByUUID_G(uuid, groupId, true);
663            }
664    
665            /**
666             * Returns the journal article resource where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
667             *
668             * @param uuid the uuid
669             * @param groupId the group ID
670             * @param retrieveFromCache whether to use the finder cache
671             * @return the matching journal article resource, or <code>null</code> if a matching journal article resource could not be found
672             * @throws SystemException if a system exception occurred
673             */
674            public JournalArticleResource fetchByUUID_G(String uuid, long groupId,
675                    boolean retrieveFromCache) throws SystemException {
676                    Object[] finderArgs = new Object[] { uuid, groupId };
677    
678                    Object result = null;
679    
680                    if (retrieveFromCache) {
681                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
682                                            finderArgs, this);
683                    }
684    
685                    if (result instanceof JournalArticleResource) {
686                            JournalArticleResource journalArticleResource = (JournalArticleResource)result;
687    
688                            if (!Validator.equals(uuid, journalArticleResource.getUuid()) ||
689                                            (groupId != journalArticleResource.getGroupId())) {
690                                    result = null;
691                            }
692                    }
693    
694                    if (result == null) {
695                            StringBundler query = new StringBundler(4);
696    
697                            query.append(_SQL_SELECT_JOURNALARTICLERESOURCE_WHERE);
698    
699                            if (uuid == null) {
700                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
701                            }
702                            else {
703                                    if (uuid.equals(StringPool.BLANK)) {
704                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
705                                    }
706                                    else {
707                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
708                                    }
709                            }
710    
711                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
712    
713                            String sql = query.toString();
714    
715                            Session session = null;
716    
717                            try {
718                                    session = openSession();
719    
720                                    Query q = session.createQuery(sql);
721    
722                                    QueryPos qPos = QueryPos.getInstance(q);
723    
724                                    if (uuid != null) {
725                                            qPos.add(uuid);
726                                    }
727    
728                                    qPos.add(groupId);
729    
730                                    List<JournalArticleResource> list = q.list();
731    
732                                    if (list.isEmpty()) {
733                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
734                                                    finderArgs, list);
735                                    }
736                                    else {
737                                            JournalArticleResource journalArticleResource = list.get(0);
738    
739                                            result = journalArticleResource;
740    
741                                            cacheResult(journalArticleResource);
742    
743                                            if ((journalArticleResource.getUuid() == null) ||
744                                                            !journalArticleResource.getUuid().equals(uuid) ||
745                                                            (journalArticleResource.getGroupId() != groupId)) {
746                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
747                                                            finderArgs, journalArticleResource);
748                                            }
749                                    }
750                            }
751                            catch (Exception e) {
752                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
753                                            finderArgs);
754    
755                                    throw processException(e);
756                            }
757                            finally {
758                                    closeSession(session);
759                            }
760                    }
761    
762                    if (result instanceof List<?>) {
763                            return null;
764                    }
765                    else {
766                            return (JournalArticleResource)result;
767                    }
768            }
769    
770            /**
771             * Removes the journal article resource where uuid = &#63; and groupId = &#63; from the database.
772             *
773             * @param uuid the uuid
774             * @param groupId the group ID
775             * @return the journal article resource that was removed
776             * @throws SystemException if a system exception occurred
777             */
778            public JournalArticleResource removeByUUID_G(String uuid, long groupId)
779                    throws NoSuchArticleResourceException, SystemException {
780                    JournalArticleResource journalArticleResource = findByUUID_G(uuid,
781                                    groupId);
782    
783                    return remove(journalArticleResource);
784            }
785    
786            /**
787             * Returns the number of journal article resources where uuid = &#63; and groupId = &#63;.
788             *
789             * @param uuid the uuid
790             * @param groupId the group ID
791             * @return the number of matching journal article resources
792             * @throws SystemException if a system exception occurred
793             */
794            public int countByUUID_G(String uuid, long groupId)
795                    throws SystemException {
796                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
797    
798                    Object[] finderArgs = new Object[] { uuid, groupId };
799    
800                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
801                                    this);
802    
803                    if (count == null) {
804                            StringBundler query = new StringBundler(3);
805    
806                            query.append(_SQL_COUNT_JOURNALARTICLERESOURCE_WHERE);
807    
808                            if (uuid == null) {
809                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
810                            }
811                            else {
812                                    if (uuid.equals(StringPool.BLANK)) {
813                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
814                                    }
815                                    else {
816                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
817                                    }
818                            }
819    
820                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
821    
822                            String sql = query.toString();
823    
824                            Session session = null;
825    
826                            try {
827                                    session = openSession();
828    
829                                    Query q = session.createQuery(sql);
830    
831                                    QueryPos qPos = QueryPos.getInstance(q);
832    
833                                    if (uuid != null) {
834                                            qPos.add(uuid);
835                                    }
836    
837                                    qPos.add(groupId);
838    
839                                    count = (Long)q.uniqueResult();
840    
841                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
842                            }
843                            catch (Exception e) {
844                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
845    
846                                    throw processException(e);
847                            }
848                            finally {
849                                    closeSession(session);
850                            }
851                    }
852    
853                    return count.intValue();
854            }
855    
856            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "journalArticleResource.uuid IS NULL AND ";
857            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "journalArticleResource.uuid = ? AND ";
858            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(journalArticleResource.uuid IS NULL OR journalArticleResource.uuid = ?) AND ";
859            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "journalArticleResource.groupId = ?";
860            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
861                            JournalArticleResourceModelImpl.FINDER_CACHE_ENABLED,
862                            JournalArticleResourceImpl.class,
863                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
864                            new String[] {
865                                    Long.class.getName(),
866                                    
867                            Integer.class.getName(), Integer.class.getName(),
868                                    OrderByComparator.class.getName()
869                            });
870            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
871                    new FinderPath(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
872                            JournalArticleResourceModelImpl.FINDER_CACHE_ENABLED,
873                            JournalArticleResourceImpl.class,
874                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
875                            new String[] { Long.class.getName() },
876                            JournalArticleResourceModelImpl.GROUPID_COLUMN_BITMASK);
877            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
878                            JournalArticleResourceModelImpl.FINDER_CACHE_ENABLED, Long.class,
879                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
880                            new String[] { Long.class.getName() });
881    
882            /**
883             * Returns all the journal article resources where groupId = &#63;.
884             *
885             * @param groupId the group ID
886             * @return the matching journal article resources
887             * @throws SystemException if a system exception occurred
888             */
889            public List<JournalArticleResource> findByGroupId(long groupId)
890                    throws SystemException {
891                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
892            }
893    
894            /**
895             * Returns a range of all the journal article resources where groupId = &#63;.
896             *
897             * <p>
898             * 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.JournalArticleResourceModelImpl}. 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.
899             * </p>
900             *
901             * @param groupId the group ID
902             * @param start the lower bound of the range of journal article resources
903             * @param end the upper bound of the range of journal article resources (not inclusive)
904             * @return the range of matching journal article resources
905             * @throws SystemException if a system exception occurred
906             */
907            public List<JournalArticleResource> findByGroupId(long groupId, int start,
908                    int end) throws SystemException {
909                    return findByGroupId(groupId, start, end, null);
910            }
911    
912            /**
913             * Returns an ordered range of all the journal article resources where groupId = &#63;.
914             *
915             * <p>
916             * 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.JournalArticleResourceModelImpl}. 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.
917             * </p>
918             *
919             * @param groupId the group ID
920             * @param start the lower bound of the range of journal article resources
921             * @param end the upper bound of the range of journal article resources (not inclusive)
922             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
923             * @return the ordered range of matching journal article resources
924             * @throws SystemException if a system exception occurred
925             */
926            public List<JournalArticleResource> findByGroupId(long groupId, int start,
927                    int end, OrderByComparator orderByComparator) throws SystemException {
928                    boolean pagination = true;
929                    FinderPath finderPath = null;
930                    Object[] finderArgs = null;
931    
932                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
933                                    (orderByComparator == null)) {
934                            pagination = false;
935                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
936                            finderArgs = new Object[] { groupId };
937                    }
938                    else {
939                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
940                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
941                    }
942    
943                    List<JournalArticleResource> list = (List<JournalArticleResource>)FinderCacheUtil.getResult(finderPath,
944                                    finderArgs, this);
945    
946                    if ((list != null) && !list.isEmpty()) {
947                            for (JournalArticleResource journalArticleResource : list) {
948                                    if ((groupId != journalArticleResource.getGroupId())) {
949                                            list = null;
950    
951                                            break;
952                                    }
953                            }
954                    }
955    
956                    if (list == null) {
957                            StringBundler query = null;
958    
959                            if (orderByComparator != null) {
960                                    query = new StringBundler(3 +
961                                                    (orderByComparator.getOrderByFields().length * 3));
962                            }
963                            else {
964                                    query = new StringBundler(3);
965                            }
966    
967                            query.append(_SQL_SELECT_JOURNALARTICLERESOURCE_WHERE);
968    
969                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
970    
971                            if (orderByComparator != null) {
972                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
973                                            orderByComparator);
974                            }
975                            else
976                             if (pagination) {
977                                    query.append(JournalArticleResourceModelImpl.ORDER_BY_JPQL);
978                            }
979    
980                            String sql = query.toString();
981    
982                            Session session = null;
983    
984                            try {
985                                    session = openSession();
986    
987                                    Query q = session.createQuery(sql);
988    
989                                    QueryPos qPos = QueryPos.getInstance(q);
990    
991                                    qPos.add(groupId);
992    
993                                    if (!pagination) {
994                                            list = (List<JournalArticleResource>)QueryUtil.list(q,
995                                                            getDialect(), start, end, false);
996    
997                                            Collections.sort(list);
998    
999                                            list = new UnmodifiableList<JournalArticleResource>(list);
1000                                    }
1001                                    else {
1002                                            list = (List<JournalArticleResource>)QueryUtil.list(q,
1003                                                            getDialect(), start, end);
1004                                    }
1005    
1006                                    cacheResult(list);
1007    
1008                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1009                            }
1010                            catch (Exception e) {
1011                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1012    
1013                                    throw processException(e);
1014                            }
1015                            finally {
1016                                    closeSession(session);
1017                            }
1018                    }
1019    
1020                    return list;
1021            }
1022    
1023            /**
1024             * Returns the first journal article resource in the ordered set where groupId = &#63;.
1025             *
1026             * @param groupId the group ID
1027             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1028             * @return the first matching journal article resource
1029             * @throws com.liferay.portlet.journal.NoSuchArticleResourceException if a matching journal article resource could not be found
1030             * @throws SystemException if a system exception occurred
1031             */
1032            public JournalArticleResource findByGroupId_First(long groupId,
1033                    OrderByComparator orderByComparator)
1034                    throws NoSuchArticleResourceException, SystemException {
1035                    JournalArticleResource journalArticleResource = fetchByGroupId_First(groupId,
1036                                    orderByComparator);
1037    
1038                    if (journalArticleResource != null) {
1039                            return journalArticleResource;
1040                    }
1041    
1042                    StringBundler msg = new StringBundler(4);
1043    
1044                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1045    
1046                    msg.append("groupId=");
1047                    msg.append(groupId);
1048    
1049                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1050    
1051                    throw new NoSuchArticleResourceException(msg.toString());
1052            }
1053    
1054            /**
1055             * Returns the first journal article resource in the ordered set where groupId = &#63;.
1056             *
1057             * @param groupId the group ID
1058             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1059             * @return the first matching journal article resource, or <code>null</code> if a matching journal article resource could not be found
1060             * @throws SystemException if a system exception occurred
1061             */
1062            public JournalArticleResource fetchByGroupId_First(long groupId,
1063                    OrderByComparator orderByComparator) throws SystemException {
1064                    List<JournalArticleResource> list = findByGroupId(groupId, 0, 1,
1065                                    orderByComparator);
1066    
1067                    if (!list.isEmpty()) {
1068                            return list.get(0);
1069                    }
1070    
1071                    return null;
1072            }
1073    
1074            /**
1075             * Returns the last journal article resource in the ordered set where groupId = &#63;.
1076             *
1077             * @param groupId the group ID
1078             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1079             * @return the last matching journal article resource
1080             * @throws com.liferay.portlet.journal.NoSuchArticleResourceException if a matching journal article resource could not be found
1081             * @throws SystemException if a system exception occurred
1082             */
1083            public JournalArticleResource findByGroupId_Last(long groupId,
1084                    OrderByComparator orderByComparator)
1085                    throws NoSuchArticleResourceException, SystemException {
1086                    JournalArticleResource journalArticleResource = fetchByGroupId_Last(groupId,
1087                                    orderByComparator);
1088    
1089                    if (journalArticleResource != null) {
1090                            return journalArticleResource;
1091                    }
1092    
1093                    StringBundler msg = new StringBundler(4);
1094    
1095                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1096    
1097                    msg.append("groupId=");
1098                    msg.append(groupId);
1099    
1100                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1101    
1102                    throw new NoSuchArticleResourceException(msg.toString());
1103            }
1104    
1105            /**
1106             * Returns the last journal article resource in the ordered set where groupId = &#63;.
1107             *
1108             * @param groupId the group ID
1109             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1110             * @return the last matching journal article resource, or <code>null</code> if a matching journal article resource could not be found
1111             * @throws SystemException if a system exception occurred
1112             */
1113            public JournalArticleResource fetchByGroupId_Last(long groupId,
1114                    OrderByComparator orderByComparator) throws SystemException {
1115                    int count = countByGroupId(groupId);
1116    
1117                    List<JournalArticleResource> list = findByGroupId(groupId, count - 1,
1118                                    count, orderByComparator);
1119    
1120                    if (!list.isEmpty()) {
1121                            return list.get(0);
1122                    }
1123    
1124                    return null;
1125            }
1126    
1127            /**
1128             * Returns the journal article resources before and after the current journal article resource in the ordered set where groupId = &#63;.
1129             *
1130             * @param resourcePrimKey the primary key of the current journal article resource
1131             * @param groupId the group ID
1132             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1133             * @return the previous, current, and next journal article resource
1134             * @throws com.liferay.portlet.journal.NoSuchArticleResourceException if a journal article resource with the primary key could not be found
1135             * @throws SystemException if a system exception occurred
1136             */
1137            public JournalArticleResource[] findByGroupId_PrevAndNext(
1138                    long resourcePrimKey, long groupId, OrderByComparator orderByComparator)
1139                    throws NoSuchArticleResourceException, SystemException {
1140                    JournalArticleResource journalArticleResource = findByPrimaryKey(resourcePrimKey);
1141    
1142                    Session session = null;
1143    
1144                    try {
1145                            session = openSession();
1146    
1147                            JournalArticleResource[] array = new JournalArticleResourceImpl[3];
1148    
1149                            array[0] = getByGroupId_PrevAndNext(session,
1150                                            journalArticleResource, groupId, orderByComparator, true);
1151    
1152                            array[1] = journalArticleResource;
1153    
1154                            array[2] = getByGroupId_PrevAndNext(session,
1155                                            journalArticleResource, groupId, orderByComparator, false);
1156    
1157                            return array;
1158                    }
1159                    catch (Exception e) {
1160                            throw processException(e);
1161                    }
1162                    finally {
1163                            closeSession(session);
1164                    }
1165            }
1166    
1167            protected JournalArticleResource getByGroupId_PrevAndNext(Session session,
1168                    JournalArticleResource journalArticleResource, long groupId,
1169                    OrderByComparator orderByComparator, boolean previous) {
1170                    StringBundler query = null;
1171    
1172                    if (orderByComparator != null) {
1173                            query = new StringBundler(6 +
1174                                            (orderByComparator.getOrderByFields().length * 6));
1175                    }
1176                    else {
1177                            query = new StringBundler(3);
1178                    }
1179    
1180                    query.append(_SQL_SELECT_JOURNALARTICLERESOURCE_WHERE);
1181    
1182                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1183    
1184                    if (orderByComparator != null) {
1185                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1186    
1187                            if (orderByConditionFields.length > 0) {
1188                                    query.append(WHERE_AND);
1189                            }
1190    
1191                            for (int i = 0; i < orderByConditionFields.length; i++) {
1192                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1193                                    query.append(orderByConditionFields[i]);
1194    
1195                                    if ((i + 1) < orderByConditionFields.length) {
1196                                            if (orderByComparator.isAscending() ^ previous) {
1197                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1198                                            }
1199                                            else {
1200                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1201                                            }
1202                                    }
1203                                    else {
1204                                            if (orderByComparator.isAscending() ^ previous) {
1205                                                    query.append(WHERE_GREATER_THAN);
1206                                            }
1207                                            else {
1208                                                    query.append(WHERE_LESSER_THAN);
1209                                            }
1210                                    }
1211                            }
1212    
1213                            query.append(ORDER_BY_CLAUSE);
1214    
1215                            String[] orderByFields = orderByComparator.getOrderByFields();
1216    
1217                            for (int i = 0; i < orderByFields.length; i++) {
1218                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1219                                    query.append(orderByFields[i]);
1220    
1221                                    if ((i + 1) < orderByFields.length) {
1222                                            if (orderByComparator.isAscending() ^ previous) {
1223                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1224                                            }
1225                                            else {
1226                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1227                                            }
1228                                    }
1229                                    else {
1230                                            if (orderByComparator.isAscending() ^ previous) {
1231                                                    query.append(ORDER_BY_ASC);
1232                                            }
1233                                            else {
1234                                                    query.append(ORDER_BY_DESC);
1235                                            }
1236                                    }
1237                            }
1238                    }
1239                    else {
1240                            query.append(JournalArticleResourceModelImpl.ORDER_BY_JPQL);
1241                    }
1242    
1243                    String sql = query.toString();
1244    
1245                    Query q = session.createQuery(sql);
1246    
1247                    q.setFirstResult(0);
1248                    q.setMaxResults(2);
1249    
1250                    QueryPos qPos = QueryPos.getInstance(q);
1251    
1252                    qPos.add(groupId);
1253    
1254                    if (orderByComparator != null) {
1255                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticleResource);
1256    
1257                            for (Object value : values) {
1258                                    qPos.add(value);
1259                            }
1260                    }
1261    
1262                    List<JournalArticleResource> list = q.list();
1263    
1264                    if (list.size() == 2) {
1265                            return list.get(1);
1266                    }
1267                    else {
1268                            return null;
1269                    }
1270            }
1271    
1272            /**
1273             * Removes all the journal article resources where groupId = &#63; from the database.
1274             *
1275             * @param groupId the group ID
1276             * @throws SystemException if a system exception occurred
1277             */
1278            public void removeByGroupId(long groupId) throws SystemException {
1279                    for (JournalArticleResource journalArticleResource : findByGroupId(
1280                                    groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1281                            remove(journalArticleResource);
1282                    }
1283            }
1284    
1285            /**
1286             * Returns the number of journal article resources where groupId = &#63;.
1287             *
1288             * @param groupId the group ID
1289             * @return the number of matching journal article resources
1290             * @throws SystemException if a system exception occurred
1291             */
1292            public int countByGroupId(long groupId) throws SystemException {
1293                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
1294    
1295                    Object[] finderArgs = new Object[] { groupId };
1296    
1297                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1298                                    this);
1299    
1300                    if (count == null) {
1301                            StringBundler query = new StringBundler(2);
1302    
1303                            query.append(_SQL_COUNT_JOURNALARTICLERESOURCE_WHERE);
1304    
1305                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1306    
1307                            String sql = query.toString();
1308    
1309                            Session session = null;
1310    
1311                            try {
1312                                    session = openSession();
1313    
1314                                    Query q = session.createQuery(sql);
1315    
1316                                    QueryPos qPos = QueryPos.getInstance(q);
1317    
1318                                    qPos.add(groupId);
1319    
1320                                    count = (Long)q.uniqueResult();
1321    
1322                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1323                            }
1324                            catch (Exception e) {
1325                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1326    
1327                                    throw processException(e);
1328                            }
1329                            finally {
1330                                    closeSession(session);
1331                            }
1332                    }
1333    
1334                    return count.intValue();
1335            }
1336    
1337            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "journalArticleResource.groupId = ?";
1338            public static final FinderPath FINDER_PATH_FETCH_BY_G_A = new FinderPath(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
1339                            JournalArticleResourceModelImpl.FINDER_CACHE_ENABLED,
1340                            JournalArticleResourceImpl.class, FINDER_CLASS_NAME_ENTITY,
1341                            "fetchByG_A",
1342                            new String[] { Long.class.getName(), String.class.getName() },
1343                            JournalArticleResourceModelImpl.GROUPID_COLUMN_BITMASK |
1344                            JournalArticleResourceModelImpl.ARTICLEID_COLUMN_BITMASK);
1345            public static final FinderPath FINDER_PATH_COUNT_BY_G_A = new FinderPath(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
1346                            JournalArticleResourceModelImpl.FINDER_CACHE_ENABLED, Long.class,
1347                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A",
1348                            new String[] { Long.class.getName(), String.class.getName() });
1349    
1350            /**
1351             * Returns the journal article resource where groupId = &#63; and articleId = &#63; or throws a {@link com.liferay.portlet.journal.NoSuchArticleResourceException} if it could not be found.
1352             *
1353             * @param groupId the group ID
1354             * @param articleId the article ID
1355             * @return the matching journal article resource
1356             * @throws com.liferay.portlet.journal.NoSuchArticleResourceException if a matching journal article resource could not be found
1357             * @throws SystemException if a system exception occurred
1358             */
1359            public JournalArticleResource findByG_A(long groupId, String articleId)
1360                    throws NoSuchArticleResourceException, SystemException {
1361                    JournalArticleResource journalArticleResource = fetchByG_A(groupId,
1362                                    articleId);
1363    
1364                    if (journalArticleResource == null) {
1365                            StringBundler msg = new StringBundler(6);
1366    
1367                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1368    
1369                            msg.append("groupId=");
1370                            msg.append(groupId);
1371    
1372                            msg.append(", articleId=");
1373                            msg.append(articleId);
1374    
1375                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1376    
1377                            if (_log.isWarnEnabled()) {
1378                                    _log.warn(msg.toString());
1379                            }
1380    
1381                            throw new NoSuchArticleResourceException(msg.toString());
1382                    }
1383    
1384                    return journalArticleResource;
1385            }
1386    
1387            /**
1388             * Returns the journal article resource where groupId = &#63; and articleId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1389             *
1390             * @param groupId the group ID
1391             * @param articleId the article ID
1392             * @return the matching journal article resource, or <code>null</code> if a matching journal article resource could not be found
1393             * @throws SystemException if a system exception occurred
1394             */
1395            public JournalArticleResource fetchByG_A(long groupId, String articleId)
1396                    throws SystemException {
1397                    return fetchByG_A(groupId, articleId, true);
1398            }
1399    
1400            /**
1401             * Returns the journal article resource where groupId = &#63; and articleId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1402             *
1403             * @param groupId the group ID
1404             * @param articleId the article ID
1405             * @param retrieveFromCache whether to use the finder cache
1406             * @return the matching journal article resource, or <code>null</code> if a matching journal article resource could not be found
1407             * @throws SystemException if a system exception occurred
1408             */
1409            public JournalArticleResource fetchByG_A(long groupId, String articleId,
1410                    boolean retrieveFromCache) throws SystemException {
1411                    Object[] finderArgs = new Object[] { groupId, articleId };
1412    
1413                    Object result = null;
1414    
1415                    if (retrieveFromCache) {
1416                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_A,
1417                                            finderArgs, this);
1418                    }
1419    
1420                    if (result instanceof JournalArticleResource) {
1421                            JournalArticleResource journalArticleResource = (JournalArticleResource)result;
1422    
1423                            if ((groupId != journalArticleResource.getGroupId()) ||
1424                                            !Validator.equals(articleId,
1425                                                    journalArticleResource.getArticleId())) {
1426                                    result = null;
1427                            }
1428                    }
1429    
1430                    if (result == null) {
1431                            StringBundler query = new StringBundler(4);
1432    
1433                            query.append(_SQL_SELECT_JOURNALARTICLERESOURCE_WHERE);
1434    
1435                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
1436    
1437                            if (articleId == null) {
1438                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
1439                            }
1440                            else {
1441                                    if (articleId.equals(StringPool.BLANK)) {
1442                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
1443                                    }
1444                                    else {
1445                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
1446                                    }
1447                            }
1448    
1449                            String sql = query.toString();
1450    
1451                            Session session = null;
1452    
1453                            try {
1454                                    session = openSession();
1455    
1456                                    Query q = session.createQuery(sql);
1457    
1458                                    QueryPos qPos = QueryPos.getInstance(q);
1459    
1460                                    qPos.add(groupId);
1461    
1462                                    if (articleId != null) {
1463                                            qPos.add(articleId);
1464                                    }
1465    
1466                                    List<JournalArticleResource> list = q.list();
1467    
1468                                    if (list.isEmpty()) {
1469                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A,
1470                                                    finderArgs, list);
1471                                    }
1472                                    else {
1473                                            JournalArticleResource journalArticleResource = list.get(0);
1474    
1475                                            result = journalArticleResource;
1476    
1477                                            cacheResult(journalArticleResource);
1478    
1479                                            if ((journalArticleResource.getGroupId() != groupId) ||
1480                                                            (journalArticleResource.getArticleId() == null) ||
1481                                                            !journalArticleResource.getArticleId()
1482                                                                                                               .equals(articleId)) {
1483                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A,
1484                                                            finderArgs, journalArticleResource);
1485                                            }
1486                                    }
1487                            }
1488                            catch (Exception e) {
1489                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A,
1490                                            finderArgs);
1491    
1492                                    throw processException(e);
1493                            }
1494                            finally {
1495                                    closeSession(session);
1496                            }
1497                    }
1498    
1499                    if (result instanceof List<?>) {
1500                            return null;
1501                    }
1502                    else {
1503                            return (JournalArticleResource)result;
1504                    }
1505            }
1506    
1507            /**
1508             * Removes the journal article resource where groupId = &#63; and articleId = &#63; from the database.
1509             *
1510             * @param groupId the group ID
1511             * @param articleId the article ID
1512             * @return the journal article resource that was removed
1513             * @throws SystemException if a system exception occurred
1514             */
1515            public JournalArticleResource removeByG_A(long groupId, String articleId)
1516                    throws NoSuchArticleResourceException, SystemException {
1517                    JournalArticleResource journalArticleResource = findByG_A(groupId,
1518                                    articleId);
1519    
1520                    return remove(journalArticleResource);
1521            }
1522    
1523            /**
1524             * Returns the number of journal article resources where groupId = &#63; and articleId = &#63;.
1525             *
1526             * @param groupId the group ID
1527             * @param articleId the article ID
1528             * @return the number of matching journal article resources
1529             * @throws SystemException if a system exception occurred
1530             */
1531            public int countByG_A(long groupId, String articleId)
1532                    throws SystemException {
1533                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A;
1534    
1535                    Object[] finderArgs = new Object[] { groupId, articleId };
1536    
1537                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1538                                    this);
1539    
1540                    if (count == null) {
1541                            StringBundler query = new StringBundler(3);
1542    
1543                            query.append(_SQL_COUNT_JOURNALARTICLERESOURCE_WHERE);
1544    
1545                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
1546    
1547                            if (articleId == null) {
1548                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
1549                            }
1550                            else {
1551                                    if (articleId.equals(StringPool.BLANK)) {
1552                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
1553                                    }
1554                                    else {
1555                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
1556                                    }
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 (articleId != null) {
1573                                            qPos.add(articleId);
1574                                    }
1575    
1576                                    count = (Long)q.uniqueResult();
1577    
1578                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1579                            }
1580                            catch (Exception e) {
1581                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1582    
1583                                    throw processException(e);
1584                            }
1585                            finally {
1586                                    closeSession(session);
1587                            }
1588                    }
1589    
1590                    return count.intValue();
1591            }
1592    
1593            private static final String _FINDER_COLUMN_G_A_GROUPID_2 = "journalArticleResource.groupId = ? AND ";
1594            private static final String _FINDER_COLUMN_G_A_ARTICLEID_1 = "journalArticleResource.articleId IS NULL";
1595            private static final String _FINDER_COLUMN_G_A_ARTICLEID_2 = "journalArticleResource.articleId = ?";
1596            private static final String _FINDER_COLUMN_G_A_ARTICLEID_3 = "(journalArticleResource.articleId IS NULL OR journalArticleResource.articleId = ?)";
1597    
1598            /**
1599             * Caches the journal article resource in the entity cache if it is enabled.
1600             *
1601             * @param journalArticleResource the journal article resource
1602             */
1603            public void cacheResult(JournalArticleResource journalArticleResource) {
1604                    EntityCacheUtil.putResult(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
1605                            JournalArticleResourceImpl.class,
1606                            journalArticleResource.getPrimaryKey(), journalArticleResource);
1607    
1608                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1609                            new Object[] {
1610                                    journalArticleResource.getUuid(),
1611                                    Long.valueOf(journalArticleResource.getGroupId())
1612                            }, journalArticleResource);
1613    
1614                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A,
1615                            new Object[] {
1616                                    Long.valueOf(journalArticleResource.getGroupId()),
1617                                    
1618                            journalArticleResource.getArticleId()
1619                            }, journalArticleResource);
1620    
1621                    journalArticleResource.resetOriginalValues();
1622            }
1623    
1624            /**
1625             * Caches the journal article resources in the entity cache if it is enabled.
1626             *
1627             * @param journalArticleResources the journal article resources
1628             */
1629            public void cacheResult(
1630                    List<JournalArticleResource> journalArticleResources) {
1631                    for (JournalArticleResource journalArticleResource : journalArticleResources) {
1632                            if (EntityCacheUtil.getResult(
1633                                                    JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
1634                                                    JournalArticleResourceImpl.class,
1635                                                    journalArticleResource.getPrimaryKey()) == null) {
1636                                    cacheResult(journalArticleResource);
1637                            }
1638                            else {
1639                                    journalArticleResource.resetOriginalValues();
1640                            }
1641                    }
1642            }
1643    
1644            /**
1645             * Clears the cache for all journal article resources.
1646             *
1647             * <p>
1648             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
1649             * </p>
1650             */
1651            @Override
1652            public void clearCache() {
1653                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
1654                            CacheRegistryUtil.clear(JournalArticleResourceImpl.class.getName());
1655                    }
1656    
1657                    EntityCacheUtil.clearCache(JournalArticleResourceImpl.class.getName());
1658    
1659                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
1660                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1661                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1662            }
1663    
1664            /**
1665             * Clears the cache for the journal article resource.
1666             *
1667             * <p>
1668             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
1669             * </p>
1670             */
1671            @Override
1672            public void clearCache(JournalArticleResource journalArticleResource) {
1673                    EntityCacheUtil.removeResult(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
1674                            JournalArticleResourceImpl.class,
1675                            journalArticleResource.getPrimaryKey());
1676    
1677                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1678                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1679    
1680                    clearUniqueFindersCache(journalArticleResource);
1681            }
1682    
1683            @Override
1684            public void clearCache(List<JournalArticleResource> journalArticleResources) {
1685                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1686                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1687    
1688                    for (JournalArticleResource journalArticleResource : journalArticleResources) {
1689                            EntityCacheUtil.removeResult(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
1690                                    JournalArticleResourceImpl.class,
1691                                    journalArticleResource.getPrimaryKey());
1692    
1693                            clearUniqueFindersCache(journalArticleResource);
1694                    }
1695            }
1696    
1697            protected void cacheUniqueFindersCache(
1698                    JournalArticleResource journalArticleResource) {
1699                    if (journalArticleResource.isNew()) {
1700                            Object[] args = new Object[] {
1701                                            journalArticleResource.getUuid(),
1702                                            Long.valueOf(journalArticleResource.getGroupId())
1703                                    };
1704    
1705                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
1706                                    Long.valueOf(1));
1707                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
1708                                    journalArticleResource);
1709    
1710                            args = new Object[] {
1711                                            Long.valueOf(journalArticleResource.getGroupId()),
1712                                            
1713                                            journalArticleResource.getArticleId()
1714                                    };
1715    
1716                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A, args,
1717                                    Long.valueOf(1));
1718                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A, args,
1719                                    journalArticleResource);
1720                    }
1721                    else {
1722                            JournalArticleResourceModelImpl journalArticleResourceModelImpl = (JournalArticleResourceModelImpl)journalArticleResource;
1723    
1724                            if ((journalArticleResourceModelImpl.getColumnBitmask() &
1725                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
1726                                    Object[] args = new Object[] {
1727                                                    journalArticleResource.getUuid(),
1728                                                    Long.valueOf(journalArticleResource.getGroupId())
1729                                            };
1730    
1731                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
1732                                            Long.valueOf(1));
1733                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
1734                                            journalArticleResource);
1735                            }
1736    
1737                            if ((journalArticleResourceModelImpl.getColumnBitmask() &
1738                                            FINDER_PATH_FETCH_BY_G_A.getColumnBitmask()) != 0) {
1739                                    Object[] args = new Object[] {
1740                                                    Long.valueOf(journalArticleResource.getGroupId()),
1741                                                    
1742                                                    journalArticleResource.getArticleId()
1743                                            };
1744    
1745                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A, args,
1746                                            Long.valueOf(1));
1747                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A, args,
1748                                            journalArticleResource);
1749                            }
1750                    }
1751            }
1752    
1753            protected void clearUniqueFindersCache(
1754                    JournalArticleResource journalArticleResource) {
1755                    JournalArticleResourceModelImpl journalArticleResourceModelImpl = (JournalArticleResourceModelImpl)journalArticleResource;
1756    
1757                    Object[] args = new Object[] {
1758                                    journalArticleResource.getUuid(),
1759                                    Long.valueOf(journalArticleResource.getGroupId())
1760                            };
1761    
1762                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
1763                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
1764    
1765                    if ((journalArticleResourceModelImpl.getColumnBitmask() &
1766                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
1767                            args = new Object[] {
1768                                            journalArticleResourceModelImpl.getOriginalUuid(),
1769                                            Long.valueOf(journalArticleResourceModelImpl.getOriginalGroupId())
1770                                    };
1771    
1772                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
1773                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
1774                    }
1775    
1776                    args = new Object[] {
1777                                    Long.valueOf(journalArticleResource.getGroupId()),
1778                                    
1779                                    journalArticleResource.getArticleId()
1780                            };
1781    
1782                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
1783                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A, args);
1784    
1785                    if ((journalArticleResourceModelImpl.getColumnBitmask() &
1786                                    FINDER_PATH_FETCH_BY_G_A.getColumnBitmask()) != 0) {
1787                            args = new Object[] {
1788                                            Long.valueOf(journalArticleResourceModelImpl.getOriginalGroupId()),
1789                                            
1790                                            journalArticleResourceModelImpl.getOriginalArticleId()
1791                                    };
1792    
1793                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
1794                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A, args);
1795                    }
1796            }
1797    
1798            /**
1799             * Creates a new journal article resource with the primary key. Does not add the journal article resource to the database.
1800             *
1801             * @param resourcePrimKey the primary key for the new journal article resource
1802             * @return the new journal article resource
1803             */
1804            public JournalArticleResource create(long resourcePrimKey) {
1805                    JournalArticleResource journalArticleResource = new JournalArticleResourceImpl();
1806    
1807                    journalArticleResource.setNew(true);
1808                    journalArticleResource.setPrimaryKey(resourcePrimKey);
1809    
1810                    String uuid = PortalUUIDUtil.generate();
1811    
1812                    journalArticleResource.setUuid(uuid);
1813    
1814                    return journalArticleResource;
1815            }
1816    
1817            /**
1818             * Removes the journal article resource with the primary key from the database. Also notifies the appropriate model listeners.
1819             *
1820             * @param resourcePrimKey the primary key of the journal article resource
1821             * @return the journal article resource that was removed
1822             * @throws com.liferay.portlet.journal.NoSuchArticleResourceException if a journal article resource with the primary key could not be found
1823             * @throws SystemException if a system exception occurred
1824             */
1825            public JournalArticleResource remove(long resourcePrimKey)
1826                    throws NoSuchArticleResourceException, SystemException {
1827                    return remove(Long.valueOf(resourcePrimKey));
1828            }
1829    
1830            /**
1831             * Removes the journal article resource with the primary key from the database. Also notifies the appropriate model listeners.
1832             *
1833             * @param primaryKey the primary key of the journal article resource
1834             * @return the journal article resource that was removed
1835             * @throws com.liferay.portlet.journal.NoSuchArticleResourceException if a journal article resource with the primary key could not be found
1836             * @throws SystemException if a system exception occurred
1837             */
1838            @Override
1839            public JournalArticleResource remove(Serializable primaryKey)
1840                    throws NoSuchArticleResourceException, SystemException {
1841                    Session session = null;
1842    
1843                    try {
1844                            session = openSession();
1845    
1846                            JournalArticleResource journalArticleResource = (JournalArticleResource)session.get(JournalArticleResourceImpl.class,
1847                                            primaryKey);
1848    
1849                            if (journalArticleResource == null) {
1850                                    if (_log.isWarnEnabled()) {
1851                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
1852                                    }
1853    
1854                                    throw new NoSuchArticleResourceException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1855                                            primaryKey);
1856                            }
1857    
1858                            return remove(journalArticleResource);
1859                    }
1860                    catch (NoSuchArticleResourceException nsee) {
1861                            throw nsee;
1862                    }
1863                    catch (Exception e) {
1864                            throw processException(e);
1865                    }
1866                    finally {
1867                            closeSession(session);
1868                    }
1869            }
1870    
1871            @Override
1872            protected JournalArticleResource removeImpl(
1873                    JournalArticleResource journalArticleResource)
1874                    throws SystemException {
1875                    journalArticleResource = toUnwrappedModel(journalArticleResource);
1876    
1877                    Session session = null;
1878    
1879                    try {
1880                            session = openSession();
1881    
1882                            if (!session.contains(journalArticleResource)) {
1883                                    journalArticleResource = (JournalArticleResource)session.get(JournalArticleResourceImpl.class,
1884                                                    journalArticleResource.getPrimaryKeyObj());
1885                            }
1886    
1887                            if (journalArticleResource != null) {
1888                                    session.delete(journalArticleResource);
1889                            }
1890                    }
1891                    catch (Exception e) {
1892                            throw processException(e);
1893                    }
1894                    finally {
1895                            closeSession(session);
1896                    }
1897    
1898                    if (journalArticleResource != null) {
1899                            clearCache(journalArticleResource);
1900                    }
1901    
1902                    return journalArticleResource;
1903            }
1904    
1905            @Override
1906            public JournalArticleResource updateImpl(
1907                    com.liferay.portlet.journal.model.JournalArticleResource journalArticleResource)
1908                    throws SystemException {
1909                    journalArticleResource = toUnwrappedModel(journalArticleResource);
1910    
1911                    boolean isNew = journalArticleResource.isNew();
1912    
1913                    JournalArticleResourceModelImpl journalArticleResourceModelImpl = (JournalArticleResourceModelImpl)journalArticleResource;
1914    
1915                    if (Validator.isNull(journalArticleResource.getUuid())) {
1916                            String uuid = PortalUUIDUtil.generate();
1917    
1918                            journalArticleResource.setUuid(uuid);
1919                    }
1920    
1921                    Session session = null;
1922    
1923                    try {
1924                            session = openSession();
1925    
1926                            if (journalArticleResource.isNew()) {
1927                                    session.save(journalArticleResource);
1928    
1929                                    journalArticleResource.setNew(false);
1930                            }
1931                            else {
1932                                    session.merge(journalArticleResource);
1933                            }
1934                    }
1935                    catch (Exception e) {
1936                            throw processException(e);
1937                    }
1938                    finally {
1939                            closeSession(session);
1940                    }
1941    
1942                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1943    
1944                    if (isNew || !JournalArticleResourceModelImpl.COLUMN_BITMASK_ENABLED) {
1945                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1946                    }
1947    
1948                    else {
1949                            if ((journalArticleResourceModelImpl.getColumnBitmask() &
1950                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
1951                                    Object[] args = new Object[] {
1952                                                    journalArticleResourceModelImpl.getOriginalUuid()
1953                                            };
1954    
1955                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
1956                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
1957                                            args);
1958    
1959                                    args = new Object[] { journalArticleResourceModelImpl.getUuid() };
1960    
1961                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
1962                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
1963                                            args);
1964                            }
1965    
1966                            if ((journalArticleResourceModelImpl.getColumnBitmask() &
1967                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
1968                                    Object[] args = new Object[] {
1969                                                    Long.valueOf(journalArticleResourceModelImpl.getOriginalGroupId())
1970                                            };
1971    
1972                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
1973                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
1974                                            args);
1975    
1976                                    args = new Object[] {
1977                                                    Long.valueOf(journalArticleResourceModelImpl.getGroupId())
1978                                            };
1979    
1980                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
1981                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
1982                                            args);
1983                            }
1984                    }
1985    
1986                    EntityCacheUtil.putResult(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
1987                            JournalArticleResourceImpl.class,
1988                            journalArticleResource.getPrimaryKey(), journalArticleResource);
1989    
1990                    clearUniqueFindersCache(journalArticleResource);
1991                    cacheUniqueFindersCache(journalArticleResource);
1992    
1993                    return journalArticleResource;
1994            }
1995    
1996            protected JournalArticleResource toUnwrappedModel(
1997                    JournalArticleResource journalArticleResource) {
1998                    if (journalArticleResource instanceof JournalArticleResourceImpl) {
1999                            return journalArticleResource;
2000                    }
2001    
2002                    JournalArticleResourceImpl journalArticleResourceImpl = new JournalArticleResourceImpl();
2003    
2004                    journalArticleResourceImpl.setNew(journalArticleResource.isNew());
2005                    journalArticleResourceImpl.setPrimaryKey(journalArticleResource.getPrimaryKey());
2006    
2007                    journalArticleResourceImpl.setUuid(journalArticleResource.getUuid());
2008                    journalArticleResourceImpl.setResourcePrimKey(journalArticleResource.getResourcePrimKey());
2009                    journalArticleResourceImpl.setGroupId(journalArticleResource.getGroupId());
2010                    journalArticleResourceImpl.setArticleId(journalArticleResource.getArticleId());
2011    
2012                    return journalArticleResourceImpl;
2013            }
2014    
2015            /**
2016             * Returns the journal article resource with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
2017             *
2018             * @param primaryKey the primary key of the journal article resource
2019             * @return the journal article resource
2020             * @throws com.liferay.portal.NoSuchModelException if a journal article resource with the primary key could not be found
2021             * @throws SystemException if a system exception occurred
2022             */
2023            @Override
2024            public JournalArticleResource findByPrimaryKey(Serializable primaryKey)
2025                    throws NoSuchModelException, SystemException {
2026                    return findByPrimaryKey(((Long)primaryKey).longValue());
2027            }
2028    
2029            /**
2030             * Returns the journal article resource with the primary key or throws a {@link com.liferay.portlet.journal.NoSuchArticleResourceException} if it could not be found.
2031             *
2032             * @param resourcePrimKey the primary key of the journal article resource
2033             * @return the journal article resource
2034             * @throws com.liferay.portlet.journal.NoSuchArticleResourceException if a journal article resource with the primary key could not be found
2035             * @throws SystemException if a system exception occurred
2036             */
2037            public JournalArticleResource findByPrimaryKey(long resourcePrimKey)
2038                    throws NoSuchArticleResourceException, SystemException {
2039                    JournalArticleResource journalArticleResource = fetchByPrimaryKey(resourcePrimKey);
2040    
2041                    if (journalArticleResource == null) {
2042                            if (_log.isWarnEnabled()) {
2043                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + resourcePrimKey);
2044                            }
2045    
2046                            throw new NoSuchArticleResourceException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2047                                    resourcePrimKey);
2048                    }
2049    
2050                    return journalArticleResource;
2051            }
2052    
2053            /**
2054             * Returns the journal article resource with the primary key or returns <code>null</code> if it could not be found.
2055             *
2056             * @param primaryKey the primary key of the journal article resource
2057             * @return the journal article resource, or <code>null</code> if a journal article resource with the primary key could not be found
2058             * @throws SystemException if a system exception occurred
2059             */
2060            @Override
2061            public JournalArticleResource fetchByPrimaryKey(Serializable primaryKey)
2062                    throws SystemException {
2063                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
2064            }
2065    
2066            /**
2067             * Returns the journal article resource with the primary key or returns <code>null</code> if it could not be found.
2068             *
2069             * @param resourcePrimKey the primary key of the journal article resource
2070             * @return the journal article resource, or <code>null</code> if a journal article resource with the primary key could not be found
2071             * @throws SystemException if a system exception occurred
2072             */
2073            public JournalArticleResource fetchByPrimaryKey(long resourcePrimKey)
2074                    throws SystemException {
2075                    JournalArticleResource journalArticleResource = (JournalArticleResource)EntityCacheUtil.getResult(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
2076                                    JournalArticleResourceImpl.class, resourcePrimKey);
2077    
2078                    if (journalArticleResource == _nullJournalArticleResource) {
2079                            return null;
2080                    }
2081    
2082                    if (journalArticleResource == null) {
2083                            Session session = null;
2084    
2085                            try {
2086                                    session = openSession();
2087    
2088                                    journalArticleResource = (JournalArticleResource)session.get(JournalArticleResourceImpl.class,
2089                                                    Long.valueOf(resourcePrimKey));
2090    
2091                                    if (journalArticleResource != null) {
2092                                            cacheResult(journalArticleResource);
2093                                    }
2094                                    else {
2095                                            EntityCacheUtil.putResult(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
2096                                                    JournalArticleResourceImpl.class, resourcePrimKey,
2097                                                    _nullJournalArticleResource);
2098                                    }
2099                            }
2100                            catch (Exception e) {
2101                                    EntityCacheUtil.removeResult(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
2102                                            JournalArticleResourceImpl.class, resourcePrimKey);
2103    
2104                                    throw processException(e);
2105                            }
2106                            finally {
2107                                    closeSession(session);
2108                            }
2109                    }
2110    
2111                    return journalArticleResource;
2112            }
2113    
2114            /**
2115             * Returns all the journal article resources.
2116             *
2117             * @return the journal article resources
2118             * @throws SystemException if a system exception occurred
2119             */
2120            public List<JournalArticleResource> findAll() throws SystemException {
2121                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2122            }
2123    
2124            /**
2125             * Returns a range of all the journal article resources.
2126             *
2127             * <p>
2128             * 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.JournalArticleResourceModelImpl}. 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.
2129             * </p>
2130             *
2131             * @param start the lower bound of the range of journal article resources
2132             * @param end the upper bound of the range of journal article resources (not inclusive)
2133             * @return the range of journal article resources
2134             * @throws SystemException if a system exception occurred
2135             */
2136            public List<JournalArticleResource> findAll(int start, int end)
2137                    throws SystemException {
2138                    return findAll(start, end, null);
2139            }
2140    
2141            /**
2142             * Returns an ordered range of all the journal article resources.
2143             *
2144             * <p>
2145             * 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.JournalArticleResourceModelImpl}. 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.
2146             * </p>
2147             *
2148             * @param start the lower bound of the range of journal article resources
2149             * @param end the upper bound of the range of journal article resources (not inclusive)
2150             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2151             * @return the ordered range of journal article resources
2152             * @throws SystemException if a system exception occurred
2153             */
2154            public List<JournalArticleResource> findAll(int start, int end,
2155                    OrderByComparator orderByComparator) throws SystemException {
2156                    boolean pagination = true;
2157                    FinderPath finderPath = null;
2158                    Object[] finderArgs = null;
2159    
2160                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2161                                    (orderByComparator == null)) {
2162                            pagination = false;
2163                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2164                            finderArgs = FINDER_ARGS_EMPTY;
2165                    }
2166                    else {
2167                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2168                            finderArgs = new Object[] { start, end, orderByComparator };
2169                    }
2170    
2171                    List<JournalArticleResource> list = (List<JournalArticleResource>)FinderCacheUtil.getResult(finderPath,
2172                                    finderArgs, this);
2173    
2174                    if (list == null) {
2175                            StringBundler query = null;
2176                            String sql = null;
2177    
2178                            if (orderByComparator != null) {
2179                                    query = new StringBundler(2 +
2180                                                    (orderByComparator.getOrderByFields().length * 3));
2181    
2182                                    query.append(_SQL_SELECT_JOURNALARTICLERESOURCE);
2183    
2184                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2185                                            orderByComparator);
2186    
2187                                    sql = query.toString();
2188                            }
2189                            else {
2190                                    sql = _SQL_SELECT_JOURNALARTICLERESOURCE;
2191    
2192                                    if (pagination) {
2193                                            sql = sql.concat(JournalArticleResourceModelImpl.ORDER_BY_JPQL);
2194                                    }
2195                            }
2196    
2197                            Session session = null;
2198    
2199                            try {
2200                                    session = openSession();
2201    
2202                                    Query q = session.createQuery(sql);
2203    
2204                                    if (!pagination) {
2205                                            list = (List<JournalArticleResource>)QueryUtil.list(q,
2206                                                            getDialect(), start, end, false);
2207    
2208                                            Collections.sort(list);
2209    
2210                                            list = new UnmodifiableList<JournalArticleResource>(list);
2211                                    }
2212                                    else {
2213                                            list = (List<JournalArticleResource>)QueryUtil.list(q,
2214                                                            getDialect(), start, end);
2215                                    }
2216    
2217                                    cacheResult(list);
2218    
2219                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2220                            }
2221                            catch (Exception e) {
2222                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2223    
2224                                    throw processException(e);
2225                            }
2226                            finally {
2227                                    closeSession(session);
2228                            }
2229                    }
2230    
2231                    return list;
2232            }
2233    
2234            /**
2235             * Removes all the journal article resources from the database.
2236             *
2237             * @throws SystemException if a system exception occurred
2238             */
2239            public void removeAll() throws SystemException {
2240                    for (JournalArticleResource journalArticleResource : findAll()) {
2241                            remove(journalArticleResource);
2242                    }
2243            }
2244    
2245            /**
2246             * Returns the number of journal article resources.
2247             *
2248             * @return the number of journal article resources
2249             * @throws SystemException if a system exception occurred
2250             */
2251            public int countAll() throws SystemException {
2252                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2253                                    FINDER_ARGS_EMPTY, this);
2254    
2255                    if (count == null) {
2256                            Session session = null;
2257    
2258                            try {
2259                                    session = openSession();
2260    
2261                                    Query q = session.createQuery(_SQL_COUNT_JOURNALARTICLERESOURCE);
2262    
2263                                    count = (Long)q.uniqueResult();
2264    
2265                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2266                                            FINDER_ARGS_EMPTY, count);
2267                            }
2268                            catch (Exception e) {
2269                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
2270                                            FINDER_ARGS_EMPTY);
2271    
2272                                    throw processException(e);
2273                            }
2274                            finally {
2275                                    closeSession(session);
2276                            }
2277                    }
2278    
2279                    return count.intValue();
2280            }
2281    
2282            /**
2283             * Initializes the journal article resource persistence.
2284             */
2285            public void afterPropertiesSet() {
2286                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2287                                            com.liferay.portal.util.PropsUtil.get(
2288                                                    "value.object.listener.com.liferay.portlet.journal.model.JournalArticleResource")));
2289    
2290                    if (listenerClassNames.length > 0) {
2291                            try {
2292                                    List<ModelListener<JournalArticleResource>> listenersList = new ArrayList<ModelListener<JournalArticleResource>>();
2293    
2294                                    for (String listenerClassName : listenerClassNames) {
2295                                            listenersList.add((ModelListener<JournalArticleResource>)InstanceFactory.newInstance(
2296                                                            listenerClassName));
2297                                    }
2298    
2299                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2300                            }
2301                            catch (Exception e) {
2302                                    _log.error(e);
2303                            }
2304                    }
2305            }
2306    
2307            public void destroy() {
2308                    EntityCacheUtil.removeCache(JournalArticleResourceImpl.class.getName());
2309                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2310                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2311                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2312            }
2313    
2314            private static final String _SQL_SELECT_JOURNALARTICLERESOURCE = "SELECT journalArticleResource FROM JournalArticleResource journalArticleResource";
2315            private static final String _SQL_SELECT_JOURNALARTICLERESOURCE_WHERE = "SELECT journalArticleResource FROM JournalArticleResource journalArticleResource WHERE ";
2316            private static final String _SQL_COUNT_JOURNALARTICLERESOURCE = "SELECT COUNT(journalArticleResource) FROM JournalArticleResource journalArticleResource";
2317            private static final String _SQL_COUNT_JOURNALARTICLERESOURCE_WHERE = "SELECT COUNT(journalArticleResource) FROM JournalArticleResource journalArticleResource WHERE ";
2318            private static final String _ORDER_BY_ENTITY_ALIAS = "journalArticleResource.";
2319            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalArticleResource exists with the primary key ";
2320            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalArticleResource exists with the key {";
2321            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2322            private static Log _log = LogFactoryUtil.getLog(JournalArticleResourcePersistenceImpl.class);
2323            private static JournalArticleResource _nullJournalArticleResource = new JournalArticleResourceImpl() {
2324                            @Override
2325                            public Object clone() {
2326                                    return this;
2327                            }
2328    
2329                            @Override
2330                            public CacheModel<JournalArticleResource> toCacheModel() {
2331                                    return _nullJournalArticleResourceCacheModel;
2332                            }
2333                    };
2334    
2335            private static CacheModel<JournalArticleResource> _nullJournalArticleResourceCacheModel =
2336                    new CacheModel<JournalArticleResource>() {
2337                            public JournalArticleResource toEntityModel() {
2338                                    return _nullJournalArticleResource;
2339                            }
2340                    };
2341    }