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