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