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