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