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