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