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