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