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