001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.softwarecatalog.service.persistence.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
020    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderPath;
022    import com.liferay.portal.kernel.dao.orm.Query;
023    import com.liferay.portal.kernel.dao.orm.QueryPos;
024    import com.liferay.portal.kernel.dao.orm.QueryUtil;
025    import com.liferay.portal.kernel.dao.orm.Session;
026    import com.liferay.portal.kernel.log.Log;
027    import com.liferay.portal.kernel.log.LogFactoryUtil;
028    import com.liferay.portal.kernel.util.OrderByComparator;
029    import com.liferay.portal.kernel.util.StringBundler;
030    import com.liferay.portal.kernel.util.StringPool;
031    import com.liferay.portal.kernel.util.StringUtil;
032    import com.liferay.portal.model.CacheModel;
033    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
034    
035    import com.liferay.portlet.softwarecatalog.NoSuchProductScreenshotException;
036    import com.liferay.portlet.softwarecatalog.model.SCProductScreenshot;
037    import com.liferay.portlet.softwarecatalog.model.impl.SCProductScreenshotImpl;
038    import com.liferay.portlet.softwarecatalog.model.impl.SCProductScreenshotModelImpl;
039    import com.liferay.portlet.softwarecatalog.service.persistence.SCProductScreenshotPersistence;
040    
041    import java.io.Serializable;
042    
043    import java.util.Collections;
044    import java.util.HashMap;
045    import java.util.HashSet;
046    import java.util.Iterator;
047    import java.util.List;
048    import java.util.Map;
049    import java.util.Set;
050    
051    /**
052     * The persistence implementation for the s c product screenshot service.
053     *
054     * <p>
055     * Caching information and settings can be found in <code>portal.properties</code>
056     * </p>
057     *
058     * @author Brian Wing Shun Chan
059     * @see SCProductScreenshotPersistence
060     * @see com.liferay.portlet.softwarecatalog.service.persistence.SCProductScreenshotUtil
061     * @generated
062     */
063    @ProviderType
064    public class SCProductScreenshotPersistenceImpl extends BasePersistenceImpl<SCProductScreenshot>
065            implements SCProductScreenshotPersistence {
066            /*
067             * NOTE FOR DEVELOPERS:
068             *
069             * Never modify or reference this class directly. Always use {@link SCProductScreenshotUtil} to access the s c product screenshot persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
070             */
071            public static final String FINDER_CLASS_NAME_ENTITY = SCProductScreenshotImpl.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(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
077                            SCProductScreenshotModelImpl.FINDER_CACHE_ENABLED,
078                            SCProductScreenshotImpl.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(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
081                            SCProductScreenshotModelImpl.FINDER_CACHE_ENABLED,
082                            SCProductScreenshotImpl.class,
083                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
084            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
085                            SCProductScreenshotModelImpl.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_PRODUCTENTRYID =
088                    new FinderPath(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
089                            SCProductScreenshotModelImpl.FINDER_CACHE_ENABLED,
090                            SCProductScreenshotImpl.class,
091                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByProductEntryId",
092                            new String[] {
093                                    Long.class.getName(),
094                                    
095                            Integer.class.getName(), Integer.class.getName(),
096                                    OrderByComparator.class.getName()
097                            });
098            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PRODUCTENTRYID =
099                    new FinderPath(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
100                            SCProductScreenshotModelImpl.FINDER_CACHE_ENABLED,
101                            SCProductScreenshotImpl.class,
102                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByProductEntryId",
103                            new String[] { Long.class.getName() },
104                            SCProductScreenshotModelImpl.PRODUCTENTRYID_COLUMN_BITMASK |
105                            SCProductScreenshotModelImpl.PRIORITY_COLUMN_BITMASK);
106            public static final FinderPath FINDER_PATH_COUNT_BY_PRODUCTENTRYID = new FinderPath(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
107                            SCProductScreenshotModelImpl.FINDER_CACHE_ENABLED, Long.class,
108                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByProductEntryId",
109                            new String[] { Long.class.getName() });
110    
111            /**
112             * Returns all the s c product screenshots where productEntryId = &#63;.
113             *
114             * @param productEntryId the product entry ID
115             * @return the matching s c product screenshots
116             */
117            @Override
118            public List<SCProductScreenshot> findByProductEntryId(long productEntryId) {
119                    return findByProductEntryId(productEntryId, QueryUtil.ALL_POS,
120                            QueryUtil.ALL_POS, null);
121            }
122    
123            /**
124             * Returns a range of all the s c product screenshots where productEntryId = &#63;.
125             *
126             * <p>
127             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SCProductScreenshotModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
128             * </p>
129             *
130             * @param productEntryId the product entry ID
131             * @param start the lower bound of the range of s c product screenshots
132             * @param end the upper bound of the range of s c product screenshots (not inclusive)
133             * @return the range of matching s c product screenshots
134             */
135            @Override
136            public List<SCProductScreenshot> findByProductEntryId(long productEntryId,
137                    int start, int end) {
138                    return findByProductEntryId(productEntryId, start, end, null);
139            }
140    
141            /**
142             * Returns an ordered range of all the s c product screenshots where productEntryId = &#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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SCProductScreenshotModelImpl}. 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 productEntryId the product entry ID
149             * @param start the lower bound of the range of s c product screenshots
150             * @param end the upper bound of the range of s c product screenshots (not inclusive)
151             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
152             * @return the ordered range of matching s c product screenshots
153             */
154            @Override
155            public List<SCProductScreenshot> findByProductEntryId(long productEntryId,
156                    int start, int end,
157                    OrderByComparator<SCProductScreenshot> orderByComparator) {
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_PRODUCTENTRYID;
166                            finderArgs = new Object[] { productEntryId };
167                    }
168                    else {
169                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PRODUCTENTRYID;
170                            finderArgs = new Object[] {
171                                            productEntryId,
172                                            
173                                            start, end, orderByComparator
174                                    };
175                    }
176    
177                    List<SCProductScreenshot> list = (List<SCProductScreenshot>)FinderCacheUtil.getResult(finderPath,
178                                    finderArgs, this);
179    
180                    if ((list != null) && !list.isEmpty()) {
181                            for (SCProductScreenshot scProductScreenshot : list) {
182                                    if ((productEntryId != scProductScreenshot.getProductEntryId())) {
183                                            list = null;
184    
185                                            break;
186                                    }
187                            }
188                    }
189    
190                    if (list == null) {
191                            StringBundler query = null;
192    
193                            if (orderByComparator != null) {
194                                    query = new StringBundler(3 +
195                                                    (orderByComparator.getOrderByFields().length * 3));
196                            }
197                            else {
198                                    query = new StringBundler(3);
199                            }
200    
201                            query.append(_SQL_SELECT_SCPRODUCTSCREENSHOT_WHERE);
202    
203                            query.append(_FINDER_COLUMN_PRODUCTENTRYID_PRODUCTENTRYID_2);
204    
205                            if (orderByComparator != null) {
206                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
207                                            orderByComparator);
208                            }
209                            else
210                             if (pagination) {
211                                    query.append(SCProductScreenshotModelImpl.ORDER_BY_JPQL);
212                            }
213    
214                            String sql = query.toString();
215    
216                            Session session = null;
217    
218                            try {
219                                    session = openSession();
220    
221                                    Query q = session.createQuery(sql);
222    
223                                    QueryPos qPos = QueryPos.getInstance(q);
224    
225                                    qPos.add(productEntryId);
226    
227                                    if (!pagination) {
228                                            list = (List<SCProductScreenshot>)QueryUtil.list(q,
229                                                            getDialect(), start, end, false);
230    
231                                            Collections.sort(list);
232    
233                                            list = Collections.unmodifiableList(list);
234                                    }
235                                    else {
236                                            list = (List<SCProductScreenshot>)QueryUtil.list(q,
237                                                            getDialect(), start, end);
238                                    }
239    
240                                    cacheResult(list);
241    
242                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
243                            }
244                            catch (Exception e) {
245                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
246    
247                                    throw processException(e);
248                            }
249                            finally {
250                                    closeSession(session);
251                            }
252                    }
253    
254                    return list;
255            }
256    
257            /**
258             * Returns the first s c product screenshot in the ordered set where productEntryId = &#63;.
259             *
260             * @param productEntryId the product entry ID
261             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
262             * @return the first matching s c product screenshot
263             * @throws NoSuchProductScreenshotException if a matching s c product screenshot could not be found
264             */
265            @Override
266            public SCProductScreenshot findByProductEntryId_First(long productEntryId,
267                    OrderByComparator<SCProductScreenshot> orderByComparator)
268                    throws NoSuchProductScreenshotException {
269                    SCProductScreenshot scProductScreenshot = fetchByProductEntryId_First(productEntryId,
270                                    orderByComparator);
271    
272                    if (scProductScreenshot != null) {
273                            return scProductScreenshot;
274                    }
275    
276                    StringBundler msg = new StringBundler(4);
277    
278                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
279    
280                    msg.append("productEntryId=");
281                    msg.append(productEntryId);
282    
283                    msg.append(StringPool.CLOSE_CURLY_BRACE);
284    
285                    throw new NoSuchProductScreenshotException(msg.toString());
286            }
287    
288            /**
289             * Returns the first s c product screenshot in the ordered set where productEntryId = &#63;.
290             *
291             * @param productEntryId the product entry ID
292             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
293             * @return the first matching s c product screenshot, or <code>null</code> if a matching s c product screenshot could not be found
294             */
295            @Override
296            public SCProductScreenshot fetchByProductEntryId_First(
297                    long productEntryId,
298                    OrderByComparator<SCProductScreenshot> orderByComparator) {
299                    List<SCProductScreenshot> list = findByProductEntryId(productEntryId,
300                                    0, 1, orderByComparator);
301    
302                    if (!list.isEmpty()) {
303                            return list.get(0);
304                    }
305    
306                    return null;
307            }
308    
309            /**
310             * Returns the last s c product screenshot in the ordered set where productEntryId = &#63;.
311             *
312             * @param productEntryId the product entry ID
313             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
314             * @return the last matching s c product screenshot
315             * @throws NoSuchProductScreenshotException if a matching s c product screenshot could not be found
316             */
317            @Override
318            public SCProductScreenshot findByProductEntryId_Last(long productEntryId,
319                    OrderByComparator<SCProductScreenshot> orderByComparator)
320                    throws NoSuchProductScreenshotException {
321                    SCProductScreenshot scProductScreenshot = fetchByProductEntryId_Last(productEntryId,
322                                    orderByComparator);
323    
324                    if (scProductScreenshot != null) {
325                            return scProductScreenshot;
326                    }
327    
328                    StringBundler msg = new StringBundler(4);
329    
330                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
331    
332                    msg.append("productEntryId=");
333                    msg.append(productEntryId);
334    
335                    msg.append(StringPool.CLOSE_CURLY_BRACE);
336    
337                    throw new NoSuchProductScreenshotException(msg.toString());
338            }
339    
340            /**
341             * Returns the last s c product screenshot in the ordered set where productEntryId = &#63;.
342             *
343             * @param productEntryId the product entry ID
344             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
345             * @return the last matching s c product screenshot, or <code>null</code> if a matching s c product screenshot could not be found
346             */
347            @Override
348            public SCProductScreenshot fetchByProductEntryId_Last(long productEntryId,
349                    OrderByComparator<SCProductScreenshot> orderByComparator) {
350                    int count = countByProductEntryId(productEntryId);
351    
352                    if (count == 0) {
353                            return null;
354                    }
355    
356                    List<SCProductScreenshot> list = findByProductEntryId(productEntryId,
357                                    count - 1, count, orderByComparator);
358    
359                    if (!list.isEmpty()) {
360                            return list.get(0);
361                    }
362    
363                    return null;
364            }
365    
366            /**
367             * Returns the s c product screenshots before and after the current s c product screenshot in the ordered set where productEntryId = &#63;.
368             *
369             * @param productScreenshotId the primary key of the current s c product screenshot
370             * @param productEntryId the product entry ID
371             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
372             * @return the previous, current, and next s c product screenshot
373             * @throws NoSuchProductScreenshotException if a s c product screenshot with the primary key could not be found
374             */
375            @Override
376            public SCProductScreenshot[] findByProductEntryId_PrevAndNext(
377                    long productScreenshotId, long productEntryId,
378                    OrderByComparator<SCProductScreenshot> orderByComparator)
379                    throws NoSuchProductScreenshotException {
380                    SCProductScreenshot scProductScreenshot = findByPrimaryKey(productScreenshotId);
381    
382                    Session session = null;
383    
384                    try {
385                            session = openSession();
386    
387                            SCProductScreenshot[] array = new SCProductScreenshotImpl[3];
388    
389                            array[0] = getByProductEntryId_PrevAndNext(session,
390                                            scProductScreenshot, productEntryId, orderByComparator, true);
391    
392                            array[1] = scProductScreenshot;
393    
394                            array[2] = getByProductEntryId_PrevAndNext(session,
395                                            scProductScreenshot, productEntryId, orderByComparator,
396                                            false);
397    
398                            return array;
399                    }
400                    catch (Exception e) {
401                            throw processException(e);
402                    }
403                    finally {
404                            closeSession(session);
405                    }
406            }
407    
408            protected SCProductScreenshot getByProductEntryId_PrevAndNext(
409                    Session session, SCProductScreenshot scProductScreenshot,
410                    long productEntryId,
411                    OrderByComparator<SCProductScreenshot> orderByComparator,
412                    boolean previous) {
413                    StringBundler query = null;
414    
415                    if (orderByComparator != null) {
416                            query = new StringBundler(6 +
417                                            (orderByComparator.getOrderByFields().length * 6));
418                    }
419                    else {
420                            query = new StringBundler(3);
421                    }
422    
423                    query.append(_SQL_SELECT_SCPRODUCTSCREENSHOT_WHERE);
424    
425                    query.append(_FINDER_COLUMN_PRODUCTENTRYID_PRODUCTENTRYID_2);
426    
427                    if (orderByComparator != null) {
428                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
429    
430                            if (orderByConditionFields.length > 0) {
431                                    query.append(WHERE_AND);
432                            }
433    
434                            for (int i = 0; i < orderByConditionFields.length; i++) {
435                                    query.append(_ORDER_BY_ENTITY_ALIAS);
436                                    query.append(orderByConditionFields[i]);
437    
438                                    if ((i + 1) < orderByConditionFields.length) {
439                                            if (orderByComparator.isAscending() ^ previous) {
440                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
441                                            }
442                                            else {
443                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
444                                            }
445                                    }
446                                    else {
447                                            if (orderByComparator.isAscending() ^ previous) {
448                                                    query.append(WHERE_GREATER_THAN);
449                                            }
450                                            else {
451                                                    query.append(WHERE_LESSER_THAN);
452                                            }
453                                    }
454                            }
455    
456                            query.append(ORDER_BY_CLAUSE);
457    
458                            String[] orderByFields = orderByComparator.getOrderByFields();
459    
460                            for (int i = 0; i < orderByFields.length; i++) {
461                                    query.append(_ORDER_BY_ENTITY_ALIAS);
462                                    query.append(orderByFields[i]);
463    
464                                    if ((i + 1) < orderByFields.length) {
465                                            if (orderByComparator.isAscending() ^ previous) {
466                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
467                                            }
468                                            else {
469                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
470                                            }
471                                    }
472                                    else {
473                                            if (orderByComparator.isAscending() ^ previous) {
474                                                    query.append(ORDER_BY_ASC);
475                                            }
476                                            else {
477                                                    query.append(ORDER_BY_DESC);
478                                            }
479                                    }
480                            }
481                    }
482                    else {
483                            query.append(SCProductScreenshotModelImpl.ORDER_BY_JPQL);
484                    }
485    
486                    String sql = query.toString();
487    
488                    Query q = session.createQuery(sql);
489    
490                    q.setFirstResult(0);
491                    q.setMaxResults(2);
492    
493                    QueryPos qPos = QueryPos.getInstance(q);
494    
495                    qPos.add(productEntryId);
496    
497                    if (orderByComparator != null) {
498                            Object[] values = orderByComparator.getOrderByConditionValues(scProductScreenshot);
499    
500                            for (Object value : values) {
501                                    qPos.add(value);
502                            }
503                    }
504    
505                    List<SCProductScreenshot> list = q.list();
506    
507                    if (list.size() == 2) {
508                            return list.get(1);
509                    }
510                    else {
511                            return null;
512                    }
513            }
514    
515            /**
516             * Removes all the s c product screenshots where productEntryId = &#63; from the database.
517             *
518             * @param productEntryId the product entry ID
519             */
520            @Override
521            public void removeByProductEntryId(long productEntryId) {
522                    for (SCProductScreenshot scProductScreenshot : findByProductEntryId(
523                                    productEntryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
524                            remove(scProductScreenshot);
525                    }
526            }
527    
528            /**
529             * Returns the number of s c product screenshots where productEntryId = &#63;.
530             *
531             * @param productEntryId the product entry ID
532             * @return the number of matching s c product screenshots
533             */
534            @Override
535            public int countByProductEntryId(long productEntryId) {
536                    FinderPath finderPath = FINDER_PATH_COUNT_BY_PRODUCTENTRYID;
537    
538                    Object[] finderArgs = new Object[] { productEntryId };
539    
540                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
541                                    this);
542    
543                    if (count == null) {
544                            StringBundler query = new StringBundler(2);
545    
546                            query.append(_SQL_COUNT_SCPRODUCTSCREENSHOT_WHERE);
547    
548                            query.append(_FINDER_COLUMN_PRODUCTENTRYID_PRODUCTENTRYID_2);
549    
550                            String sql = query.toString();
551    
552                            Session session = null;
553    
554                            try {
555                                    session = openSession();
556    
557                                    Query q = session.createQuery(sql);
558    
559                                    QueryPos qPos = QueryPos.getInstance(q);
560    
561                                    qPos.add(productEntryId);
562    
563                                    count = (Long)q.uniqueResult();
564    
565                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
566                            }
567                            catch (Exception e) {
568                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
569    
570                                    throw processException(e);
571                            }
572                            finally {
573                                    closeSession(session);
574                            }
575                    }
576    
577                    return count.intValue();
578            }
579    
580            private static final String _FINDER_COLUMN_PRODUCTENTRYID_PRODUCTENTRYID_2 = "scProductScreenshot.productEntryId = ?";
581            public static final FinderPath FINDER_PATH_FETCH_BY_THUMBNAILID = new FinderPath(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
582                            SCProductScreenshotModelImpl.FINDER_CACHE_ENABLED,
583                            SCProductScreenshotImpl.class, FINDER_CLASS_NAME_ENTITY,
584                            "fetchByThumbnailId", new String[] { Long.class.getName() },
585                            SCProductScreenshotModelImpl.THUMBNAILID_COLUMN_BITMASK);
586            public static final FinderPath FINDER_PATH_COUNT_BY_THUMBNAILID = new FinderPath(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
587                            SCProductScreenshotModelImpl.FINDER_CACHE_ENABLED, Long.class,
588                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByThumbnailId",
589                            new String[] { Long.class.getName() });
590    
591            /**
592             * Returns the s c product screenshot where thumbnailId = &#63; or throws a {@link NoSuchProductScreenshotException} if it could not be found.
593             *
594             * @param thumbnailId the thumbnail ID
595             * @return the matching s c product screenshot
596             * @throws NoSuchProductScreenshotException if a matching s c product screenshot could not be found
597             */
598            @Override
599            public SCProductScreenshot findByThumbnailId(long thumbnailId)
600                    throws NoSuchProductScreenshotException {
601                    SCProductScreenshot scProductScreenshot = fetchByThumbnailId(thumbnailId);
602    
603                    if (scProductScreenshot == null) {
604                            StringBundler msg = new StringBundler(4);
605    
606                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
607    
608                            msg.append("thumbnailId=");
609                            msg.append(thumbnailId);
610    
611                            msg.append(StringPool.CLOSE_CURLY_BRACE);
612    
613                            if (_log.isWarnEnabled()) {
614                                    _log.warn(msg.toString());
615                            }
616    
617                            throw new NoSuchProductScreenshotException(msg.toString());
618                    }
619    
620                    return scProductScreenshot;
621            }
622    
623            /**
624             * Returns the s c product screenshot where thumbnailId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
625             *
626             * @param thumbnailId the thumbnail ID
627             * @return the matching s c product screenshot, or <code>null</code> if a matching s c product screenshot could not be found
628             */
629            @Override
630            public SCProductScreenshot fetchByThumbnailId(long thumbnailId) {
631                    return fetchByThumbnailId(thumbnailId, true);
632            }
633    
634            /**
635             * Returns the s c product screenshot where thumbnailId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
636             *
637             * @param thumbnailId the thumbnail ID
638             * @param retrieveFromCache whether to use the finder cache
639             * @return the matching s c product screenshot, or <code>null</code> if a matching s c product screenshot could not be found
640             */
641            @Override
642            public SCProductScreenshot fetchByThumbnailId(long thumbnailId,
643                    boolean retrieveFromCache) {
644                    Object[] finderArgs = new Object[] { thumbnailId };
645    
646                    Object result = null;
647    
648                    if (retrieveFromCache) {
649                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_THUMBNAILID,
650                                            finderArgs, this);
651                    }
652    
653                    if (result instanceof SCProductScreenshot) {
654                            SCProductScreenshot scProductScreenshot = (SCProductScreenshot)result;
655    
656                            if ((thumbnailId != scProductScreenshot.getThumbnailId())) {
657                                    result = null;
658                            }
659                    }
660    
661                    if (result == null) {
662                            StringBundler query = new StringBundler(3);
663    
664                            query.append(_SQL_SELECT_SCPRODUCTSCREENSHOT_WHERE);
665    
666                            query.append(_FINDER_COLUMN_THUMBNAILID_THUMBNAILID_2);
667    
668                            String sql = query.toString();
669    
670                            Session session = null;
671    
672                            try {
673                                    session = openSession();
674    
675                                    Query q = session.createQuery(sql);
676    
677                                    QueryPos qPos = QueryPos.getInstance(q);
678    
679                                    qPos.add(thumbnailId);
680    
681                                    List<SCProductScreenshot> list = q.list();
682    
683                                    if (list.isEmpty()) {
684                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_THUMBNAILID,
685                                                    finderArgs, list);
686                                    }
687                                    else {
688                                            if ((list.size() > 1) && _log.isWarnEnabled()) {
689                                                    _log.warn(
690                                                            "SCProductScreenshotPersistenceImpl.fetchByThumbnailId(long, boolean) with parameters (" +
691                                                            StringUtil.merge(finderArgs) +
692                                                            ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder.");
693                                            }
694    
695                                            SCProductScreenshot scProductScreenshot = list.get(0);
696    
697                                            result = scProductScreenshot;
698    
699                                            cacheResult(scProductScreenshot);
700    
701                                            if ((scProductScreenshot.getThumbnailId() != thumbnailId)) {
702                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_THUMBNAILID,
703                                                            finderArgs, scProductScreenshot);
704                                            }
705                                    }
706                            }
707                            catch (Exception e) {
708                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_THUMBNAILID,
709                                            finderArgs);
710    
711                                    throw processException(e);
712                            }
713                            finally {
714                                    closeSession(session);
715                            }
716                    }
717    
718                    if (result instanceof List<?>) {
719                            return null;
720                    }
721                    else {
722                            return (SCProductScreenshot)result;
723                    }
724            }
725    
726            /**
727             * Removes the s c product screenshot where thumbnailId = &#63; from the database.
728             *
729             * @param thumbnailId the thumbnail ID
730             * @return the s c product screenshot that was removed
731             */
732            @Override
733            public SCProductScreenshot removeByThumbnailId(long thumbnailId)
734                    throws NoSuchProductScreenshotException {
735                    SCProductScreenshot scProductScreenshot = findByThumbnailId(thumbnailId);
736    
737                    return remove(scProductScreenshot);
738            }
739    
740            /**
741             * Returns the number of s c product screenshots where thumbnailId = &#63;.
742             *
743             * @param thumbnailId the thumbnail ID
744             * @return the number of matching s c product screenshots
745             */
746            @Override
747            public int countByThumbnailId(long thumbnailId) {
748                    FinderPath finderPath = FINDER_PATH_COUNT_BY_THUMBNAILID;
749    
750                    Object[] finderArgs = new Object[] { thumbnailId };
751    
752                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
753                                    this);
754    
755                    if (count == null) {
756                            StringBundler query = new StringBundler(2);
757    
758                            query.append(_SQL_COUNT_SCPRODUCTSCREENSHOT_WHERE);
759    
760                            query.append(_FINDER_COLUMN_THUMBNAILID_THUMBNAILID_2);
761    
762                            String sql = query.toString();
763    
764                            Session session = null;
765    
766                            try {
767                                    session = openSession();
768    
769                                    Query q = session.createQuery(sql);
770    
771                                    QueryPos qPos = QueryPos.getInstance(q);
772    
773                                    qPos.add(thumbnailId);
774    
775                                    count = (Long)q.uniqueResult();
776    
777                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
778                            }
779                            catch (Exception e) {
780                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
781    
782                                    throw processException(e);
783                            }
784                            finally {
785                                    closeSession(session);
786                            }
787                    }
788    
789                    return count.intValue();
790            }
791    
792            private static final String _FINDER_COLUMN_THUMBNAILID_THUMBNAILID_2 = "scProductScreenshot.thumbnailId = ?";
793            public static final FinderPath FINDER_PATH_FETCH_BY_FULLIMAGEID = new FinderPath(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
794                            SCProductScreenshotModelImpl.FINDER_CACHE_ENABLED,
795                            SCProductScreenshotImpl.class, FINDER_CLASS_NAME_ENTITY,
796                            "fetchByFullImageId", new String[] { Long.class.getName() },
797                            SCProductScreenshotModelImpl.FULLIMAGEID_COLUMN_BITMASK);
798            public static final FinderPath FINDER_PATH_COUNT_BY_FULLIMAGEID = new FinderPath(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
799                            SCProductScreenshotModelImpl.FINDER_CACHE_ENABLED, Long.class,
800                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByFullImageId",
801                            new String[] { Long.class.getName() });
802    
803            /**
804             * Returns the s c product screenshot where fullImageId = &#63; or throws a {@link NoSuchProductScreenshotException} if it could not be found.
805             *
806             * @param fullImageId the full image ID
807             * @return the matching s c product screenshot
808             * @throws NoSuchProductScreenshotException if a matching s c product screenshot could not be found
809             */
810            @Override
811            public SCProductScreenshot findByFullImageId(long fullImageId)
812                    throws NoSuchProductScreenshotException {
813                    SCProductScreenshot scProductScreenshot = fetchByFullImageId(fullImageId);
814    
815                    if (scProductScreenshot == null) {
816                            StringBundler msg = new StringBundler(4);
817    
818                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
819    
820                            msg.append("fullImageId=");
821                            msg.append(fullImageId);
822    
823                            msg.append(StringPool.CLOSE_CURLY_BRACE);
824    
825                            if (_log.isWarnEnabled()) {
826                                    _log.warn(msg.toString());
827                            }
828    
829                            throw new NoSuchProductScreenshotException(msg.toString());
830                    }
831    
832                    return scProductScreenshot;
833            }
834    
835            /**
836             * Returns the s c product screenshot where fullImageId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
837             *
838             * @param fullImageId the full image ID
839             * @return the matching s c product screenshot, or <code>null</code> if a matching s c product screenshot could not be found
840             */
841            @Override
842            public SCProductScreenshot fetchByFullImageId(long fullImageId) {
843                    return fetchByFullImageId(fullImageId, true);
844            }
845    
846            /**
847             * Returns the s c product screenshot where fullImageId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
848             *
849             * @param fullImageId the full image ID
850             * @param retrieveFromCache whether to use the finder cache
851             * @return the matching s c product screenshot, or <code>null</code> if a matching s c product screenshot could not be found
852             */
853            @Override
854            public SCProductScreenshot fetchByFullImageId(long fullImageId,
855                    boolean retrieveFromCache) {
856                    Object[] finderArgs = new Object[] { fullImageId };
857    
858                    Object result = null;
859    
860                    if (retrieveFromCache) {
861                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_FULLIMAGEID,
862                                            finderArgs, this);
863                    }
864    
865                    if (result instanceof SCProductScreenshot) {
866                            SCProductScreenshot scProductScreenshot = (SCProductScreenshot)result;
867    
868                            if ((fullImageId != scProductScreenshot.getFullImageId())) {
869                                    result = null;
870                            }
871                    }
872    
873                    if (result == null) {
874                            StringBundler query = new StringBundler(3);
875    
876                            query.append(_SQL_SELECT_SCPRODUCTSCREENSHOT_WHERE);
877    
878                            query.append(_FINDER_COLUMN_FULLIMAGEID_FULLIMAGEID_2);
879    
880                            String sql = query.toString();
881    
882                            Session session = null;
883    
884                            try {
885                                    session = openSession();
886    
887                                    Query q = session.createQuery(sql);
888    
889                                    QueryPos qPos = QueryPos.getInstance(q);
890    
891                                    qPos.add(fullImageId);
892    
893                                    List<SCProductScreenshot> list = q.list();
894    
895                                    if (list.isEmpty()) {
896                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_FULLIMAGEID,
897                                                    finderArgs, list);
898                                    }
899                                    else {
900                                            if ((list.size() > 1) && _log.isWarnEnabled()) {
901                                                    _log.warn(
902                                                            "SCProductScreenshotPersistenceImpl.fetchByFullImageId(long, boolean) with parameters (" +
903                                                            StringUtil.merge(finderArgs) +
904                                                            ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder.");
905                                            }
906    
907                                            SCProductScreenshot scProductScreenshot = list.get(0);
908    
909                                            result = scProductScreenshot;
910    
911                                            cacheResult(scProductScreenshot);
912    
913                                            if ((scProductScreenshot.getFullImageId() != fullImageId)) {
914                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_FULLIMAGEID,
915                                                            finderArgs, scProductScreenshot);
916                                            }
917                                    }
918                            }
919                            catch (Exception e) {
920                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_FULLIMAGEID,
921                                            finderArgs);
922    
923                                    throw processException(e);
924                            }
925                            finally {
926                                    closeSession(session);
927                            }
928                    }
929    
930                    if (result instanceof List<?>) {
931                            return null;
932                    }
933                    else {
934                            return (SCProductScreenshot)result;
935                    }
936            }
937    
938            /**
939             * Removes the s c product screenshot where fullImageId = &#63; from the database.
940             *
941             * @param fullImageId the full image ID
942             * @return the s c product screenshot that was removed
943             */
944            @Override
945            public SCProductScreenshot removeByFullImageId(long fullImageId)
946                    throws NoSuchProductScreenshotException {
947                    SCProductScreenshot scProductScreenshot = findByFullImageId(fullImageId);
948    
949                    return remove(scProductScreenshot);
950            }
951    
952            /**
953             * Returns the number of s c product screenshots where fullImageId = &#63;.
954             *
955             * @param fullImageId the full image ID
956             * @return the number of matching s c product screenshots
957             */
958            @Override
959            public int countByFullImageId(long fullImageId) {
960                    FinderPath finderPath = FINDER_PATH_COUNT_BY_FULLIMAGEID;
961    
962                    Object[] finderArgs = new Object[] { fullImageId };
963    
964                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
965                                    this);
966    
967                    if (count == null) {
968                            StringBundler query = new StringBundler(2);
969    
970                            query.append(_SQL_COUNT_SCPRODUCTSCREENSHOT_WHERE);
971    
972                            query.append(_FINDER_COLUMN_FULLIMAGEID_FULLIMAGEID_2);
973    
974                            String sql = query.toString();
975    
976                            Session session = null;
977    
978                            try {
979                                    session = openSession();
980    
981                                    Query q = session.createQuery(sql);
982    
983                                    QueryPos qPos = QueryPos.getInstance(q);
984    
985                                    qPos.add(fullImageId);
986    
987                                    count = (Long)q.uniqueResult();
988    
989                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
990                            }
991                            catch (Exception e) {
992                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
993    
994                                    throw processException(e);
995                            }
996                            finally {
997                                    closeSession(session);
998                            }
999                    }
1000    
1001                    return count.intValue();
1002            }
1003    
1004            private static final String _FINDER_COLUMN_FULLIMAGEID_FULLIMAGEID_2 = "scProductScreenshot.fullImageId = ?";
1005            public static final FinderPath FINDER_PATH_FETCH_BY_P_P = new FinderPath(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
1006                            SCProductScreenshotModelImpl.FINDER_CACHE_ENABLED,
1007                            SCProductScreenshotImpl.class, FINDER_CLASS_NAME_ENTITY,
1008                            "fetchByP_P",
1009                            new String[] { Long.class.getName(), Integer.class.getName() },
1010                            SCProductScreenshotModelImpl.PRODUCTENTRYID_COLUMN_BITMASK |
1011                            SCProductScreenshotModelImpl.PRIORITY_COLUMN_BITMASK);
1012            public static final FinderPath FINDER_PATH_COUNT_BY_P_P = new FinderPath(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
1013                            SCProductScreenshotModelImpl.FINDER_CACHE_ENABLED, Long.class,
1014                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_P",
1015                            new String[] { Long.class.getName(), Integer.class.getName() });
1016    
1017            /**
1018             * Returns the s c product screenshot where productEntryId = &#63; and priority = &#63; or throws a {@link NoSuchProductScreenshotException} if it could not be found.
1019             *
1020             * @param productEntryId the product entry ID
1021             * @param priority the priority
1022             * @return the matching s c product screenshot
1023             * @throws NoSuchProductScreenshotException if a matching s c product screenshot could not be found
1024             */
1025            @Override
1026            public SCProductScreenshot findByP_P(long productEntryId, int priority)
1027                    throws NoSuchProductScreenshotException {
1028                    SCProductScreenshot scProductScreenshot = fetchByP_P(productEntryId,
1029                                    priority);
1030    
1031                    if (scProductScreenshot == null) {
1032                            StringBundler msg = new StringBundler(6);
1033    
1034                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1035    
1036                            msg.append("productEntryId=");
1037                            msg.append(productEntryId);
1038    
1039                            msg.append(", priority=");
1040                            msg.append(priority);
1041    
1042                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1043    
1044                            if (_log.isWarnEnabled()) {
1045                                    _log.warn(msg.toString());
1046                            }
1047    
1048                            throw new NoSuchProductScreenshotException(msg.toString());
1049                    }
1050    
1051                    return scProductScreenshot;
1052            }
1053    
1054            /**
1055             * Returns the s c product screenshot where productEntryId = &#63; and priority = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1056             *
1057             * @param productEntryId the product entry ID
1058             * @param priority the priority
1059             * @return the matching s c product screenshot, or <code>null</code> if a matching s c product screenshot could not be found
1060             */
1061            @Override
1062            public SCProductScreenshot fetchByP_P(long productEntryId, int priority) {
1063                    return fetchByP_P(productEntryId, priority, true);
1064            }
1065    
1066            /**
1067             * Returns the s c product screenshot where productEntryId = &#63; and priority = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1068             *
1069             * @param productEntryId the product entry ID
1070             * @param priority the priority
1071             * @param retrieveFromCache whether to use the finder cache
1072             * @return the matching s c product screenshot, or <code>null</code> if a matching s c product screenshot could not be found
1073             */
1074            @Override
1075            public SCProductScreenshot fetchByP_P(long productEntryId, int priority,
1076                    boolean retrieveFromCache) {
1077                    Object[] finderArgs = new Object[] { productEntryId, priority };
1078    
1079                    Object result = null;
1080    
1081                    if (retrieveFromCache) {
1082                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_P_P,
1083                                            finderArgs, this);
1084                    }
1085    
1086                    if (result instanceof SCProductScreenshot) {
1087                            SCProductScreenshot scProductScreenshot = (SCProductScreenshot)result;
1088    
1089                            if ((productEntryId != scProductScreenshot.getProductEntryId()) ||
1090                                            (priority != scProductScreenshot.getPriority())) {
1091                                    result = null;
1092                            }
1093                    }
1094    
1095                    if (result == null) {
1096                            StringBundler query = new StringBundler(4);
1097    
1098                            query.append(_SQL_SELECT_SCPRODUCTSCREENSHOT_WHERE);
1099    
1100                            query.append(_FINDER_COLUMN_P_P_PRODUCTENTRYID_2);
1101    
1102                            query.append(_FINDER_COLUMN_P_P_PRIORITY_2);
1103    
1104                            String sql = query.toString();
1105    
1106                            Session session = null;
1107    
1108                            try {
1109                                    session = openSession();
1110    
1111                                    Query q = session.createQuery(sql);
1112    
1113                                    QueryPos qPos = QueryPos.getInstance(q);
1114    
1115                                    qPos.add(productEntryId);
1116    
1117                                    qPos.add(priority);
1118    
1119                                    List<SCProductScreenshot> list = q.list();
1120    
1121                                    if (list.isEmpty()) {
1122                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_P,
1123                                                    finderArgs, list);
1124                                    }
1125                                    else {
1126                                            if ((list.size() > 1) && _log.isWarnEnabled()) {
1127                                                    _log.warn(
1128                                                            "SCProductScreenshotPersistenceImpl.fetchByP_P(long, int, boolean) with parameters (" +
1129                                                            StringUtil.merge(finderArgs) +
1130                                                            ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder.");
1131                                            }
1132    
1133                                            SCProductScreenshot scProductScreenshot = list.get(0);
1134    
1135                                            result = scProductScreenshot;
1136    
1137                                            cacheResult(scProductScreenshot);
1138    
1139                                            if ((scProductScreenshot.getProductEntryId() != productEntryId) ||
1140                                                            (scProductScreenshot.getPriority() != priority)) {
1141                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_P,
1142                                                            finderArgs, scProductScreenshot);
1143                                            }
1144                                    }
1145                            }
1146                            catch (Exception e) {
1147                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_P,
1148                                            finderArgs);
1149    
1150                                    throw processException(e);
1151                            }
1152                            finally {
1153                                    closeSession(session);
1154                            }
1155                    }
1156    
1157                    if (result instanceof List<?>) {
1158                            return null;
1159                    }
1160                    else {
1161                            return (SCProductScreenshot)result;
1162                    }
1163            }
1164    
1165            /**
1166             * Removes the s c product screenshot where productEntryId = &#63; and priority = &#63; from the database.
1167             *
1168             * @param productEntryId the product entry ID
1169             * @param priority the priority
1170             * @return the s c product screenshot that was removed
1171             */
1172            @Override
1173            public SCProductScreenshot removeByP_P(long productEntryId, int priority)
1174                    throws NoSuchProductScreenshotException {
1175                    SCProductScreenshot scProductScreenshot = findByP_P(productEntryId,
1176                                    priority);
1177    
1178                    return remove(scProductScreenshot);
1179            }
1180    
1181            /**
1182             * Returns the number of s c product screenshots where productEntryId = &#63; and priority = &#63;.
1183             *
1184             * @param productEntryId the product entry ID
1185             * @param priority the priority
1186             * @return the number of matching s c product screenshots
1187             */
1188            @Override
1189            public int countByP_P(long productEntryId, int priority) {
1190                    FinderPath finderPath = FINDER_PATH_COUNT_BY_P_P;
1191    
1192                    Object[] finderArgs = new Object[] { productEntryId, priority };
1193    
1194                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1195                                    this);
1196    
1197                    if (count == null) {
1198                            StringBundler query = new StringBundler(3);
1199    
1200                            query.append(_SQL_COUNT_SCPRODUCTSCREENSHOT_WHERE);
1201    
1202                            query.append(_FINDER_COLUMN_P_P_PRODUCTENTRYID_2);
1203    
1204                            query.append(_FINDER_COLUMN_P_P_PRIORITY_2);
1205    
1206                            String sql = query.toString();
1207    
1208                            Session session = null;
1209    
1210                            try {
1211                                    session = openSession();
1212    
1213                                    Query q = session.createQuery(sql);
1214    
1215                                    QueryPos qPos = QueryPos.getInstance(q);
1216    
1217                                    qPos.add(productEntryId);
1218    
1219                                    qPos.add(priority);
1220    
1221                                    count = (Long)q.uniqueResult();
1222    
1223                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1224                            }
1225                            catch (Exception e) {
1226                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1227    
1228                                    throw processException(e);
1229                            }
1230                            finally {
1231                                    closeSession(session);
1232                            }
1233                    }
1234    
1235                    return count.intValue();
1236            }
1237    
1238            private static final String _FINDER_COLUMN_P_P_PRODUCTENTRYID_2 = "scProductScreenshot.productEntryId = ? AND ";
1239            private static final String _FINDER_COLUMN_P_P_PRIORITY_2 = "scProductScreenshot.priority = ?";
1240    
1241            public SCProductScreenshotPersistenceImpl() {
1242                    setModelClass(SCProductScreenshot.class);
1243            }
1244    
1245            /**
1246             * Caches the s c product screenshot in the entity cache if it is enabled.
1247             *
1248             * @param scProductScreenshot the s c product screenshot
1249             */
1250            @Override
1251            public void cacheResult(SCProductScreenshot scProductScreenshot) {
1252                    EntityCacheUtil.putResult(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
1253                            SCProductScreenshotImpl.class, scProductScreenshot.getPrimaryKey(),
1254                            scProductScreenshot);
1255    
1256                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_THUMBNAILID,
1257                            new Object[] { scProductScreenshot.getThumbnailId() },
1258                            scProductScreenshot);
1259    
1260                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_FULLIMAGEID,
1261                            new Object[] { scProductScreenshot.getFullImageId() },
1262                            scProductScreenshot);
1263    
1264                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_P,
1265                            new Object[] {
1266                                    scProductScreenshot.getProductEntryId(),
1267                                    scProductScreenshot.getPriority()
1268                            }, scProductScreenshot);
1269    
1270                    scProductScreenshot.resetOriginalValues();
1271            }
1272    
1273            /**
1274             * Caches the s c product screenshots in the entity cache if it is enabled.
1275             *
1276             * @param scProductScreenshots the s c product screenshots
1277             */
1278            @Override
1279            public void cacheResult(List<SCProductScreenshot> scProductScreenshots) {
1280                    for (SCProductScreenshot scProductScreenshot : scProductScreenshots) {
1281                            if (EntityCacheUtil.getResult(
1282                                                    SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
1283                                                    SCProductScreenshotImpl.class,
1284                                                    scProductScreenshot.getPrimaryKey()) == null) {
1285                                    cacheResult(scProductScreenshot);
1286                            }
1287                            else {
1288                                    scProductScreenshot.resetOriginalValues();
1289                            }
1290                    }
1291            }
1292    
1293            /**
1294             * Clears the cache for all s c product screenshots.
1295             *
1296             * <p>
1297             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
1298             * </p>
1299             */
1300            @Override
1301            public void clearCache() {
1302                    EntityCacheUtil.clearCache(SCProductScreenshotImpl.class);
1303    
1304                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
1305                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1306                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1307            }
1308    
1309            /**
1310             * Clears the cache for the s c product screenshot.
1311             *
1312             * <p>
1313             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
1314             * </p>
1315             */
1316            @Override
1317            public void clearCache(SCProductScreenshot scProductScreenshot) {
1318                    EntityCacheUtil.removeResult(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
1319                            SCProductScreenshotImpl.class, scProductScreenshot.getPrimaryKey());
1320    
1321                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1322                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1323    
1324                    clearUniqueFindersCache(scProductScreenshot);
1325            }
1326    
1327            @Override
1328            public void clearCache(List<SCProductScreenshot> scProductScreenshots) {
1329                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1330                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1331    
1332                    for (SCProductScreenshot scProductScreenshot : scProductScreenshots) {
1333                            EntityCacheUtil.removeResult(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
1334                                    SCProductScreenshotImpl.class,
1335                                    scProductScreenshot.getPrimaryKey());
1336    
1337                            clearUniqueFindersCache(scProductScreenshot);
1338                    }
1339            }
1340    
1341            protected void cacheUniqueFindersCache(
1342                    SCProductScreenshot scProductScreenshot) {
1343                    if (scProductScreenshot.isNew()) {
1344                            Object[] args = new Object[] { scProductScreenshot.getThumbnailId() };
1345    
1346                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_THUMBNAILID, args,
1347                                    Long.valueOf(1));
1348                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_THUMBNAILID, args,
1349                                    scProductScreenshot);
1350    
1351                            args = new Object[] { scProductScreenshot.getFullImageId() };
1352    
1353                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_FULLIMAGEID, args,
1354                                    Long.valueOf(1));
1355                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_FULLIMAGEID, args,
1356                                    scProductScreenshot);
1357    
1358                            args = new Object[] {
1359                                            scProductScreenshot.getProductEntryId(),
1360                                            scProductScreenshot.getPriority()
1361                                    };
1362    
1363                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_P, args,
1364                                    Long.valueOf(1));
1365                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_P, args,
1366                                    scProductScreenshot);
1367                    }
1368                    else {
1369                            SCProductScreenshotModelImpl scProductScreenshotModelImpl = (SCProductScreenshotModelImpl)scProductScreenshot;
1370    
1371                            if ((scProductScreenshotModelImpl.getColumnBitmask() &
1372                                            FINDER_PATH_FETCH_BY_THUMBNAILID.getColumnBitmask()) != 0) {
1373                                    Object[] args = new Object[] {
1374                                                    scProductScreenshot.getThumbnailId()
1375                                            };
1376    
1377                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_THUMBNAILID,
1378                                            args, Long.valueOf(1));
1379                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_THUMBNAILID,
1380                                            args, scProductScreenshot);
1381                            }
1382    
1383                            if ((scProductScreenshotModelImpl.getColumnBitmask() &
1384                                            FINDER_PATH_FETCH_BY_FULLIMAGEID.getColumnBitmask()) != 0) {
1385                                    Object[] args = new Object[] {
1386                                                    scProductScreenshot.getFullImageId()
1387                                            };
1388    
1389                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_FULLIMAGEID,
1390                                            args, Long.valueOf(1));
1391                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_FULLIMAGEID,
1392                                            args, scProductScreenshot);
1393                            }
1394    
1395                            if ((scProductScreenshotModelImpl.getColumnBitmask() &
1396                                            FINDER_PATH_FETCH_BY_P_P.getColumnBitmask()) != 0) {
1397                                    Object[] args = new Object[] {
1398                                                    scProductScreenshot.getProductEntryId(),
1399                                                    scProductScreenshot.getPriority()
1400                                            };
1401    
1402                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_P, args,
1403                                            Long.valueOf(1));
1404                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_P, args,
1405                                            scProductScreenshot);
1406                            }
1407                    }
1408            }
1409    
1410            protected void clearUniqueFindersCache(
1411                    SCProductScreenshot scProductScreenshot) {
1412                    SCProductScreenshotModelImpl scProductScreenshotModelImpl = (SCProductScreenshotModelImpl)scProductScreenshot;
1413    
1414                    Object[] args = new Object[] { scProductScreenshot.getThumbnailId() };
1415    
1416                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_THUMBNAILID, args);
1417                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_THUMBNAILID, args);
1418    
1419                    if ((scProductScreenshotModelImpl.getColumnBitmask() &
1420                                    FINDER_PATH_FETCH_BY_THUMBNAILID.getColumnBitmask()) != 0) {
1421                            args = new Object[] {
1422                                            scProductScreenshotModelImpl.getOriginalThumbnailId()
1423                                    };
1424    
1425                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_THUMBNAILID, args);
1426                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_THUMBNAILID, args);
1427                    }
1428    
1429                    args = new Object[] { scProductScreenshot.getFullImageId() };
1430    
1431                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FULLIMAGEID, args);
1432                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_FULLIMAGEID, args);
1433    
1434                    if ((scProductScreenshotModelImpl.getColumnBitmask() &
1435                                    FINDER_PATH_FETCH_BY_FULLIMAGEID.getColumnBitmask()) != 0) {
1436                            args = new Object[] {
1437                                            scProductScreenshotModelImpl.getOriginalFullImageId()
1438                                    };
1439    
1440                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FULLIMAGEID, args);
1441                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_FULLIMAGEID, args);
1442                    }
1443    
1444                    args = new Object[] {
1445                                    scProductScreenshot.getProductEntryId(),
1446                                    scProductScreenshot.getPriority()
1447                            };
1448    
1449                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_P, args);
1450                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_P, args);
1451    
1452                    if ((scProductScreenshotModelImpl.getColumnBitmask() &
1453                                    FINDER_PATH_FETCH_BY_P_P.getColumnBitmask()) != 0) {
1454                            args = new Object[] {
1455                                            scProductScreenshotModelImpl.getOriginalProductEntryId(),
1456                                            scProductScreenshotModelImpl.getOriginalPriority()
1457                                    };
1458    
1459                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_P, args);
1460                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_P, args);
1461                    }
1462            }
1463    
1464            /**
1465             * Creates a new s c product screenshot with the primary key. Does not add the s c product screenshot to the database.
1466             *
1467             * @param productScreenshotId the primary key for the new s c product screenshot
1468             * @return the new s c product screenshot
1469             */
1470            @Override
1471            public SCProductScreenshot create(long productScreenshotId) {
1472                    SCProductScreenshot scProductScreenshot = new SCProductScreenshotImpl();
1473    
1474                    scProductScreenshot.setNew(true);
1475                    scProductScreenshot.setPrimaryKey(productScreenshotId);
1476    
1477                    return scProductScreenshot;
1478            }
1479    
1480            /**
1481             * Removes the s c product screenshot with the primary key from the database. Also notifies the appropriate model listeners.
1482             *
1483             * @param productScreenshotId the primary key of the s c product screenshot
1484             * @return the s c product screenshot that was removed
1485             * @throws NoSuchProductScreenshotException if a s c product screenshot with the primary key could not be found
1486             */
1487            @Override
1488            public SCProductScreenshot remove(long productScreenshotId)
1489                    throws NoSuchProductScreenshotException {
1490                    return remove((Serializable)productScreenshotId);
1491            }
1492    
1493            /**
1494             * Removes the s c product screenshot with the primary key from the database. Also notifies the appropriate model listeners.
1495             *
1496             * @param primaryKey the primary key of the s c product screenshot
1497             * @return the s c product screenshot that was removed
1498             * @throws NoSuchProductScreenshotException if a s c product screenshot with the primary key could not be found
1499             */
1500            @Override
1501            public SCProductScreenshot remove(Serializable primaryKey)
1502                    throws NoSuchProductScreenshotException {
1503                    Session session = null;
1504    
1505                    try {
1506                            session = openSession();
1507    
1508                            SCProductScreenshot scProductScreenshot = (SCProductScreenshot)session.get(SCProductScreenshotImpl.class,
1509                                            primaryKey);
1510    
1511                            if (scProductScreenshot == null) {
1512                                    if (_log.isWarnEnabled()) {
1513                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
1514                                    }
1515    
1516                                    throw new NoSuchProductScreenshotException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1517                                            primaryKey);
1518                            }
1519    
1520                            return remove(scProductScreenshot);
1521                    }
1522                    catch (NoSuchProductScreenshotException nsee) {
1523                            throw nsee;
1524                    }
1525                    catch (Exception e) {
1526                            throw processException(e);
1527                    }
1528                    finally {
1529                            closeSession(session);
1530                    }
1531            }
1532    
1533            @Override
1534            protected SCProductScreenshot removeImpl(
1535                    SCProductScreenshot scProductScreenshot) {
1536                    scProductScreenshot = toUnwrappedModel(scProductScreenshot);
1537    
1538                    Session session = null;
1539    
1540                    try {
1541                            session = openSession();
1542    
1543                            if (!session.contains(scProductScreenshot)) {
1544                                    scProductScreenshot = (SCProductScreenshot)session.get(SCProductScreenshotImpl.class,
1545                                                    scProductScreenshot.getPrimaryKeyObj());
1546                            }
1547    
1548                            if (scProductScreenshot != null) {
1549                                    session.delete(scProductScreenshot);
1550                            }
1551                    }
1552                    catch (Exception e) {
1553                            throw processException(e);
1554                    }
1555                    finally {
1556                            closeSession(session);
1557                    }
1558    
1559                    if (scProductScreenshot != null) {
1560                            clearCache(scProductScreenshot);
1561                    }
1562    
1563                    return scProductScreenshot;
1564            }
1565    
1566            @Override
1567            public SCProductScreenshot updateImpl(
1568                    SCProductScreenshot scProductScreenshot) {
1569                    scProductScreenshot = toUnwrappedModel(scProductScreenshot);
1570    
1571                    boolean isNew = scProductScreenshot.isNew();
1572    
1573                    SCProductScreenshotModelImpl scProductScreenshotModelImpl = (SCProductScreenshotModelImpl)scProductScreenshot;
1574    
1575                    Session session = null;
1576    
1577                    try {
1578                            session = openSession();
1579    
1580                            if (scProductScreenshot.isNew()) {
1581                                    session.save(scProductScreenshot);
1582    
1583                                    scProductScreenshot.setNew(false);
1584                            }
1585                            else {
1586                                    session.merge(scProductScreenshot);
1587                            }
1588                    }
1589                    catch (Exception e) {
1590                            throw processException(e);
1591                    }
1592                    finally {
1593                            closeSession(session);
1594                    }
1595    
1596                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1597    
1598                    if (isNew || !SCProductScreenshotModelImpl.COLUMN_BITMASK_ENABLED) {
1599                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1600                    }
1601    
1602                    else {
1603                            if ((scProductScreenshotModelImpl.getColumnBitmask() &
1604                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PRODUCTENTRYID.getColumnBitmask()) != 0) {
1605                                    Object[] args = new Object[] {
1606                                                    scProductScreenshotModelImpl.getOriginalProductEntryId()
1607                                            };
1608    
1609                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PRODUCTENTRYID,
1610                                            args);
1611                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PRODUCTENTRYID,
1612                                            args);
1613    
1614                                    args = new Object[] {
1615                                                    scProductScreenshotModelImpl.getProductEntryId()
1616                                            };
1617    
1618                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PRODUCTENTRYID,
1619                                            args);
1620                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PRODUCTENTRYID,
1621                                            args);
1622                            }
1623                    }
1624    
1625                    EntityCacheUtil.putResult(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
1626                            SCProductScreenshotImpl.class, scProductScreenshot.getPrimaryKey(),
1627                            scProductScreenshot, false);
1628    
1629                    clearUniqueFindersCache(scProductScreenshot);
1630                    cacheUniqueFindersCache(scProductScreenshot);
1631    
1632                    scProductScreenshot.resetOriginalValues();
1633    
1634                    return scProductScreenshot;
1635            }
1636    
1637            protected SCProductScreenshot toUnwrappedModel(
1638                    SCProductScreenshot scProductScreenshot) {
1639                    if (scProductScreenshot instanceof SCProductScreenshotImpl) {
1640                            return scProductScreenshot;
1641                    }
1642    
1643                    SCProductScreenshotImpl scProductScreenshotImpl = new SCProductScreenshotImpl();
1644    
1645                    scProductScreenshotImpl.setNew(scProductScreenshot.isNew());
1646                    scProductScreenshotImpl.setPrimaryKey(scProductScreenshot.getPrimaryKey());
1647    
1648                    scProductScreenshotImpl.setProductScreenshotId(scProductScreenshot.getProductScreenshotId());
1649                    scProductScreenshotImpl.setCompanyId(scProductScreenshot.getCompanyId());
1650                    scProductScreenshotImpl.setGroupId(scProductScreenshot.getGroupId());
1651                    scProductScreenshotImpl.setProductEntryId(scProductScreenshot.getProductEntryId());
1652                    scProductScreenshotImpl.setThumbnailId(scProductScreenshot.getThumbnailId());
1653                    scProductScreenshotImpl.setFullImageId(scProductScreenshot.getFullImageId());
1654                    scProductScreenshotImpl.setPriority(scProductScreenshot.getPriority());
1655    
1656                    return scProductScreenshotImpl;
1657            }
1658    
1659            /**
1660             * Returns the s c product screenshot with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
1661             *
1662             * @param primaryKey the primary key of the s c product screenshot
1663             * @return the s c product screenshot
1664             * @throws NoSuchProductScreenshotException if a s c product screenshot with the primary key could not be found
1665             */
1666            @Override
1667            public SCProductScreenshot findByPrimaryKey(Serializable primaryKey)
1668                    throws NoSuchProductScreenshotException {
1669                    SCProductScreenshot scProductScreenshot = fetchByPrimaryKey(primaryKey);
1670    
1671                    if (scProductScreenshot == null) {
1672                            if (_log.isWarnEnabled()) {
1673                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
1674                            }
1675    
1676                            throw new NoSuchProductScreenshotException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1677                                    primaryKey);
1678                    }
1679    
1680                    return scProductScreenshot;
1681            }
1682    
1683            /**
1684             * Returns the s c product screenshot with the primary key or throws a {@link NoSuchProductScreenshotException} if it could not be found.
1685             *
1686             * @param productScreenshotId the primary key of the s c product screenshot
1687             * @return the s c product screenshot
1688             * @throws NoSuchProductScreenshotException if a s c product screenshot with the primary key could not be found
1689             */
1690            @Override
1691            public SCProductScreenshot findByPrimaryKey(long productScreenshotId)
1692                    throws NoSuchProductScreenshotException {
1693                    return findByPrimaryKey((Serializable)productScreenshotId);
1694            }
1695    
1696            /**
1697             * Returns the s c product screenshot with the primary key or returns <code>null</code> if it could not be found.
1698             *
1699             * @param primaryKey the primary key of the s c product screenshot
1700             * @return the s c product screenshot, or <code>null</code> if a s c product screenshot with the primary key could not be found
1701             */
1702            @Override
1703            public SCProductScreenshot fetchByPrimaryKey(Serializable primaryKey) {
1704                    SCProductScreenshot scProductScreenshot = (SCProductScreenshot)EntityCacheUtil.getResult(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
1705                                    SCProductScreenshotImpl.class, primaryKey);
1706    
1707                    if (scProductScreenshot == _nullSCProductScreenshot) {
1708                            return null;
1709                    }
1710    
1711                    if (scProductScreenshot == null) {
1712                            Session session = null;
1713    
1714                            try {
1715                                    session = openSession();
1716    
1717                                    scProductScreenshot = (SCProductScreenshot)session.get(SCProductScreenshotImpl.class,
1718                                                    primaryKey);
1719    
1720                                    if (scProductScreenshot != null) {
1721                                            cacheResult(scProductScreenshot);
1722                                    }
1723                                    else {
1724                                            EntityCacheUtil.putResult(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
1725                                                    SCProductScreenshotImpl.class, primaryKey,
1726                                                    _nullSCProductScreenshot);
1727                                    }
1728                            }
1729                            catch (Exception e) {
1730                                    EntityCacheUtil.removeResult(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
1731                                            SCProductScreenshotImpl.class, primaryKey);
1732    
1733                                    throw processException(e);
1734                            }
1735                            finally {
1736                                    closeSession(session);
1737                            }
1738                    }
1739    
1740                    return scProductScreenshot;
1741            }
1742    
1743            /**
1744             * Returns the s c product screenshot with the primary key or returns <code>null</code> if it could not be found.
1745             *
1746             * @param productScreenshotId the primary key of the s c product screenshot
1747             * @return the s c product screenshot, or <code>null</code> if a s c product screenshot with the primary key could not be found
1748             */
1749            @Override
1750            public SCProductScreenshot fetchByPrimaryKey(long productScreenshotId) {
1751                    return fetchByPrimaryKey((Serializable)productScreenshotId);
1752            }
1753    
1754            @Override
1755            public Map<Serializable, SCProductScreenshot> fetchByPrimaryKeys(
1756                    Set<Serializable> primaryKeys) {
1757                    if (primaryKeys.isEmpty()) {
1758                            return Collections.emptyMap();
1759                    }
1760    
1761                    Map<Serializable, SCProductScreenshot> map = new HashMap<Serializable, SCProductScreenshot>();
1762    
1763                    if (primaryKeys.size() == 1) {
1764                            Iterator<Serializable> iterator = primaryKeys.iterator();
1765    
1766                            Serializable primaryKey = iterator.next();
1767    
1768                            SCProductScreenshot scProductScreenshot = fetchByPrimaryKey(primaryKey);
1769    
1770                            if (scProductScreenshot != null) {
1771                                    map.put(primaryKey, scProductScreenshot);
1772                            }
1773    
1774                            return map;
1775                    }
1776    
1777                    Set<Serializable> uncachedPrimaryKeys = null;
1778    
1779                    for (Serializable primaryKey : primaryKeys) {
1780                            SCProductScreenshot scProductScreenshot = (SCProductScreenshot)EntityCacheUtil.getResult(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
1781                                            SCProductScreenshotImpl.class, primaryKey);
1782    
1783                            if (scProductScreenshot == null) {
1784                                    if (uncachedPrimaryKeys == null) {
1785                                            uncachedPrimaryKeys = new HashSet<Serializable>();
1786                                    }
1787    
1788                                    uncachedPrimaryKeys.add(primaryKey);
1789                            }
1790                            else {
1791                                    map.put(primaryKey, scProductScreenshot);
1792                            }
1793                    }
1794    
1795                    if (uncachedPrimaryKeys == null) {
1796                            return map;
1797                    }
1798    
1799                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
1800                                    1);
1801    
1802                    query.append(_SQL_SELECT_SCPRODUCTSCREENSHOT_WHERE_PKS_IN);
1803    
1804                    for (Serializable primaryKey : uncachedPrimaryKeys) {
1805                            query.append(String.valueOf(primaryKey));
1806    
1807                            query.append(StringPool.COMMA);
1808                    }
1809    
1810                    query.setIndex(query.index() - 1);
1811    
1812                    query.append(StringPool.CLOSE_PARENTHESIS);
1813    
1814                    String sql = query.toString();
1815    
1816                    Session session = null;
1817    
1818                    try {
1819                            session = openSession();
1820    
1821                            Query q = session.createQuery(sql);
1822    
1823                            for (SCProductScreenshot scProductScreenshot : (List<SCProductScreenshot>)q.list()) {
1824                                    map.put(scProductScreenshot.getPrimaryKeyObj(),
1825                                            scProductScreenshot);
1826    
1827                                    cacheResult(scProductScreenshot);
1828    
1829                                    uncachedPrimaryKeys.remove(scProductScreenshot.getPrimaryKeyObj());
1830                            }
1831    
1832                            for (Serializable primaryKey : uncachedPrimaryKeys) {
1833                                    EntityCacheUtil.putResult(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
1834                                            SCProductScreenshotImpl.class, primaryKey,
1835                                            _nullSCProductScreenshot);
1836                            }
1837                    }
1838                    catch (Exception e) {
1839                            throw processException(e);
1840                    }
1841                    finally {
1842                            closeSession(session);
1843                    }
1844    
1845                    return map;
1846            }
1847    
1848            /**
1849             * Returns all the s c product screenshots.
1850             *
1851             * @return the s c product screenshots
1852             */
1853            @Override
1854            public List<SCProductScreenshot> findAll() {
1855                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1856            }
1857    
1858            /**
1859             * Returns a range of all the s c product screenshots.
1860             *
1861             * <p>
1862             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SCProductScreenshotModelImpl}. 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.
1863             * </p>
1864             *
1865             * @param start the lower bound of the range of s c product screenshots
1866             * @param end the upper bound of the range of s c product screenshots (not inclusive)
1867             * @return the range of s c product screenshots
1868             */
1869            @Override
1870            public List<SCProductScreenshot> findAll(int start, int end) {
1871                    return findAll(start, end, null);
1872            }
1873    
1874            /**
1875             * Returns an ordered range of all the s c product screenshots.
1876             *
1877             * <p>
1878             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SCProductScreenshotModelImpl}. 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.
1879             * </p>
1880             *
1881             * @param start the lower bound of the range of s c product screenshots
1882             * @param end the upper bound of the range of s c product screenshots (not inclusive)
1883             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1884             * @return the ordered range of s c product screenshots
1885             */
1886            @Override
1887            public List<SCProductScreenshot> findAll(int start, int end,
1888                    OrderByComparator<SCProductScreenshot> orderByComparator) {
1889                    boolean pagination = true;
1890                    FinderPath finderPath = null;
1891                    Object[] finderArgs = null;
1892    
1893                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1894                                    (orderByComparator == null)) {
1895                            pagination = false;
1896                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1897                            finderArgs = FINDER_ARGS_EMPTY;
1898                    }
1899                    else {
1900                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1901                            finderArgs = new Object[] { start, end, orderByComparator };
1902                    }
1903    
1904                    List<SCProductScreenshot> list = (List<SCProductScreenshot>)FinderCacheUtil.getResult(finderPath,
1905                                    finderArgs, this);
1906    
1907                    if (list == null) {
1908                            StringBundler query = null;
1909                            String sql = null;
1910    
1911                            if (orderByComparator != null) {
1912                                    query = new StringBundler(2 +
1913                                                    (orderByComparator.getOrderByFields().length * 3));
1914    
1915                                    query.append(_SQL_SELECT_SCPRODUCTSCREENSHOT);
1916    
1917                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1918                                            orderByComparator);
1919    
1920                                    sql = query.toString();
1921                            }
1922                            else {
1923                                    sql = _SQL_SELECT_SCPRODUCTSCREENSHOT;
1924    
1925                                    if (pagination) {
1926                                            sql = sql.concat(SCProductScreenshotModelImpl.ORDER_BY_JPQL);
1927                                    }
1928                            }
1929    
1930                            Session session = null;
1931    
1932                            try {
1933                                    session = openSession();
1934    
1935                                    Query q = session.createQuery(sql);
1936    
1937                                    if (!pagination) {
1938                                            list = (List<SCProductScreenshot>)QueryUtil.list(q,
1939                                                            getDialect(), start, end, false);
1940    
1941                                            Collections.sort(list);
1942    
1943                                            list = Collections.unmodifiableList(list);
1944                                    }
1945                                    else {
1946                                            list = (List<SCProductScreenshot>)QueryUtil.list(q,
1947                                                            getDialect(), start, end);
1948                                    }
1949    
1950                                    cacheResult(list);
1951    
1952                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1953                            }
1954                            catch (Exception e) {
1955                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1956    
1957                                    throw processException(e);
1958                            }
1959                            finally {
1960                                    closeSession(session);
1961                            }
1962                    }
1963    
1964                    return list;
1965            }
1966    
1967            /**
1968             * Removes all the s c product screenshots from the database.
1969             *
1970             */
1971            @Override
1972            public void removeAll() {
1973                    for (SCProductScreenshot scProductScreenshot : findAll()) {
1974                            remove(scProductScreenshot);
1975                    }
1976            }
1977    
1978            /**
1979             * Returns the number of s c product screenshots.
1980             *
1981             * @return the number of s c product screenshots
1982             */
1983            @Override
1984            public int countAll() {
1985                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1986                                    FINDER_ARGS_EMPTY, this);
1987    
1988                    if (count == null) {
1989                            Session session = null;
1990    
1991                            try {
1992                                    session = openSession();
1993    
1994                                    Query q = session.createQuery(_SQL_COUNT_SCPRODUCTSCREENSHOT);
1995    
1996                                    count = (Long)q.uniqueResult();
1997    
1998                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1999                                            FINDER_ARGS_EMPTY, count);
2000                            }
2001                            catch (Exception e) {
2002                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
2003                                            FINDER_ARGS_EMPTY);
2004    
2005                                    throw processException(e);
2006                            }
2007                            finally {
2008                                    closeSession(session);
2009                            }
2010                    }
2011    
2012                    return count.intValue();
2013            }
2014    
2015            /**
2016             * Initializes the s c product screenshot persistence.
2017             */
2018            public void afterPropertiesSet() {
2019            }
2020    
2021            public void destroy() {
2022                    EntityCacheUtil.removeCache(SCProductScreenshotImpl.class.getName());
2023                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2024                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2025                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2026            }
2027    
2028            private static final String _SQL_SELECT_SCPRODUCTSCREENSHOT = "SELECT scProductScreenshot FROM SCProductScreenshot scProductScreenshot";
2029            private static final String _SQL_SELECT_SCPRODUCTSCREENSHOT_WHERE_PKS_IN = "SELECT scProductScreenshot FROM SCProductScreenshot scProductScreenshot WHERE productScreenshotId IN (";
2030            private static final String _SQL_SELECT_SCPRODUCTSCREENSHOT_WHERE = "SELECT scProductScreenshot FROM SCProductScreenshot scProductScreenshot WHERE ";
2031            private static final String _SQL_COUNT_SCPRODUCTSCREENSHOT = "SELECT COUNT(scProductScreenshot) FROM SCProductScreenshot scProductScreenshot";
2032            private static final String _SQL_COUNT_SCPRODUCTSCREENSHOT_WHERE = "SELECT COUNT(scProductScreenshot) FROM SCProductScreenshot scProductScreenshot WHERE ";
2033            private static final String _ORDER_BY_ENTITY_ALIAS = "scProductScreenshot.";
2034            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SCProductScreenshot exists with the primary key ";
2035            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SCProductScreenshot exists with the key {";
2036            private static final Log _log = LogFactoryUtil.getLog(SCProductScreenshotPersistenceImpl.class);
2037            private static final SCProductScreenshot _nullSCProductScreenshot = new SCProductScreenshotImpl() {
2038                            @Override
2039                            public Object clone() {
2040                                    return this;
2041                            }
2042    
2043                            @Override
2044                            public CacheModel<SCProductScreenshot> toCacheModel() {
2045                                    return _nullSCProductScreenshotCacheModel;
2046                            }
2047                    };
2048    
2049            private static final CacheModel<SCProductScreenshot> _nullSCProductScreenshotCacheModel =
2050                    new CacheModel<SCProductScreenshot>() {
2051                            @Override
2052                            public SCProductScreenshot toEntityModel() {
2053                                    return _nullSCProductScreenshot;
2054                            }
2055                    };
2056    }