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