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