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