1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portlet.softwarecatalog.service.persistence;
16  
17  import com.liferay.portal.NoSuchModelException;
18  import com.liferay.portal.SystemException;
19  import com.liferay.portal.kernel.annotation.BeanReference;
20  import com.liferay.portal.kernel.cache.CacheRegistry;
21  import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
22  import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
23  import com.liferay.portal.kernel.dao.orm.FinderPath;
24  import com.liferay.portal.kernel.dao.orm.Query;
25  import com.liferay.portal.kernel.dao.orm.QueryPos;
26  import com.liferay.portal.kernel.dao.orm.QueryUtil;
27  import com.liferay.portal.kernel.dao.orm.Session;
28  import com.liferay.portal.kernel.log.Log;
29  import com.liferay.portal.kernel.log.LogFactoryUtil;
30  import com.liferay.portal.kernel.util.GetterUtil;
31  import com.liferay.portal.kernel.util.InstanceFactory;
32  import com.liferay.portal.kernel.util.OrderByComparator;
33  import com.liferay.portal.kernel.util.StringBundler;
34  import com.liferay.portal.kernel.util.StringPool;
35  import com.liferay.portal.kernel.util.StringUtil;
36  import com.liferay.portal.model.ModelListener;
37  import com.liferay.portal.service.persistence.BatchSessionUtil;
38  import com.liferay.portal.service.persistence.ImagePersistence;
39  import com.liferay.portal.service.persistence.ResourcePersistence;
40  import com.liferay.portal.service.persistence.UserPersistence;
41  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
42  
43  import com.liferay.portlet.softwarecatalog.NoSuchProductScreenshotException;
44  import com.liferay.portlet.softwarecatalog.model.SCProductScreenshot;
45  import com.liferay.portlet.softwarecatalog.model.impl.SCProductScreenshotImpl;
46  import com.liferay.portlet.softwarecatalog.model.impl.SCProductScreenshotModelImpl;
47  
48  import java.io.Serializable;
49  
50  import java.util.ArrayList;
51  import java.util.Collections;
52  import java.util.List;
53  
54  /**
55   * <a href="SCProductScreenshotPersistenceImpl.java.html"><b><i>View Source</i></b></a>
56   *
57   * <p>
58   * ServiceBuilder generated this class. Modifications in this class will be
59   * overwritten the next time is generated.
60   * </p>
61   *
62   * @author    Brian Wing Shun Chan
63   * @see       SCProductScreenshotPersistence
64   * @see       SCProductScreenshotUtil
65   * @generated
66   */
67  public class SCProductScreenshotPersistenceImpl extends BasePersistenceImpl<SCProductScreenshot>
68      implements SCProductScreenshotPersistence {
69      public static final String FINDER_CLASS_NAME_ENTITY = SCProductScreenshotImpl.class.getName();
70      public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
71          ".List";
72      public static final FinderPath FINDER_PATH_FIND_BY_PRODUCTENTRYID = new FinderPath(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
73              SCProductScreenshotModelImpl.FINDER_CACHE_ENABLED,
74              FINDER_CLASS_NAME_LIST, "findByProductEntryId",
75              new String[] {
76                  Long.class.getName(),
77                  
78              "java.lang.Integer", "java.lang.Integer",
79                  "com.liferay.portal.kernel.util.OrderByComparator"
80              });
81      public static final FinderPath FINDER_PATH_COUNT_BY_PRODUCTENTRYID = new FinderPath(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
82              SCProductScreenshotModelImpl.FINDER_CACHE_ENABLED,
83              FINDER_CLASS_NAME_LIST, "countByProductEntryId",
84              new String[] { Long.class.getName() });
85      public static final FinderPath FINDER_PATH_FETCH_BY_THUMBNAILID = new FinderPath(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
86              SCProductScreenshotModelImpl.FINDER_CACHE_ENABLED,
87              FINDER_CLASS_NAME_ENTITY, "fetchByThumbnailId",
88              new String[] { Long.class.getName() });
89      public static final FinderPath FINDER_PATH_COUNT_BY_THUMBNAILID = new FinderPath(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
90              SCProductScreenshotModelImpl.FINDER_CACHE_ENABLED,
91              FINDER_CLASS_NAME_LIST, "countByThumbnailId",
92              new String[] { Long.class.getName() });
93      public static final FinderPath FINDER_PATH_FETCH_BY_FULLIMAGEID = new FinderPath(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
94              SCProductScreenshotModelImpl.FINDER_CACHE_ENABLED,
95              FINDER_CLASS_NAME_ENTITY, "fetchByFullImageId",
96              new String[] { Long.class.getName() });
97      public static final FinderPath FINDER_PATH_COUNT_BY_FULLIMAGEID = new FinderPath(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
98              SCProductScreenshotModelImpl.FINDER_CACHE_ENABLED,
99              FINDER_CLASS_NAME_LIST, "countByFullImageId",
100             new String[] { Long.class.getName() });
101     public static final FinderPath FINDER_PATH_FETCH_BY_P_P = new FinderPath(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
102             SCProductScreenshotModelImpl.FINDER_CACHE_ENABLED,
103             FINDER_CLASS_NAME_ENTITY, "fetchByP_P",
104             new String[] { Long.class.getName(), Integer.class.getName() });
105     public static final FinderPath FINDER_PATH_COUNT_BY_P_P = new FinderPath(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
106             SCProductScreenshotModelImpl.FINDER_CACHE_ENABLED,
107             FINDER_CLASS_NAME_LIST, "countByP_P",
108             new String[] { Long.class.getName(), Integer.class.getName() });
109     public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
110             SCProductScreenshotModelImpl.FINDER_CACHE_ENABLED,
111             FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
112     public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
113             SCProductScreenshotModelImpl.FINDER_CACHE_ENABLED,
114             FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
115 
116     public void cacheResult(SCProductScreenshot scProductScreenshot) {
117         EntityCacheUtil.putResult(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
118             SCProductScreenshotImpl.class, scProductScreenshot.getPrimaryKey(),
119             scProductScreenshot);
120 
121         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_THUMBNAILID,
122             new Object[] { new Long(scProductScreenshot.getThumbnailId()) },
123             scProductScreenshot);
124 
125         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_FULLIMAGEID,
126             new Object[] { new Long(scProductScreenshot.getFullImageId()) },
127             scProductScreenshot);
128 
129         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_P,
130             new Object[] {
131                 new Long(scProductScreenshot.getProductEntryId()),
132                 new Integer(scProductScreenshot.getPriority())
133             }, scProductScreenshot);
134     }
135 
136     public void cacheResult(List<SCProductScreenshot> scProductScreenshots) {
137         for (SCProductScreenshot scProductScreenshot : scProductScreenshots) {
138             if (EntityCacheUtil.getResult(
139                         SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
140                         SCProductScreenshotImpl.class,
141                         scProductScreenshot.getPrimaryKey(), this) == null) {
142                 cacheResult(scProductScreenshot);
143             }
144         }
145     }
146 
147     public void clearCache() {
148         CacheRegistry.clear(SCProductScreenshotImpl.class.getName());
149         EntityCacheUtil.clearCache(SCProductScreenshotImpl.class.getName());
150         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
151         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
152     }
153 
154     public void clearCache(SCProductScreenshot scProductScreenshot) {
155         EntityCacheUtil.removeResult(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
156             SCProductScreenshotImpl.class, scProductScreenshot.getPrimaryKey());
157 
158         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_THUMBNAILID,
159             new Object[] { new Long(scProductScreenshot.getThumbnailId()) });
160 
161         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_FULLIMAGEID,
162             new Object[] { new Long(scProductScreenshot.getFullImageId()) });
163 
164         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_P,
165             new Object[] {
166                 new Long(scProductScreenshot.getProductEntryId()),
167                 new Integer(scProductScreenshot.getPriority())
168             });
169     }
170 
171     public SCProductScreenshot create(long productScreenshotId) {
172         SCProductScreenshot scProductScreenshot = new SCProductScreenshotImpl();
173 
174         scProductScreenshot.setNew(true);
175         scProductScreenshot.setPrimaryKey(productScreenshotId);
176 
177         return scProductScreenshot;
178     }
179 
180     public SCProductScreenshot remove(Serializable primaryKey)
181         throws NoSuchModelException, SystemException {
182         return remove(((Long)primaryKey).longValue());
183     }
184 
185     public SCProductScreenshot remove(long productScreenshotId)
186         throws NoSuchProductScreenshotException, SystemException {
187         Session session = null;
188 
189         try {
190             session = openSession();
191 
192             SCProductScreenshot scProductScreenshot = (SCProductScreenshot)session.get(SCProductScreenshotImpl.class,
193                     new Long(productScreenshotId));
194 
195             if (scProductScreenshot == null) {
196                 if (_log.isWarnEnabled()) {
197                     _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
198                         productScreenshotId);
199                 }
200 
201                 throw new NoSuchProductScreenshotException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
202                     productScreenshotId);
203             }
204 
205             return remove(scProductScreenshot);
206         }
207         catch (NoSuchProductScreenshotException nsee) {
208             throw nsee;
209         }
210         catch (Exception e) {
211             throw processException(e);
212         }
213         finally {
214             closeSession(session);
215         }
216     }
217 
218     protected SCProductScreenshot removeImpl(
219         SCProductScreenshot scProductScreenshot) throws SystemException {
220         scProductScreenshot = toUnwrappedModel(scProductScreenshot);
221 
222         Session session = null;
223 
224         try {
225             session = openSession();
226 
227             BatchSessionUtil.delete(session, scProductScreenshot);
228         }
229         catch (Exception e) {
230             throw processException(e);
231         }
232         finally {
233             closeSession(session);
234         }
235 
236         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
237 
238         SCProductScreenshotModelImpl scProductScreenshotModelImpl = (SCProductScreenshotModelImpl)scProductScreenshot;
239 
240         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_THUMBNAILID,
241             new Object[] {
242                 new Long(scProductScreenshotModelImpl.getOriginalThumbnailId())
243             });
244 
245         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_FULLIMAGEID,
246             new Object[] {
247                 new Long(scProductScreenshotModelImpl.getOriginalFullImageId())
248             });
249 
250         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_P,
251             new Object[] {
252                 new Long(scProductScreenshotModelImpl.getOriginalProductEntryId()),
253                 new Integer(scProductScreenshotModelImpl.getOriginalPriority())
254             });
255 
256         EntityCacheUtil.removeResult(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
257             SCProductScreenshotImpl.class, scProductScreenshot.getPrimaryKey());
258 
259         return scProductScreenshot;
260     }
261 
262     /**
263      * @deprecated Use {@link BasePersistence#update(com.liferay.portal.model.BaseModel, boolean)}.
264      */
265     public SCProductScreenshot update(SCProductScreenshot scProductScreenshot)
266         throws SystemException {
267         if (_log.isWarnEnabled()) {
268             _log.warn(
269                 "Using the deprecated update(SCProductScreenshot scProductScreenshot) method. Use update(SCProductScreenshot scProductScreenshot, boolean merge) instead.");
270         }
271 
272         return update(scProductScreenshot, false);
273     }
274 
275     public SCProductScreenshot updateImpl(
276         com.liferay.portlet.softwarecatalog.model.SCProductScreenshot scProductScreenshot,
277         boolean merge) throws SystemException {
278         scProductScreenshot = toUnwrappedModel(scProductScreenshot);
279 
280         boolean isNew = scProductScreenshot.isNew();
281 
282         SCProductScreenshotModelImpl scProductScreenshotModelImpl = (SCProductScreenshotModelImpl)scProductScreenshot;
283 
284         Session session = null;
285 
286         try {
287             session = openSession();
288 
289             BatchSessionUtil.update(session, scProductScreenshot, merge);
290 
291             scProductScreenshot.setNew(false);
292         }
293         catch (Exception e) {
294             throw processException(e);
295         }
296         finally {
297             closeSession(session);
298         }
299 
300         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
301 
302         EntityCacheUtil.putResult(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
303             SCProductScreenshotImpl.class, scProductScreenshot.getPrimaryKey(),
304             scProductScreenshot);
305 
306         if (!isNew &&
307                 (scProductScreenshot.getThumbnailId() != scProductScreenshotModelImpl.getOriginalThumbnailId())) {
308             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_THUMBNAILID,
309                 new Object[] {
310                     new Long(scProductScreenshotModelImpl.getOriginalThumbnailId())
311                 });
312         }
313 
314         if (isNew ||
315                 (scProductScreenshot.getThumbnailId() != scProductScreenshotModelImpl.getOriginalThumbnailId())) {
316             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_THUMBNAILID,
317                 new Object[] { new Long(scProductScreenshot.getThumbnailId()) },
318                 scProductScreenshot);
319         }
320 
321         if (!isNew &&
322                 (scProductScreenshot.getFullImageId() != scProductScreenshotModelImpl.getOriginalFullImageId())) {
323             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_FULLIMAGEID,
324                 new Object[] {
325                     new Long(scProductScreenshotModelImpl.getOriginalFullImageId())
326                 });
327         }
328 
329         if (isNew ||
330                 (scProductScreenshot.getFullImageId() != scProductScreenshotModelImpl.getOriginalFullImageId())) {
331             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_FULLIMAGEID,
332                 new Object[] { new Long(scProductScreenshot.getFullImageId()) },
333                 scProductScreenshot);
334         }
335 
336         if (!isNew &&
337                 ((scProductScreenshot.getProductEntryId() != scProductScreenshotModelImpl.getOriginalProductEntryId()) ||
338                 (scProductScreenshot.getPriority() != scProductScreenshotModelImpl.getOriginalPriority()))) {
339             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_P,
340                 new Object[] {
341                     new Long(scProductScreenshotModelImpl.getOriginalProductEntryId()),
342                     new Integer(scProductScreenshotModelImpl.getOriginalPriority())
343                 });
344         }
345 
346         if (isNew ||
347                 ((scProductScreenshot.getProductEntryId() != scProductScreenshotModelImpl.getOriginalProductEntryId()) ||
348                 (scProductScreenshot.getPriority() != scProductScreenshotModelImpl.getOriginalPriority()))) {
349             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_P,
350                 new Object[] {
351                     new Long(scProductScreenshot.getProductEntryId()),
352                     new Integer(scProductScreenshot.getPriority())
353                 }, scProductScreenshot);
354         }
355 
356         return scProductScreenshot;
357     }
358 
359     protected SCProductScreenshot toUnwrappedModel(
360         SCProductScreenshot scProductScreenshot) {
361         if (scProductScreenshot instanceof SCProductScreenshotImpl) {
362             return scProductScreenshot;
363         }
364 
365         SCProductScreenshotImpl scProductScreenshotImpl = new SCProductScreenshotImpl();
366 
367         scProductScreenshotImpl.setNew(scProductScreenshot.isNew());
368         scProductScreenshotImpl.setPrimaryKey(scProductScreenshot.getPrimaryKey());
369 
370         scProductScreenshotImpl.setProductScreenshotId(scProductScreenshot.getProductScreenshotId());
371         scProductScreenshotImpl.setCompanyId(scProductScreenshot.getCompanyId());
372         scProductScreenshotImpl.setGroupId(scProductScreenshot.getGroupId());
373         scProductScreenshotImpl.setProductEntryId(scProductScreenshot.getProductEntryId());
374         scProductScreenshotImpl.setThumbnailId(scProductScreenshot.getThumbnailId());
375         scProductScreenshotImpl.setFullImageId(scProductScreenshot.getFullImageId());
376         scProductScreenshotImpl.setPriority(scProductScreenshot.getPriority());
377 
378         return scProductScreenshotImpl;
379     }
380 
381     public SCProductScreenshot findByPrimaryKey(Serializable primaryKey)
382         throws NoSuchModelException, SystemException {
383         return findByPrimaryKey(((Long)primaryKey).longValue());
384     }
385 
386     public SCProductScreenshot findByPrimaryKey(long productScreenshotId)
387         throws NoSuchProductScreenshotException, SystemException {
388         SCProductScreenshot scProductScreenshot = fetchByPrimaryKey(productScreenshotId);
389 
390         if (scProductScreenshot == null) {
391             if (_log.isWarnEnabled()) {
392                 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
393                     productScreenshotId);
394             }
395 
396             throw new NoSuchProductScreenshotException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
397                 productScreenshotId);
398         }
399 
400         return scProductScreenshot;
401     }
402 
403     public SCProductScreenshot fetchByPrimaryKey(Serializable primaryKey)
404         throws SystemException {
405         return fetchByPrimaryKey(((Long)primaryKey).longValue());
406     }
407 
408     public SCProductScreenshot fetchByPrimaryKey(long productScreenshotId)
409         throws SystemException {
410         SCProductScreenshot scProductScreenshot = (SCProductScreenshot)EntityCacheUtil.getResult(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
411                 SCProductScreenshotImpl.class, productScreenshotId, this);
412 
413         if (scProductScreenshot == null) {
414             Session session = null;
415 
416             try {
417                 session = openSession();
418 
419                 scProductScreenshot = (SCProductScreenshot)session.get(SCProductScreenshotImpl.class,
420                         new Long(productScreenshotId));
421             }
422             catch (Exception e) {
423                 throw processException(e);
424             }
425             finally {
426                 if (scProductScreenshot != null) {
427                     cacheResult(scProductScreenshot);
428                 }
429 
430                 closeSession(session);
431             }
432         }
433 
434         return scProductScreenshot;
435     }
436 
437     public List<SCProductScreenshot> findByProductEntryId(long productEntryId)
438         throws SystemException {
439         return findByProductEntryId(productEntryId, QueryUtil.ALL_POS,
440             QueryUtil.ALL_POS, null);
441     }
442 
443     public List<SCProductScreenshot> findByProductEntryId(long productEntryId,
444         int start, int end) throws SystemException {
445         return findByProductEntryId(productEntryId, start, end, null);
446     }
447 
448     public List<SCProductScreenshot> findByProductEntryId(long productEntryId,
449         int start, int end, OrderByComparator orderByComparator)
450         throws SystemException {
451         Object[] finderArgs = new Object[] {
452                 productEntryId,
453                 
454                 String.valueOf(start), String.valueOf(end),
455                 String.valueOf(orderByComparator)
456             };
457 
458         List<SCProductScreenshot> list = (List<SCProductScreenshot>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_PRODUCTENTRYID,
459                 finderArgs, this);
460 
461         if (list == null) {
462             StringBundler query = null;
463 
464             if (orderByComparator != null) {
465                 query = new StringBundler(3 +
466                         (orderByComparator.getOrderByFields().length * 3));
467             }
468             else {
469                 query = new StringBundler(3);
470             }
471 
472             query.append(_SQL_SELECT_SCPRODUCTSCREENSHOT_WHERE);
473 
474             query.append(_FINDER_COLUMN_PRODUCTENTRYID_PRODUCTENTRYID_2);
475 
476             if (orderByComparator != null) {
477                 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
478                     orderByComparator);
479             }
480 
481             else {
482                 query.append(SCProductScreenshotModelImpl.ORDER_BY_JPQL);
483             }
484 
485             String sql = query.toString();
486 
487             Session session = null;
488 
489             try {
490                 session = openSession();
491 
492                 Query q = session.createQuery(sql);
493 
494                 QueryPos qPos = QueryPos.getInstance(q);
495 
496                 qPos.add(productEntryId);
497 
498                 list = (List<SCProductScreenshot>)QueryUtil.list(q,
499                         getDialect(), start, end);
500             }
501             catch (Exception e) {
502                 throw processException(e);
503             }
504             finally {
505                 if (list == null) {
506                     list = new ArrayList<SCProductScreenshot>();
507                 }
508 
509                 cacheResult(list);
510 
511                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_PRODUCTENTRYID,
512                     finderArgs, list);
513 
514                 closeSession(session);
515             }
516         }
517 
518         return list;
519     }
520 
521     public SCProductScreenshot findByProductEntryId_First(long productEntryId,
522         OrderByComparator orderByComparator)
523         throws NoSuchProductScreenshotException, SystemException {
524         List<SCProductScreenshot> list = findByProductEntryId(productEntryId,
525                 0, 1, orderByComparator);
526 
527         if (list.isEmpty()) {
528             StringBundler msg = new StringBundler(4);
529 
530             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
531 
532             msg.append("productEntryId=");
533             msg.append(productEntryId);
534 
535             msg.append(StringPool.CLOSE_CURLY_BRACE);
536 
537             throw new NoSuchProductScreenshotException(msg.toString());
538         }
539         else {
540             return list.get(0);
541         }
542     }
543 
544     public SCProductScreenshot findByProductEntryId_Last(long productEntryId,
545         OrderByComparator orderByComparator)
546         throws NoSuchProductScreenshotException, SystemException {
547         int count = countByProductEntryId(productEntryId);
548 
549         List<SCProductScreenshot> list = findByProductEntryId(productEntryId,
550                 count - 1, count, orderByComparator);
551 
552         if (list.isEmpty()) {
553             StringBundler msg = new StringBundler(4);
554 
555             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
556 
557             msg.append("productEntryId=");
558             msg.append(productEntryId);
559 
560             msg.append(StringPool.CLOSE_CURLY_BRACE);
561 
562             throw new NoSuchProductScreenshotException(msg.toString());
563         }
564         else {
565             return list.get(0);
566         }
567     }
568 
569     public SCProductScreenshot[] findByProductEntryId_PrevAndNext(
570         long productScreenshotId, long productEntryId,
571         OrderByComparator orderByComparator)
572         throws NoSuchProductScreenshotException, SystemException {
573         SCProductScreenshot scProductScreenshot = findByPrimaryKey(productScreenshotId);
574 
575         Session session = null;
576 
577         try {
578             session = openSession();
579 
580             SCProductScreenshot[] array = new SCProductScreenshotImpl[3];
581 
582             array[0] = getByProductEntryId_PrevAndNext(session,
583                     scProductScreenshot, productEntryId, orderByComparator, true);
584 
585             array[1] = scProductScreenshot;
586 
587             array[2] = getByProductEntryId_PrevAndNext(session,
588                     scProductScreenshot, productEntryId, orderByComparator,
589                     false);
590 
591             return array;
592         }
593         catch (Exception e) {
594             throw processException(e);
595         }
596         finally {
597             closeSession(session);
598         }
599     }
600 
601     protected SCProductScreenshot getByProductEntryId_PrevAndNext(
602         Session session, SCProductScreenshot scProductScreenshot,
603         long productEntryId, OrderByComparator orderByComparator,
604         boolean previous) {
605         StringBundler query = null;
606 
607         if (orderByComparator != null) {
608             query = new StringBundler(6 +
609                     (orderByComparator.getOrderByFields().length * 6));
610         }
611         else {
612             query = new StringBundler(3);
613         }
614 
615         query.append(_SQL_SELECT_SCPRODUCTSCREENSHOT_WHERE);
616 
617         query.append(_FINDER_COLUMN_PRODUCTENTRYID_PRODUCTENTRYID_2);
618 
619         if (orderByComparator != null) {
620             String[] orderByFields = orderByComparator.getOrderByFields();
621 
622             if (orderByFields.length > 0) {
623                 query.append(WHERE_AND);
624             }
625 
626             for (int i = 0; i < orderByFields.length; i++) {
627                 query.append(_ORDER_BY_ENTITY_ALIAS);
628                 query.append(orderByFields[i]);
629 
630                 if ((i + 1) < orderByFields.length) {
631                     if (orderByComparator.isAscending() ^ previous) {
632                         query.append(WHERE_GREATER_THAN_HAS_NEXT);
633                     }
634                     else {
635                         query.append(WHERE_LESSER_THAN_HAS_NEXT);
636                     }
637                 }
638                 else {
639                     if (orderByComparator.isAscending() ^ previous) {
640                         query.append(WHERE_GREATER_THAN);
641                     }
642                     else {
643                         query.append(WHERE_LESSER_THAN);
644                     }
645                 }
646             }
647 
648             query.append(ORDER_BY_CLAUSE);
649 
650             for (int i = 0; i < orderByFields.length; i++) {
651                 query.append(_ORDER_BY_ENTITY_ALIAS);
652                 query.append(orderByFields[i]);
653 
654                 if ((i + 1) < orderByFields.length) {
655                     if (orderByComparator.isAscending() ^ previous) {
656                         query.append(ORDER_BY_ASC_HAS_NEXT);
657                     }
658                     else {
659                         query.append(ORDER_BY_DESC_HAS_NEXT);
660                     }
661                 }
662                 else {
663                     if (orderByComparator.isAscending() ^ previous) {
664                         query.append(ORDER_BY_ASC);
665                     }
666                     else {
667                         query.append(ORDER_BY_DESC);
668                     }
669                 }
670             }
671         }
672 
673         else {
674             query.append(SCProductScreenshotModelImpl.ORDER_BY_JPQL);
675         }
676 
677         String sql = query.toString();
678 
679         Query q = session.createQuery(sql);
680 
681         q.setFirstResult(0);
682         q.setMaxResults(2);
683 
684         QueryPos qPos = QueryPos.getInstance(q);
685 
686         qPos.add(productEntryId);
687 
688         if (orderByComparator != null) {
689             Object[] values = orderByComparator.getOrderByValues(scProductScreenshot);
690 
691             for (Object value : values) {
692                 qPos.add(value);
693             }
694         }
695 
696         List<SCProductScreenshot> list = q.list();
697 
698         if (list.size() == 2) {
699             return list.get(1);
700         }
701         else {
702             return null;
703         }
704     }
705 
706     public SCProductScreenshot findByThumbnailId(long thumbnailId)
707         throws NoSuchProductScreenshotException, SystemException {
708         SCProductScreenshot scProductScreenshot = fetchByThumbnailId(thumbnailId);
709 
710         if (scProductScreenshot == null) {
711             StringBundler msg = new StringBundler(4);
712 
713             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
714 
715             msg.append("thumbnailId=");
716             msg.append(thumbnailId);
717 
718             msg.append(StringPool.CLOSE_CURLY_BRACE);
719 
720             if (_log.isWarnEnabled()) {
721                 _log.warn(msg.toString());
722             }
723 
724             throw new NoSuchProductScreenshotException(msg.toString());
725         }
726 
727         return scProductScreenshot;
728     }
729 
730     public SCProductScreenshot fetchByThumbnailId(long thumbnailId)
731         throws SystemException {
732         return fetchByThumbnailId(thumbnailId, true);
733     }
734 
735     public SCProductScreenshot fetchByThumbnailId(long thumbnailId,
736         boolean retrieveFromCache) throws SystemException {
737         Object[] finderArgs = new Object[] { thumbnailId };
738 
739         Object result = null;
740 
741         if (retrieveFromCache) {
742             result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_THUMBNAILID,
743                     finderArgs, this);
744         }
745 
746         if (result == null) {
747             StringBundler query = new StringBundler(3);
748 
749             query.append(_SQL_SELECT_SCPRODUCTSCREENSHOT_WHERE);
750 
751             query.append(_FINDER_COLUMN_THUMBNAILID_THUMBNAILID_2);
752 
753             query.append(SCProductScreenshotModelImpl.ORDER_BY_JPQL);
754 
755             String sql = query.toString();
756 
757             Session session = null;
758 
759             try {
760                 session = openSession();
761 
762                 Query q = session.createQuery(sql);
763 
764                 QueryPos qPos = QueryPos.getInstance(q);
765 
766                 qPos.add(thumbnailId);
767 
768                 List<SCProductScreenshot> list = q.list();
769 
770                 result = list;
771 
772                 SCProductScreenshot scProductScreenshot = null;
773 
774                 if (list.isEmpty()) {
775                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_THUMBNAILID,
776                         finderArgs, list);
777                 }
778                 else {
779                     scProductScreenshot = list.get(0);
780 
781                     cacheResult(scProductScreenshot);
782 
783                     if ((scProductScreenshot.getThumbnailId() != thumbnailId)) {
784                         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_THUMBNAILID,
785                             finderArgs, scProductScreenshot);
786                     }
787                 }
788 
789                 return scProductScreenshot;
790             }
791             catch (Exception e) {
792                 throw processException(e);
793             }
794             finally {
795                 if (result == null) {
796                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_THUMBNAILID,
797                         finderArgs, new ArrayList<SCProductScreenshot>());
798                 }
799 
800                 closeSession(session);
801             }
802         }
803         else {
804             if (result instanceof List<?>) {
805                 return null;
806             }
807             else {
808                 return (SCProductScreenshot)result;
809             }
810         }
811     }
812 
813     public SCProductScreenshot findByFullImageId(long fullImageId)
814         throws NoSuchProductScreenshotException, SystemException {
815         SCProductScreenshot scProductScreenshot = fetchByFullImageId(fullImageId);
816 
817         if (scProductScreenshot == null) {
818             StringBundler msg = new StringBundler(4);
819 
820             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
821 
822             msg.append("fullImageId=");
823             msg.append(fullImageId);
824 
825             msg.append(StringPool.CLOSE_CURLY_BRACE);
826 
827             if (_log.isWarnEnabled()) {
828                 _log.warn(msg.toString());
829             }
830 
831             throw new NoSuchProductScreenshotException(msg.toString());
832         }
833 
834         return scProductScreenshot;
835     }
836 
837     public SCProductScreenshot fetchByFullImageId(long fullImageId)
838         throws SystemException {
839         return fetchByFullImageId(fullImageId, true);
840     }
841 
842     public SCProductScreenshot fetchByFullImageId(long fullImageId,
843         boolean retrieveFromCache) throws SystemException {
844         Object[] finderArgs = new Object[] { fullImageId };
845 
846         Object result = null;
847 
848         if (retrieveFromCache) {
849             result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_FULLIMAGEID,
850                     finderArgs, this);
851         }
852 
853         if (result == null) {
854             StringBundler query = new StringBundler(3);
855 
856             query.append(_SQL_SELECT_SCPRODUCTSCREENSHOT_WHERE);
857 
858             query.append(_FINDER_COLUMN_FULLIMAGEID_FULLIMAGEID_2);
859 
860             query.append(SCProductScreenshotModelImpl.ORDER_BY_JPQL);
861 
862             String sql = query.toString();
863 
864             Session session = null;
865 
866             try {
867                 session = openSession();
868 
869                 Query q = session.createQuery(sql);
870 
871                 QueryPos qPos = QueryPos.getInstance(q);
872 
873                 qPos.add(fullImageId);
874 
875                 List<SCProductScreenshot> list = q.list();
876 
877                 result = list;
878 
879                 SCProductScreenshot scProductScreenshot = null;
880 
881                 if (list.isEmpty()) {
882                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_FULLIMAGEID,
883                         finderArgs, list);
884                 }
885                 else {
886                     scProductScreenshot = list.get(0);
887 
888                     cacheResult(scProductScreenshot);
889 
890                     if ((scProductScreenshot.getFullImageId() != fullImageId)) {
891                         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_FULLIMAGEID,
892                             finderArgs, scProductScreenshot);
893                     }
894                 }
895 
896                 return scProductScreenshot;
897             }
898             catch (Exception e) {
899                 throw processException(e);
900             }
901             finally {
902                 if (result == null) {
903                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_FULLIMAGEID,
904                         finderArgs, new ArrayList<SCProductScreenshot>());
905                 }
906 
907                 closeSession(session);
908             }
909         }
910         else {
911             if (result instanceof List<?>) {
912                 return null;
913             }
914             else {
915                 return (SCProductScreenshot)result;
916             }
917         }
918     }
919 
920     public SCProductScreenshot findByP_P(long productEntryId, int priority)
921         throws NoSuchProductScreenshotException, SystemException {
922         SCProductScreenshot scProductScreenshot = fetchByP_P(productEntryId,
923                 priority);
924 
925         if (scProductScreenshot == null) {
926             StringBundler msg = new StringBundler(6);
927 
928             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
929 
930             msg.append("productEntryId=");
931             msg.append(productEntryId);
932 
933             msg.append(", priority=");
934             msg.append(priority);
935 
936             msg.append(StringPool.CLOSE_CURLY_BRACE);
937 
938             if (_log.isWarnEnabled()) {
939                 _log.warn(msg.toString());
940             }
941 
942             throw new NoSuchProductScreenshotException(msg.toString());
943         }
944 
945         return scProductScreenshot;
946     }
947 
948     public SCProductScreenshot fetchByP_P(long productEntryId, int priority)
949         throws SystemException {
950         return fetchByP_P(productEntryId, priority, true);
951     }
952 
953     public SCProductScreenshot fetchByP_P(long productEntryId, int priority,
954         boolean retrieveFromCache) throws SystemException {
955         Object[] finderArgs = new Object[] { productEntryId, priority };
956 
957         Object result = null;
958 
959         if (retrieveFromCache) {
960             result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_P_P,
961                     finderArgs, this);
962         }
963 
964         if (result == null) {
965             StringBundler query = new StringBundler(4);
966 
967             query.append(_SQL_SELECT_SCPRODUCTSCREENSHOT_WHERE);
968 
969             query.append(_FINDER_COLUMN_P_P_PRODUCTENTRYID_2);
970 
971             query.append(_FINDER_COLUMN_P_P_PRIORITY_2);
972 
973             query.append(SCProductScreenshotModelImpl.ORDER_BY_JPQL);
974 
975             String sql = query.toString();
976 
977             Session session = null;
978 
979             try {
980                 session = openSession();
981 
982                 Query q = session.createQuery(sql);
983 
984                 QueryPos qPos = QueryPos.getInstance(q);
985 
986                 qPos.add(productEntryId);
987 
988                 qPos.add(priority);
989 
990                 List<SCProductScreenshot> list = q.list();
991 
992                 result = list;
993 
994                 SCProductScreenshot scProductScreenshot = null;
995 
996                 if (list.isEmpty()) {
997                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_P,
998                         finderArgs, list);
999                 }
1000                else {
1001                    scProductScreenshot = list.get(0);
1002
1003                    cacheResult(scProductScreenshot);
1004
1005                    if ((scProductScreenshot.getProductEntryId() != productEntryId) ||
1006                            (scProductScreenshot.getPriority() != priority)) {
1007                        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_P,
1008                            finderArgs, scProductScreenshot);
1009                    }
1010                }
1011
1012                return scProductScreenshot;
1013            }
1014            catch (Exception e) {
1015                throw processException(e);
1016            }
1017            finally {
1018                if (result == null) {
1019                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_P,
1020                        finderArgs, new ArrayList<SCProductScreenshot>());
1021                }
1022
1023                closeSession(session);
1024            }
1025        }
1026        else {
1027            if (result instanceof List<?>) {
1028                return null;
1029            }
1030            else {
1031                return (SCProductScreenshot)result;
1032            }
1033        }
1034    }
1035
1036    public List<SCProductScreenshot> findAll() throws SystemException {
1037        return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1038    }
1039
1040    public List<SCProductScreenshot> findAll(int start, int end)
1041        throws SystemException {
1042        return findAll(start, end, null);
1043    }
1044
1045    public List<SCProductScreenshot> findAll(int start, int end,
1046        OrderByComparator orderByComparator) throws SystemException {
1047        Object[] finderArgs = new Object[] {
1048                String.valueOf(start), String.valueOf(end),
1049                String.valueOf(orderByComparator)
1050            };
1051
1052        List<SCProductScreenshot> list = (List<SCProductScreenshot>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1053                finderArgs, this);
1054
1055        if (list == null) {
1056            StringBundler query = null;
1057            String sql = null;
1058
1059            if (orderByComparator != null) {
1060                query = new StringBundler(2 +
1061                        (orderByComparator.getOrderByFields().length * 3));
1062
1063                query.append(_SQL_SELECT_SCPRODUCTSCREENSHOT);
1064
1065                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1066                    orderByComparator);
1067
1068                sql = query.toString();
1069            }
1070            else {
1071                sql = _SQL_SELECT_SCPRODUCTSCREENSHOT.concat(SCProductScreenshotModelImpl.ORDER_BY_JPQL);
1072            }
1073
1074            Session session = null;
1075
1076            try {
1077                session = openSession();
1078
1079                Query q = session.createQuery(sql);
1080
1081                if (orderByComparator == null) {
1082                    list = (List<SCProductScreenshot>)QueryUtil.list(q,
1083                            getDialect(), start, end, false);
1084
1085                    Collections.sort(list);
1086                }
1087                else {
1088                    list = (List<SCProductScreenshot>)QueryUtil.list(q,
1089                            getDialect(), start, end);
1090                }
1091            }
1092            catch (Exception e) {
1093                throw processException(e);
1094            }
1095            finally {
1096                if (list == null) {
1097                    list = new ArrayList<SCProductScreenshot>();
1098                }
1099
1100                cacheResult(list);
1101
1102                FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1103
1104                closeSession(session);
1105            }
1106        }
1107
1108        return list;
1109    }
1110
1111    public void removeByProductEntryId(long productEntryId)
1112        throws SystemException {
1113        for (SCProductScreenshot scProductScreenshot : findByProductEntryId(
1114                productEntryId)) {
1115            remove(scProductScreenshot);
1116        }
1117    }
1118
1119    public void removeByThumbnailId(long thumbnailId)
1120        throws NoSuchProductScreenshotException, SystemException {
1121        SCProductScreenshot scProductScreenshot = findByThumbnailId(thumbnailId);
1122
1123        remove(scProductScreenshot);
1124    }
1125
1126    public void removeByFullImageId(long fullImageId)
1127        throws NoSuchProductScreenshotException, SystemException {
1128        SCProductScreenshot scProductScreenshot = findByFullImageId(fullImageId);
1129
1130        remove(scProductScreenshot);
1131    }
1132
1133    public void removeByP_P(long productEntryId, int priority)
1134        throws NoSuchProductScreenshotException, SystemException {
1135        SCProductScreenshot scProductScreenshot = findByP_P(productEntryId,
1136                priority);
1137
1138        remove(scProductScreenshot);
1139    }
1140
1141    public void removeAll() throws SystemException {
1142        for (SCProductScreenshot scProductScreenshot : findAll()) {
1143            remove(scProductScreenshot);
1144        }
1145    }
1146
1147    public int countByProductEntryId(long productEntryId)
1148        throws SystemException {
1149        Object[] finderArgs = new Object[] { productEntryId };
1150
1151        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PRODUCTENTRYID,
1152                finderArgs, this);
1153
1154        if (count == null) {
1155            StringBundler query = new StringBundler(2);
1156
1157            query.append(_SQL_COUNT_SCPRODUCTSCREENSHOT_WHERE);
1158
1159            query.append(_FINDER_COLUMN_PRODUCTENTRYID_PRODUCTENTRYID_2);
1160
1161            String sql = query.toString();
1162
1163            Session session = null;
1164
1165            try {
1166                session = openSession();
1167
1168                Query q = session.createQuery(sql);
1169
1170                QueryPos qPos = QueryPos.getInstance(q);
1171
1172                qPos.add(productEntryId);
1173
1174                count = (Long)q.uniqueResult();
1175            }
1176            catch (Exception e) {
1177                throw processException(e);
1178            }
1179            finally {
1180                if (count == null) {
1181                    count = Long.valueOf(0);
1182                }
1183
1184                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PRODUCTENTRYID,
1185                    finderArgs, count);
1186
1187                closeSession(session);
1188            }
1189        }
1190
1191        return count.intValue();
1192    }
1193
1194    public int countByThumbnailId(long thumbnailId) throws SystemException {
1195        Object[] finderArgs = new Object[] { thumbnailId };
1196
1197        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_THUMBNAILID,
1198                finderArgs, this);
1199
1200        if (count == null) {
1201            StringBundler query = new StringBundler(2);
1202
1203            query.append(_SQL_COUNT_SCPRODUCTSCREENSHOT_WHERE);
1204
1205            query.append(_FINDER_COLUMN_THUMBNAILID_THUMBNAILID_2);
1206
1207            String sql = query.toString();
1208
1209            Session session = null;
1210
1211            try {
1212                session = openSession();
1213
1214                Query q = session.createQuery(sql);
1215
1216                QueryPos qPos = QueryPos.getInstance(q);
1217
1218                qPos.add(thumbnailId);
1219
1220                count = (Long)q.uniqueResult();
1221            }
1222            catch (Exception e) {
1223                throw processException(e);
1224            }
1225            finally {
1226                if (count == null) {
1227                    count = Long.valueOf(0);
1228                }
1229
1230                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_THUMBNAILID,
1231                    finderArgs, count);
1232
1233                closeSession(session);
1234            }
1235        }
1236
1237        return count.intValue();
1238    }
1239
1240    public int countByFullImageId(long fullImageId) throws SystemException {
1241        Object[] finderArgs = new Object[] { fullImageId };
1242
1243        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_FULLIMAGEID,
1244                finderArgs, this);
1245
1246        if (count == null) {
1247            StringBundler query = new StringBundler(2);
1248
1249            query.append(_SQL_COUNT_SCPRODUCTSCREENSHOT_WHERE);
1250
1251            query.append(_FINDER_COLUMN_FULLIMAGEID_FULLIMAGEID_2);
1252
1253            String sql = query.toString();
1254
1255            Session session = null;
1256
1257            try {
1258                session = openSession();
1259
1260                Query q = session.createQuery(sql);
1261
1262                QueryPos qPos = QueryPos.getInstance(q);
1263
1264                qPos.add(fullImageId);
1265
1266                count = (Long)q.uniqueResult();
1267            }
1268            catch (Exception e) {
1269                throw processException(e);
1270            }
1271            finally {
1272                if (count == null) {
1273                    count = Long.valueOf(0);
1274                }
1275
1276                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_FULLIMAGEID,
1277                    finderArgs, count);
1278
1279                closeSession(session);
1280            }
1281        }
1282
1283        return count.intValue();
1284    }
1285
1286    public int countByP_P(long productEntryId, int priority)
1287        throws SystemException {
1288        Object[] finderArgs = new Object[] { productEntryId, priority };
1289
1290        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_P,
1291                finderArgs, this);
1292
1293        if (count == null) {
1294            StringBundler query = new StringBundler(3);
1295
1296            query.append(_SQL_COUNT_SCPRODUCTSCREENSHOT_WHERE);
1297
1298            query.append(_FINDER_COLUMN_P_P_PRODUCTENTRYID_2);
1299
1300            query.append(_FINDER_COLUMN_P_P_PRIORITY_2);
1301
1302            String sql = query.toString();
1303
1304            Session session = null;
1305
1306            try {
1307                session = openSession();
1308
1309                Query q = session.createQuery(sql);
1310
1311                QueryPos qPos = QueryPos.getInstance(q);
1312
1313                qPos.add(productEntryId);
1314
1315                qPos.add(priority);
1316
1317                count = (Long)q.uniqueResult();
1318            }
1319            catch (Exception e) {
1320                throw processException(e);
1321            }
1322            finally {
1323                if (count == null) {
1324                    count = Long.valueOf(0);
1325                }
1326
1327                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_P, finderArgs,
1328                    count);
1329
1330                closeSession(session);
1331            }
1332        }
1333
1334        return count.intValue();
1335    }
1336
1337    public int countAll() throws SystemException {
1338        Object[] finderArgs = new Object[0];
1339
1340        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1341                finderArgs, this);
1342
1343        if (count == null) {
1344            Session session = null;
1345
1346            try {
1347                session = openSession();
1348
1349                Query q = session.createQuery(_SQL_COUNT_SCPRODUCTSCREENSHOT);
1350
1351                count = (Long)q.uniqueResult();
1352            }
1353            catch (Exception e) {
1354                throw processException(e);
1355            }
1356            finally {
1357                if (count == null) {
1358                    count = Long.valueOf(0);
1359                }
1360
1361                FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1362                    count);
1363
1364                closeSession(session);
1365            }
1366        }
1367
1368        return count.intValue();
1369    }
1370
1371    public void afterPropertiesSet() {
1372        String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1373                    com.liferay.portal.util.PropsUtil.get(
1374                        "value.object.listener.com.liferay.portlet.softwarecatalog.model.SCProductScreenshot")));
1375
1376        if (listenerClassNames.length > 0) {
1377            try {
1378                List<ModelListener<SCProductScreenshot>> listenersList = new ArrayList<ModelListener<SCProductScreenshot>>();
1379
1380                for (String listenerClassName : listenerClassNames) {
1381                    listenersList.add((ModelListener<SCProductScreenshot>)InstanceFactory.newInstance(
1382                            listenerClassName));
1383                }
1384
1385                listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1386            }
1387            catch (Exception e) {
1388                _log.error(e);
1389            }
1390        }
1391    }
1392
1393    public void destroy() {
1394        EntityCacheUtil.removeCache(SCProductScreenshotImpl.class.getName());
1395        FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1396        FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
1397    }
1398
1399    @BeanReference(type = SCLicensePersistence.class)
1400    protected SCLicensePersistence scLicensePersistence;
1401    @BeanReference(type = SCFrameworkVersionPersistence.class)
1402    protected SCFrameworkVersionPersistence scFrameworkVersionPersistence;
1403    @BeanReference(type = SCProductEntryPersistence.class)
1404    protected SCProductEntryPersistence scProductEntryPersistence;
1405    @BeanReference(type = SCProductScreenshotPersistence.class)
1406    protected SCProductScreenshotPersistence scProductScreenshotPersistence;
1407    @BeanReference(type = SCProductVersionPersistence.class)
1408    protected SCProductVersionPersistence scProductVersionPersistence;
1409    @BeanReference(type = ImagePersistence.class)
1410    protected ImagePersistence imagePersistence;
1411    @BeanReference(type = ResourcePersistence.class)
1412    protected ResourcePersistence resourcePersistence;
1413    @BeanReference(type = UserPersistence.class)
1414    protected UserPersistence userPersistence;
1415    private static final String _SQL_SELECT_SCPRODUCTSCREENSHOT = "SELECT scProductScreenshot FROM SCProductScreenshot scProductScreenshot";
1416    private static final String _SQL_SELECT_SCPRODUCTSCREENSHOT_WHERE = "SELECT scProductScreenshot FROM SCProductScreenshot scProductScreenshot WHERE ";
1417    private static final String _SQL_COUNT_SCPRODUCTSCREENSHOT = "SELECT COUNT(scProductScreenshot) FROM SCProductScreenshot scProductScreenshot";
1418    private static final String _SQL_COUNT_SCPRODUCTSCREENSHOT_WHERE = "SELECT COUNT(scProductScreenshot) FROM SCProductScreenshot scProductScreenshot WHERE ";
1419    private static final String _FINDER_COLUMN_PRODUCTENTRYID_PRODUCTENTRYID_2 = "scProductScreenshot.productEntryId = ?";
1420    private static final String _FINDER_COLUMN_THUMBNAILID_THUMBNAILID_2 = "scProductScreenshot.thumbnailId = ?";
1421    private static final String _FINDER_COLUMN_FULLIMAGEID_FULLIMAGEID_2 = "scProductScreenshot.fullImageId = ?";
1422    private static final String _FINDER_COLUMN_P_P_PRODUCTENTRYID_2 = "scProductScreenshot.productEntryId = ? AND ";
1423    private static final String _FINDER_COLUMN_P_P_PRIORITY_2 = "scProductScreenshot.priority = ?";
1424    private static final String _ORDER_BY_ENTITY_ALIAS = "scProductScreenshot.";
1425    private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SCProductScreenshot exists with the primary key ";
1426    private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SCProductScreenshot exists with the key {";
1427    private static Log _log = LogFactoryUtil.getLog(SCProductScreenshotPersistenceImpl.class);
1428}