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