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