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