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