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