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