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