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            /**
1271             * Caches the s c product screenshot in the entity cache if it is enabled.
1272             *
1273             * @param scProductScreenshot the s c product screenshot
1274             */
1275            @Override
1276            public void cacheResult(SCProductScreenshot scProductScreenshot) {
1277                    EntityCacheUtil.putResult(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
1278                            SCProductScreenshotImpl.class, scProductScreenshot.getPrimaryKey(),
1279                            scProductScreenshot);
1280    
1281                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_THUMBNAILID,
1282                            new Object[] { scProductScreenshot.getThumbnailId() },
1283                            scProductScreenshot);
1284    
1285                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_FULLIMAGEID,
1286                            new Object[] { scProductScreenshot.getFullImageId() },
1287                            scProductScreenshot);
1288    
1289                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_P,
1290                            new Object[] {
1291                                    scProductScreenshot.getProductEntryId(),
1292                                    scProductScreenshot.getPriority()
1293                            }, scProductScreenshot);
1294    
1295                    scProductScreenshot.resetOriginalValues();
1296            }
1297    
1298            /**
1299             * Caches the s c product screenshots in the entity cache if it is enabled.
1300             *
1301             * @param scProductScreenshots the s c product screenshots
1302             */
1303            @Override
1304            public void cacheResult(List<SCProductScreenshot> scProductScreenshots) {
1305                    for (SCProductScreenshot scProductScreenshot : scProductScreenshots) {
1306                            if (EntityCacheUtil.getResult(
1307                                                    SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
1308                                                    SCProductScreenshotImpl.class,
1309                                                    scProductScreenshot.getPrimaryKey()) == null) {
1310                                    cacheResult(scProductScreenshot);
1311                            }
1312                            else {
1313                                    scProductScreenshot.resetOriginalValues();
1314                            }
1315                    }
1316            }
1317    
1318            /**
1319             * Clears the cache for all s c product screenshots.
1320             *
1321             * <p>
1322             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
1323             * </p>
1324             */
1325            @Override
1326            public void clearCache() {
1327                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
1328                            CacheRegistryUtil.clear(SCProductScreenshotImpl.class.getName());
1329                    }
1330    
1331                    EntityCacheUtil.clearCache(SCProductScreenshotImpl.class.getName());
1332    
1333                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
1334                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1335                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1336            }
1337    
1338            /**
1339             * Clears the cache for the s c product screenshot.
1340             *
1341             * <p>
1342             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
1343             * </p>
1344             */
1345            @Override
1346            public void clearCache(SCProductScreenshot scProductScreenshot) {
1347                    EntityCacheUtil.removeResult(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
1348                            SCProductScreenshotImpl.class, scProductScreenshot.getPrimaryKey());
1349    
1350                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1351                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1352    
1353                    clearUniqueFindersCache(scProductScreenshot);
1354            }
1355    
1356            @Override
1357            public void clearCache(List<SCProductScreenshot> scProductScreenshots) {
1358                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1359                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1360    
1361                    for (SCProductScreenshot scProductScreenshot : scProductScreenshots) {
1362                            EntityCacheUtil.removeResult(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
1363                                    SCProductScreenshotImpl.class,
1364                                    scProductScreenshot.getPrimaryKey());
1365    
1366                            clearUniqueFindersCache(scProductScreenshot);
1367                    }
1368            }
1369    
1370            protected void cacheUniqueFindersCache(
1371                    SCProductScreenshot scProductScreenshot) {
1372                    if (scProductScreenshot.isNew()) {
1373                            Object[] args = new Object[] { scProductScreenshot.getThumbnailId() };
1374    
1375                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_THUMBNAILID, args,
1376                                    Long.valueOf(1));
1377                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_THUMBNAILID, args,
1378                                    scProductScreenshot);
1379    
1380                            args = new Object[] { scProductScreenshot.getFullImageId() };
1381    
1382                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_FULLIMAGEID, args,
1383                                    Long.valueOf(1));
1384                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_FULLIMAGEID, args,
1385                                    scProductScreenshot);
1386    
1387                            args = new Object[] {
1388                                            scProductScreenshot.getProductEntryId(),
1389                                            scProductScreenshot.getPriority()
1390                                    };
1391    
1392                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_P, args,
1393                                    Long.valueOf(1));
1394                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_P, args,
1395                                    scProductScreenshot);
1396                    }
1397                    else {
1398                            SCProductScreenshotModelImpl scProductScreenshotModelImpl = (SCProductScreenshotModelImpl)scProductScreenshot;
1399    
1400                            if ((scProductScreenshotModelImpl.getColumnBitmask() &
1401                                            FINDER_PATH_FETCH_BY_THUMBNAILID.getColumnBitmask()) != 0) {
1402                                    Object[] args = new Object[] {
1403                                                    scProductScreenshot.getThumbnailId()
1404                                            };
1405    
1406                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_THUMBNAILID,
1407                                            args, Long.valueOf(1));
1408                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_THUMBNAILID,
1409                                            args, scProductScreenshot);
1410                            }
1411    
1412                            if ((scProductScreenshotModelImpl.getColumnBitmask() &
1413                                            FINDER_PATH_FETCH_BY_FULLIMAGEID.getColumnBitmask()) != 0) {
1414                                    Object[] args = new Object[] {
1415                                                    scProductScreenshot.getFullImageId()
1416                                            };
1417    
1418                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_FULLIMAGEID,
1419                                            args, Long.valueOf(1));
1420                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_FULLIMAGEID,
1421                                            args, scProductScreenshot);
1422                            }
1423    
1424                            if ((scProductScreenshotModelImpl.getColumnBitmask() &
1425                                            FINDER_PATH_FETCH_BY_P_P.getColumnBitmask()) != 0) {
1426                                    Object[] args = new Object[] {
1427                                                    scProductScreenshot.getProductEntryId(),
1428                                                    scProductScreenshot.getPriority()
1429                                            };
1430    
1431                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_P, args,
1432                                            Long.valueOf(1));
1433                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_P, args,
1434                                            scProductScreenshot);
1435                            }
1436                    }
1437            }
1438    
1439            protected void clearUniqueFindersCache(
1440                    SCProductScreenshot scProductScreenshot) {
1441                    SCProductScreenshotModelImpl scProductScreenshotModelImpl = (SCProductScreenshotModelImpl)scProductScreenshot;
1442    
1443                    Object[] args = new Object[] { scProductScreenshot.getThumbnailId() };
1444    
1445                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_THUMBNAILID, args);
1446                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_THUMBNAILID, args);
1447    
1448                    if ((scProductScreenshotModelImpl.getColumnBitmask() &
1449                                    FINDER_PATH_FETCH_BY_THUMBNAILID.getColumnBitmask()) != 0) {
1450                            args = new Object[] {
1451                                            scProductScreenshotModelImpl.getOriginalThumbnailId()
1452                                    };
1453    
1454                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_THUMBNAILID, args);
1455                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_THUMBNAILID, args);
1456                    }
1457    
1458                    args = new Object[] { scProductScreenshot.getFullImageId() };
1459    
1460                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FULLIMAGEID, args);
1461                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_FULLIMAGEID, args);
1462    
1463                    if ((scProductScreenshotModelImpl.getColumnBitmask() &
1464                                    FINDER_PATH_FETCH_BY_FULLIMAGEID.getColumnBitmask()) != 0) {
1465                            args = new Object[] {
1466                                            scProductScreenshotModelImpl.getOriginalFullImageId()
1467                                    };
1468    
1469                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FULLIMAGEID, args);
1470                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_FULLIMAGEID, args);
1471                    }
1472    
1473                    args = new Object[] {
1474                                    scProductScreenshot.getProductEntryId(),
1475                                    scProductScreenshot.getPriority()
1476                            };
1477    
1478                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_P, args);
1479                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_P, args);
1480    
1481                    if ((scProductScreenshotModelImpl.getColumnBitmask() &
1482                                    FINDER_PATH_FETCH_BY_P_P.getColumnBitmask()) != 0) {
1483                            args = new Object[] {
1484                                            scProductScreenshotModelImpl.getOriginalProductEntryId(),
1485                                            scProductScreenshotModelImpl.getOriginalPriority()
1486                                    };
1487    
1488                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_P, args);
1489                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_P, args);
1490                    }
1491            }
1492    
1493            /**
1494             * Creates a new s c product screenshot with the primary key. Does not add the s c product screenshot to the database.
1495             *
1496             * @param productScreenshotId the primary key for the new s c product screenshot
1497             * @return the new s c product screenshot
1498             */
1499            @Override
1500            public SCProductScreenshot create(long productScreenshotId) {
1501                    SCProductScreenshot scProductScreenshot = new SCProductScreenshotImpl();
1502    
1503                    scProductScreenshot.setNew(true);
1504                    scProductScreenshot.setPrimaryKey(productScreenshotId);
1505    
1506                    return scProductScreenshot;
1507            }
1508    
1509            /**
1510             * Removes the s c product screenshot with the primary key from the database. Also notifies the appropriate model listeners.
1511             *
1512             * @param productScreenshotId the primary key of the s c product screenshot
1513             * @return the s c product screenshot that was removed
1514             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductScreenshotException if a s c product screenshot with the primary key could not be found
1515             * @throws SystemException if a system exception occurred
1516             */
1517            @Override
1518            public SCProductScreenshot remove(long productScreenshotId)
1519                    throws NoSuchProductScreenshotException, SystemException {
1520                    return remove((Serializable)productScreenshotId);
1521            }
1522    
1523            /**
1524             * Removes the s c product screenshot with the primary key from the database. Also notifies the appropriate model listeners.
1525             *
1526             * @param primaryKey the primary key of the s c product screenshot
1527             * @return the s c product screenshot that was removed
1528             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductScreenshotException if a s c product screenshot with the primary key could not be found
1529             * @throws SystemException if a system exception occurred
1530             */
1531            @Override
1532            public SCProductScreenshot remove(Serializable primaryKey)
1533                    throws NoSuchProductScreenshotException, SystemException {
1534                    Session session = null;
1535    
1536                    try {
1537                            session = openSession();
1538    
1539                            SCProductScreenshot scProductScreenshot = (SCProductScreenshot)session.get(SCProductScreenshotImpl.class,
1540                                            primaryKey);
1541    
1542                            if (scProductScreenshot == null) {
1543                                    if (_log.isWarnEnabled()) {
1544                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
1545                                    }
1546    
1547                                    throw new NoSuchProductScreenshotException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1548                                            primaryKey);
1549                            }
1550    
1551                            return remove(scProductScreenshot);
1552                    }
1553                    catch (NoSuchProductScreenshotException nsee) {
1554                            throw nsee;
1555                    }
1556                    catch (Exception e) {
1557                            throw processException(e);
1558                    }
1559                    finally {
1560                            closeSession(session);
1561                    }
1562            }
1563    
1564            @Override
1565            protected SCProductScreenshot removeImpl(
1566                    SCProductScreenshot scProductScreenshot) throws SystemException {
1567                    scProductScreenshot = toUnwrappedModel(scProductScreenshot);
1568    
1569                    Session session = null;
1570    
1571                    try {
1572                            session = openSession();
1573    
1574                            if (!session.contains(scProductScreenshot)) {
1575                                    scProductScreenshot = (SCProductScreenshot)session.get(SCProductScreenshotImpl.class,
1576                                                    scProductScreenshot.getPrimaryKeyObj());
1577                            }
1578    
1579                            if (scProductScreenshot != null) {
1580                                    session.delete(scProductScreenshot);
1581                            }
1582                    }
1583                    catch (Exception e) {
1584                            throw processException(e);
1585                    }
1586                    finally {
1587                            closeSession(session);
1588                    }
1589    
1590                    if (scProductScreenshot != null) {
1591                            clearCache(scProductScreenshot);
1592                    }
1593    
1594                    return scProductScreenshot;
1595            }
1596    
1597            @Override
1598            public SCProductScreenshot updateImpl(
1599                    com.liferay.portlet.softwarecatalog.model.SCProductScreenshot scProductScreenshot)
1600                    throws SystemException {
1601                    scProductScreenshot = toUnwrappedModel(scProductScreenshot);
1602    
1603                    boolean isNew = scProductScreenshot.isNew();
1604    
1605                    SCProductScreenshotModelImpl scProductScreenshotModelImpl = (SCProductScreenshotModelImpl)scProductScreenshot;
1606    
1607                    Session session = null;
1608    
1609                    try {
1610                            session = openSession();
1611    
1612                            if (scProductScreenshot.isNew()) {
1613                                    session.save(scProductScreenshot);
1614    
1615                                    scProductScreenshot.setNew(false);
1616                            }
1617                            else {
1618                                    session.merge(scProductScreenshot);
1619                            }
1620                    }
1621                    catch (Exception e) {
1622                            throw processException(e);
1623                    }
1624                    finally {
1625                            closeSession(session);
1626                    }
1627    
1628                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1629    
1630                    if (isNew || !SCProductScreenshotModelImpl.COLUMN_BITMASK_ENABLED) {
1631                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1632                    }
1633    
1634                    else {
1635                            if ((scProductScreenshotModelImpl.getColumnBitmask() &
1636                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PRODUCTENTRYID.getColumnBitmask()) != 0) {
1637                                    Object[] args = new Object[] {
1638                                                    scProductScreenshotModelImpl.getOriginalProductEntryId()
1639                                            };
1640    
1641                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PRODUCTENTRYID,
1642                                            args);
1643                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PRODUCTENTRYID,
1644                                            args);
1645    
1646                                    args = new Object[] {
1647                                                    scProductScreenshotModelImpl.getProductEntryId()
1648                                            };
1649    
1650                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PRODUCTENTRYID,
1651                                            args);
1652                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PRODUCTENTRYID,
1653                                            args);
1654                            }
1655                    }
1656    
1657                    EntityCacheUtil.putResult(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
1658                            SCProductScreenshotImpl.class, scProductScreenshot.getPrimaryKey(),
1659                            scProductScreenshot);
1660    
1661                    clearUniqueFindersCache(scProductScreenshot);
1662                    cacheUniqueFindersCache(scProductScreenshot);
1663    
1664                    return scProductScreenshot;
1665            }
1666    
1667            protected SCProductScreenshot toUnwrappedModel(
1668                    SCProductScreenshot scProductScreenshot) {
1669                    if (scProductScreenshot instanceof SCProductScreenshotImpl) {
1670                            return scProductScreenshot;
1671                    }
1672    
1673                    SCProductScreenshotImpl scProductScreenshotImpl = new SCProductScreenshotImpl();
1674    
1675                    scProductScreenshotImpl.setNew(scProductScreenshot.isNew());
1676                    scProductScreenshotImpl.setPrimaryKey(scProductScreenshot.getPrimaryKey());
1677    
1678                    scProductScreenshotImpl.setProductScreenshotId(scProductScreenshot.getProductScreenshotId());
1679                    scProductScreenshotImpl.setCompanyId(scProductScreenshot.getCompanyId());
1680                    scProductScreenshotImpl.setGroupId(scProductScreenshot.getGroupId());
1681                    scProductScreenshotImpl.setProductEntryId(scProductScreenshot.getProductEntryId());
1682                    scProductScreenshotImpl.setThumbnailId(scProductScreenshot.getThumbnailId());
1683                    scProductScreenshotImpl.setFullImageId(scProductScreenshot.getFullImageId());
1684                    scProductScreenshotImpl.setPriority(scProductScreenshot.getPriority());
1685    
1686                    return scProductScreenshotImpl;
1687            }
1688    
1689            /**
1690             * Returns the s c product screenshot with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
1691             *
1692             * @param primaryKey the primary key of the s c product screenshot
1693             * @return the s c product screenshot
1694             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductScreenshotException if a s c product screenshot with the primary key could not be found
1695             * @throws SystemException if a system exception occurred
1696             */
1697            @Override
1698            public SCProductScreenshot findByPrimaryKey(Serializable primaryKey)
1699                    throws NoSuchProductScreenshotException, SystemException {
1700                    SCProductScreenshot scProductScreenshot = fetchByPrimaryKey(primaryKey);
1701    
1702                    if (scProductScreenshot == null) {
1703                            if (_log.isWarnEnabled()) {
1704                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
1705                            }
1706    
1707                            throw new NoSuchProductScreenshotException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1708                                    primaryKey);
1709                    }
1710    
1711                    return scProductScreenshot;
1712            }
1713    
1714            /**
1715             * 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.
1716             *
1717             * @param productScreenshotId the primary key of the s c product screenshot
1718             * @return the s c product screenshot
1719             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductScreenshotException if a s c product screenshot with the primary key could not be found
1720             * @throws SystemException if a system exception occurred
1721             */
1722            @Override
1723            public SCProductScreenshot findByPrimaryKey(long productScreenshotId)
1724                    throws NoSuchProductScreenshotException, SystemException {
1725                    return findByPrimaryKey((Serializable)productScreenshotId);
1726            }
1727    
1728            /**
1729             * Returns the s c product screenshot with the primary key or returns <code>null</code> if it could not be found.
1730             *
1731             * @param primaryKey the primary key of the s c product screenshot
1732             * @return the s c product screenshot, or <code>null</code> if a s c product screenshot with the primary key could not be found
1733             * @throws SystemException if a system exception occurred
1734             */
1735            @Override
1736            public SCProductScreenshot fetchByPrimaryKey(Serializable primaryKey)
1737                    throws SystemException {
1738                    SCProductScreenshot scProductScreenshot = (SCProductScreenshot)EntityCacheUtil.getResult(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
1739                                    SCProductScreenshotImpl.class, primaryKey);
1740    
1741                    if (scProductScreenshot == _nullSCProductScreenshot) {
1742                            return null;
1743                    }
1744    
1745                    if (scProductScreenshot == null) {
1746                            Session session = null;
1747    
1748                            try {
1749                                    session = openSession();
1750    
1751                                    scProductScreenshot = (SCProductScreenshot)session.get(SCProductScreenshotImpl.class,
1752                                                    primaryKey);
1753    
1754                                    if (scProductScreenshot != null) {
1755                                            cacheResult(scProductScreenshot);
1756                                    }
1757                                    else {
1758                                            EntityCacheUtil.putResult(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
1759                                                    SCProductScreenshotImpl.class, primaryKey,
1760                                                    _nullSCProductScreenshot);
1761                                    }
1762                            }
1763                            catch (Exception e) {
1764                                    EntityCacheUtil.removeResult(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
1765                                            SCProductScreenshotImpl.class, primaryKey);
1766    
1767                                    throw processException(e);
1768                            }
1769                            finally {
1770                                    closeSession(session);
1771                            }
1772                    }
1773    
1774                    return scProductScreenshot;
1775            }
1776    
1777            /**
1778             * Returns the s c product screenshot with the primary key or returns <code>null</code> if it could not be found.
1779             *
1780             * @param productScreenshotId the primary key of the s c product screenshot
1781             * @return the s c product screenshot, or <code>null</code> if a s c product screenshot with the primary key could not be found
1782             * @throws SystemException if a system exception occurred
1783             */
1784            @Override
1785            public SCProductScreenshot fetchByPrimaryKey(long productScreenshotId)
1786                    throws SystemException {
1787                    return fetchByPrimaryKey((Serializable)productScreenshotId);
1788            }
1789    
1790            /**
1791             * Returns all the s c product screenshots.
1792             *
1793             * @return the s c product screenshots
1794             * @throws SystemException if a system exception occurred
1795             */
1796            @Override
1797            public List<SCProductScreenshot> findAll() throws SystemException {
1798                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1799            }
1800    
1801            /**
1802             * Returns a range of all the s c product screenshots.
1803             *
1804             * <p>
1805             * 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.
1806             * </p>
1807             *
1808             * @param start the lower bound of the range of s c product screenshots
1809             * @param end the upper bound of the range of s c product screenshots (not inclusive)
1810             * @return the range of s c product screenshots
1811             * @throws SystemException if a system exception occurred
1812             */
1813            @Override
1814            public List<SCProductScreenshot> findAll(int start, int end)
1815                    throws SystemException {
1816                    return findAll(start, end, null);
1817            }
1818    
1819            /**
1820             * Returns an ordered range of all the s c product screenshots.
1821             *
1822             * <p>
1823             * 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.
1824             * </p>
1825             *
1826             * @param start the lower bound of the range of s c product screenshots
1827             * @param end the upper bound of the range of s c product screenshots (not inclusive)
1828             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1829             * @return the ordered range of s c product screenshots
1830             * @throws SystemException if a system exception occurred
1831             */
1832            @Override
1833            public List<SCProductScreenshot> findAll(int start, int end,
1834                    OrderByComparator orderByComparator) throws SystemException {
1835                    boolean pagination = true;
1836                    FinderPath finderPath = null;
1837                    Object[] finderArgs = null;
1838    
1839                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1840                                    (orderByComparator == null)) {
1841                            pagination = false;
1842                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1843                            finderArgs = FINDER_ARGS_EMPTY;
1844                    }
1845                    else {
1846                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1847                            finderArgs = new Object[] { start, end, orderByComparator };
1848                    }
1849    
1850                    List<SCProductScreenshot> list = (List<SCProductScreenshot>)FinderCacheUtil.getResult(finderPath,
1851                                    finderArgs, this);
1852    
1853                    if (list == null) {
1854                            StringBundler query = null;
1855                            String sql = null;
1856    
1857                            if (orderByComparator != null) {
1858                                    query = new StringBundler(2 +
1859                                                    (orderByComparator.getOrderByFields().length * 3));
1860    
1861                                    query.append(_SQL_SELECT_SCPRODUCTSCREENSHOT);
1862    
1863                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1864                                            orderByComparator);
1865    
1866                                    sql = query.toString();
1867                            }
1868                            else {
1869                                    sql = _SQL_SELECT_SCPRODUCTSCREENSHOT;
1870    
1871                                    if (pagination) {
1872                                            sql = sql.concat(SCProductScreenshotModelImpl.ORDER_BY_JPQL);
1873                                    }
1874                            }
1875    
1876                            Session session = null;
1877    
1878                            try {
1879                                    session = openSession();
1880    
1881                                    Query q = session.createQuery(sql);
1882    
1883                                    if (!pagination) {
1884                                            list = (List<SCProductScreenshot>)QueryUtil.list(q,
1885                                                            getDialect(), start, end, false);
1886    
1887                                            Collections.sort(list);
1888    
1889                                            list = new UnmodifiableList<SCProductScreenshot>(list);
1890                                    }
1891                                    else {
1892                                            list = (List<SCProductScreenshot>)QueryUtil.list(q,
1893                                                            getDialect(), start, end);
1894                                    }
1895    
1896                                    cacheResult(list);
1897    
1898                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1899                            }
1900                            catch (Exception e) {
1901                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1902    
1903                                    throw processException(e);
1904                            }
1905                            finally {
1906                                    closeSession(session);
1907                            }
1908                    }
1909    
1910                    return list;
1911            }
1912    
1913            /**
1914             * Removes all the s c product screenshots from the database.
1915             *
1916             * @throws SystemException if a system exception occurred
1917             */
1918            @Override
1919            public void removeAll() throws SystemException {
1920                    for (SCProductScreenshot scProductScreenshot : findAll()) {
1921                            remove(scProductScreenshot);
1922                    }
1923            }
1924    
1925            /**
1926             * Returns the number of s c product screenshots.
1927             *
1928             * @return the number of s c product screenshots
1929             * @throws SystemException if a system exception occurred
1930             */
1931            @Override
1932            public int countAll() throws SystemException {
1933                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1934                                    FINDER_ARGS_EMPTY, this);
1935    
1936                    if (count == null) {
1937                            Session session = null;
1938    
1939                            try {
1940                                    session = openSession();
1941    
1942                                    Query q = session.createQuery(_SQL_COUNT_SCPRODUCTSCREENSHOT);
1943    
1944                                    count = (Long)q.uniqueResult();
1945    
1946                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1947                                            FINDER_ARGS_EMPTY, count);
1948                            }
1949                            catch (Exception e) {
1950                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
1951                                            FINDER_ARGS_EMPTY);
1952    
1953                                    throw processException(e);
1954                            }
1955                            finally {
1956                                    closeSession(session);
1957                            }
1958                    }
1959    
1960                    return count.intValue();
1961            }
1962    
1963            /**
1964             * Initializes the s c product screenshot persistence.
1965             */
1966            public void afterPropertiesSet() {
1967                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1968                                            com.liferay.portal.util.PropsUtil.get(
1969                                                    "value.object.listener.com.liferay.portlet.softwarecatalog.model.SCProductScreenshot")));
1970    
1971                    if (listenerClassNames.length > 0) {
1972                            try {
1973                                    List<ModelListener<SCProductScreenshot>> listenersList = new ArrayList<ModelListener<SCProductScreenshot>>();
1974    
1975                                    for (String listenerClassName : listenerClassNames) {
1976                                            listenersList.add((ModelListener<SCProductScreenshot>)InstanceFactory.newInstance(
1977                                                            getClassLoader(), listenerClassName));
1978                                    }
1979    
1980                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1981                            }
1982                            catch (Exception e) {
1983                                    _log.error(e);
1984                            }
1985                    }
1986            }
1987    
1988            public void destroy() {
1989                    EntityCacheUtil.removeCache(SCProductScreenshotImpl.class.getName());
1990                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1991                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1992                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1993            }
1994    
1995            private static final String _SQL_SELECT_SCPRODUCTSCREENSHOT = "SELECT scProductScreenshot FROM SCProductScreenshot scProductScreenshot";
1996            private static final String _SQL_SELECT_SCPRODUCTSCREENSHOT_WHERE = "SELECT scProductScreenshot FROM SCProductScreenshot scProductScreenshot WHERE ";
1997            private static final String _SQL_COUNT_SCPRODUCTSCREENSHOT = "SELECT COUNT(scProductScreenshot) FROM SCProductScreenshot scProductScreenshot";
1998            private static final String _SQL_COUNT_SCPRODUCTSCREENSHOT_WHERE = "SELECT COUNT(scProductScreenshot) FROM SCProductScreenshot scProductScreenshot WHERE ";
1999            private static final String _ORDER_BY_ENTITY_ALIAS = "scProductScreenshot.";
2000            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SCProductScreenshot exists with the primary key ";
2001            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SCProductScreenshot exists with the key {";
2002            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2003            private static Log _log = LogFactoryUtil.getLog(SCProductScreenshotPersistenceImpl.class);
2004            private static SCProductScreenshot _nullSCProductScreenshot = new SCProductScreenshotImpl() {
2005                            @Override
2006                            public Object clone() {
2007                                    return this;
2008                            }
2009    
2010                            @Override
2011                            public CacheModel<SCProductScreenshot> toCacheModel() {
2012                                    return _nullSCProductScreenshotCacheModel;
2013                            }
2014                    };
2015    
2016            private static CacheModel<SCProductScreenshot> _nullSCProductScreenshotCacheModel =
2017                    new CacheModel<SCProductScreenshot>() {
2018                            @Override
2019                            public SCProductScreenshot toEntityModel() {
2020                                    return _nullSCProductScreenshot;
2021                            }
2022                    };
2023    }