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