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