001
014
015 package com.liferay.portlet.softwarecatalog.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.bean.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderPath;
023 import com.liferay.portal.kernel.dao.orm.Query;
024 import com.liferay.portal.kernel.dao.orm.QueryPos;
025 import com.liferay.portal.kernel.dao.orm.QueryUtil;
026 import com.liferay.portal.kernel.dao.orm.Session;
027 import com.liferay.portal.kernel.exception.SystemException;
028 import com.liferay.portal.kernel.log.Log;
029 import com.liferay.portal.kernel.log.LogFactoryUtil;
030 import com.liferay.portal.kernel.util.GetterUtil;
031 import com.liferay.portal.kernel.util.InstanceFactory;
032 import com.liferay.portal.kernel.util.OrderByComparator;
033 import com.liferay.portal.kernel.util.StringBundler;
034 import com.liferay.portal.kernel.util.StringPool;
035 import com.liferay.portal.kernel.util.StringUtil;
036 import com.liferay.portal.model.CacheModel;
037 import com.liferay.portal.model.ModelListener;
038 import com.liferay.portal.service.persistence.BatchSessionUtil;
039 import com.liferay.portal.service.persistence.ImagePersistence;
040 import com.liferay.portal.service.persistence.ResourcePersistence;
041 import com.liferay.portal.service.persistence.UserPersistence;
042 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
043
044 import com.liferay.portlet.softwarecatalog.NoSuchProductScreenshotException;
045 import com.liferay.portlet.softwarecatalog.model.SCProductScreenshot;
046 import com.liferay.portlet.softwarecatalog.model.impl.SCProductScreenshotImpl;
047 import com.liferay.portlet.softwarecatalog.model.impl.SCProductScreenshotModelImpl;
048
049 import java.io.Serializable;
050
051 import java.util.ArrayList;
052 import java.util.Collections;
053 import java.util.List;
054
055
067 public class SCProductScreenshotPersistenceImpl extends BasePersistenceImpl<SCProductScreenshot>
068 implements SCProductScreenshotPersistence {
069
074 public static final String FINDER_CLASS_NAME_ENTITY = SCProductScreenshotImpl.class.getName();
075 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
076 ".List1";
077 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
078 ".List2";
079 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_PRODUCTENTRYID =
080 new FinderPath(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
081 SCProductScreenshotModelImpl.FINDER_CACHE_ENABLED,
082 SCProductScreenshotImpl.class,
083 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByProductEntryId",
084 new String[] {
085 Long.class.getName(),
086
087 "java.lang.Integer", "java.lang.Integer",
088 "com.liferay.portal.kernel.util.OrderByComparator"
089 });
090 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PRODUCTENTRYID =
091 new FinderPath(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
092 SCProductScreenshotModelImpl.FINDER_CACHE_ENABLED,
093 SCProductScreenshotImpl.class,
094 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByProductEntryId",
095 new String[] { Long.class.getName() },
096 SCProductScreenshotModelImpl.PRODUCTENTRYID_COLUMN_BITMASK);
097 public static final FinderPath FINDER_PATH_COUNT_BY_PRODUCTENTRYID = new FinderPath(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
098 SCProductScreenshotModelImpl.FINDER_CACHE_ENABLED, Long.class,
099 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByProductEntryId",
100 new String[] { Long.class.getName() });
101 public static final FinderPath FINDER_PATH_FETCH_BY_THUMBNAILID = new FinderPath(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
102 SCProductScreenshotModelImpl.FINDER_CACHE_ENABLED,
103 SCProductScreenshotImpl.class, FINDER_CLASS_NAME_ENTITY,
104 "fetchByThumbnailId", new String[] { Long.class.getName() },
105 SCProductScreenshotModelImpl.THUMBNAILID_COLUMN_BITMASK);
106 public static final FinderPath FINDER_PATH_COUNT_BY_THUMBNAILID = new FinderPath(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
107 SCProductScreenshotModelImpl.FINDER_CACHE_ENABLED, Long.class,
108 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByThumbnailId",
109 new String[] { Long.class.getName() });
110 public static final FinderPath FINDER_PATH_FETCH_BY_FULLIMAGEID = new FinderPath(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
111 SCProductScreenshotModelImpl.FINDER_CACHE_ENABLED,
112 SCProductScreenshotImpl.class, FINDER_CLASS_NAME_ENTITY,
113 "fetchByFullImageId", new String[] { Long.class.getName() },
114 SCProductScreenshotModelImpl.FULLIMAGEID_COLUMN_BITMASK);
115 public static final FinderPath FINDER_PATH_COUNT_BY_FULLIMAGEID = new FinderPath(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
116 SCProductScreenshotModelImpl.FINDER_CACHE_ENABLED, Long.class,
117 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByFullImageId",
118 new String[] { Long.class.getName() });
119 public static final FinderPath FINDER_PATH_FETCH_BY_P_P = new FinderPath(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
120 SCProductScreenshotModelImpl.FINDER_CACHE_ENABLED,
121 SCProductScreenshotImpl.class, FINDER_CLASS_NAME_ENTITY,
122 "fetchByP_P",
123 new String[] { Long.class.getName(), Integer.class.getName() },
124 SCProductScreenshotModelImpl.PRODUCTENTRYID_COLUMN_BITMASK |
125 SCProductScreenshotModelImpl.PRIORITY_COLUMN_BITMASK);
126 public static final FinderPath FINDER_PATH_COUNT_BY_P_P = new FinderPath(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
127 SCProductScreenshotModelImpl.FINDER_CACHE_ENABLED, Long.class,
128 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_P",
129 new String[] { Long.class.getName(), Integer.class.getName() });
130 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
131 SCProductScreenshotModelImpl.FINDER_CACHE_ENABLED,
132 SCProductScreenshotImpl.class,
133 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
134 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
135 SCProductScreenshotModelImpl.FINDER_CACHE_ENABLED,
136 SCProductScreenshotImpl.class,
137 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
138 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
139 SCProductScreenshotModelImpl.FINDER_CACHE_ENABLED, Long.class,
140 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
141
142
147 public void cacheResult(SCProductScreenshot scProductScreenshot) {
148 EntityCacheUtil.putResult(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
149 SCProductScreenshotImpl.class, scProductScreenshot.getPrimaryKey(),
150 scProductScreenshot);
151
152 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_THUMBNAILID,
153 new Object[] { Long.valueOf(scProductScreenshot.getThumbnailId()) },
154 scProductScreenshot);
155
156 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_FULLIMAGEID,
157 new Object[] { Long.valueOf(scProductScreenshot.getFullImageId()) },
158 scProductScreenshot);
159
160 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_P,
161 new Object[] {
162 Long.valueOf(scProductScreenshot.getProductEntryId()),
163 Integer.valueOf(scProductScreenshot.getPriority())
164 }, scProductScreenshot);
165
166 scProductScreenshot.resetOriginalValues();
167 }
168
169
174 public void cacheResult(List<SCProductScreenshot> scProductScreenshots) {
175 for (SCProductScreenshot scProductScreenshot : scProductScreenshots) {
176 if (EntityCacheUtil.getResult(
177 SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
178 SCProductScreenshotImpl.class,
179 scProductScreenshot.getPrimaryKey()) == null) {
180 cacheResult(scProductScreenshot);
181 }
182 else {
183 scProductScreenshot.resetOriginalValues();
184 }
185 }
186 }
187
188
195 @Override
196 public void clearCache() {
197 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
198 CacheRegistryUtil.clear(SCProductScreenshotImpl.class.getName());
199 }
200
201 EntityCacheUtil.clearCache(SCProductScreenshotImpl.class.getName());
202
203 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
204 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
205 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
206 }
207
208
215 @Override
216 public void clearCache(SCProductScreenshot scProductScreenshot) {
217 EntityCacheUtil.removeResult(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
218 SCProductScreenshotImpl.class, scProductScreenshot.getPrimaryKey());
219
220 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
221 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
222
223 clearUniqueFindersCache(scProductScreenshot);
224 }
225
226 @Override
227 public void clearCache(List<SCProductScreenshot> scProductScreenshots) {
228 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
229 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
230
231 for (SCProductScreenshot scProductScreenshot : scProductScreenshots) {
232 EntityCacheUtil.removeResult(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
233 SCProductScreenshotImpl.class,
234 scProductScreenshot.getPrimaryKey());
235
236 clearUniqueFindersCache(scProductScreenshot);
237 }
238 }
239
240 protected void clearUniqueFindersCache(
241 SCProductScreenshot scProductScreenshot) {
242 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_THUMBNAILID,
243 new Object[] { Long.valueOf(scProductScreenshot.getThumbnailId()) });
244
245 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_FULLIMAGEID,
246 new Object[] { Long.valueOf(scProductScreenshot.getFullImageId()) });
247
248 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_P,
249 new Object[] {
250 Long.valueOf(scProductScreenshot.getProductEntryId()),
251 Integer.valueOf(scProductScreenshot.getPriority())
252 });
253 }
254
255
261 public SCProductScreenshot create(long productScreenshotId) {
262 SCProductScreenshot scProductScreenshot = new SCProductScreenshotImpl();
263
264 scProductScreenshot.setNew(true);
265 scProductScreenshot.setPrimaryKey(productScreenshotId);
266
267 return scProductScreenshot;
268 }
269
270
278 public SCProductScreenshot remove(long productScreenshotId)
279 throws NoSuchProductScreenshotException, SystemException {
280 return remove(Long.valueOf(productScreenshotId));
281 }
282
283
291 @Override
292 public SCProductScreenshot remove(Serializable primaryKey)
293 throws NoSuchProductScreenshotException, SystemException {
294 Session session = null;
295
296 try {
297 session = openSession();
298
299 SCProductScreenshot scProductScreenshot = (SCProductScreenshot)session.get(SCProductScreenshotImpl.class,
300 primaryKey);
301
302 if (scProductScreenshot == null) {
303 if (_log.isWarnEnabled()) {
304 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
305 }
306
307 throw new NoSuchProductScreenshotException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
308 primaryKey);
309 }
310
311 return remove(scProductScreenshot);
312 }
313 catch (NoSuchProductScreenshotException nsee) {
314 throw nsee;
315 }
316 catch (Exception e) {
317 throw processException(e);
318 }
319 finally {
320 closeSession(session);
321 }
322 }
323
324 @Override
325 protected SCProductScreenshot removeImpl(
326 SCProductScreenshot scProductScreenshot) throws SystemException {
327 scProductScreenshot = toUnwrappedModel(scProductScreenshot);
328
329 Session session = null;
330
331 try {
332 session = openSession();
333
334 BatchSessionUtil.delete(session, scProductScreenshot);
335 }
336 catch (Exception e) {
337 throw processException(e);
338 }
339 finally {
340 closeSession(session);
341 }
342
343 clearCache(scProductScreenshot);
344
345 return scProductScreenshot;
346 }
347
348 @Override
349 public SCProductScreenshot updateImpl(
350 com.liferay.portlet.softwarecatalog.model.SCProductScreenshot scProductScreenshot,
351 boolean merge) throws SystemException {
352 scProductScreenshot = toUnwrappedModel(scProductScreenshot);
353
354 boolean isNew = scProductScreenshot.isNew();
355
356 SCProductScreenshotModelImpl scProductScreenshotModelImpl = (SCProductScreenshotModelImpl)scProductScreenshot;
357
358 Session session = null;
359
360 try {
361 session = openSession();
362
363 BatchSessionUtil.update(session, scProductScreenshot, merge);
364
365 scProductScreenshot.setNew(false);
366 }
367 catch (Exception e) {
368 throw processException(e);
369 }
370 finally {
371 closeSession(session);
372 }
373
374 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
375
376 if (isNew || !SCProductScreenshotModelImpl.COLUMN_BITMASK_ENABLED) {
377 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
378 }
379 else {
380 if ((scProductScreenshotModelImpl.getColumnBitmask() &
381 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PRODUCTENTRYID.getColumnBitmask()) != 0) {
382 Object[] args = new Object[] {
383 Long.valueOf(scProductScreenshotModelImpl.getOriginalProductEntryId())
384 };
385
386 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PRODUCTENTRYID,
387 args);
388 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PRODUCTENTRYID,
389 args);
390
391 args = new Object[] {
392 Long.valueOf(scProductScreenshotModelImpl.getProductEntryId())
393 };
394
395 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PRODUCTENTRYID,
396 args);
397 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PRODUCTENTRYID,
398 args);
399 }
400 }
401
402 EntityCacheUtil.putResult(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
403 SCProductScreenshotImpl.class, scProductScreenshot.getPrimaryKey(),
404 scProductScreenshot);
405
406 if (isNew) {
407 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_THUMBNAILID,
408 new Object[] { Long.valueOf(
409 scProductScreenshot.getThumbnailId()) },
410 scProductScreenshot);
411
412 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_FULLIMAGEID,
413 new Object[] { Long.valueOf(
414 scProductScreenshot.getFullImageId()) },
415 scProductScreenshot);
416
417 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_P,
418 new Object[] {
419 Long.valueOf(scProductScreenshot.getProductEntryId()),
420 Integer.valueOf(scProductScreenshot.getPriority())
421 }, scProductScreenshot);
422 }
423 else {
424 if ((scProductScreenshotModelImpl.getColumnBitmask() &
425 FINDER_PATH_FETCH_BY_THUMBNAILID.getColumnBitmask()) != 0) {
426 Object[] args = new Object[] {
427 Long.valueOf(scProductScreenshotModelImpl.getOriginalThumbnailId())
428 };
429
430 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_THUMBNAILID,
431 args);
432 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_THUMBNAILID,
433 args);
434
435 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_THUMBNAILID,
436 new Object[] {
437 Long.valueOf(scProductScreenshot.getThumbnailId())
438 }, scProductScreenshot);
439 }
440
441 if ((scProductScreenshotModelImpl.getColumnBitmask() &
442 FINDER_PATH_FETCH_BY_FULLIMAGEID.getColumnBitmask()) != 0) {
443 Object[] args = new Object[] {
444 Long.valueOf(scProductScreenshotModelImpl.getOriginalFullImageId())
445 };
446
447 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FULLIMAGEID,
448 args);
449 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_FULLIMAGEID,
450 args);
451
452 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_FULLIMAGEID,
453 new Object[] {
454 Long.valueOf(scProductScreenshot.getFullImageId())
455 }, scProductScreenshot);
456 }
457
458 if ((scProductScreenshotModelImpl.getColumnBitmask() &
459 FINDER_PATH_FETCH_BY_P_P.getColumnBitmask()) != 0) {
460 Object[] args = new Object[] {
461 Long.valueOf(scProductScreenshotModelImpl.getOriginalProductEntryId()),
462 Integer.valueOf(scProductScreenshotModelImpl.getOriginalPriority())
463 };
464
465 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_P, args);
466 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_P, args);
467
468 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_P,
469 new Object[] {
470 Long.valueOf(scProductScreenshot.getProductEntryId()),
471 Integer.valueOf(scProductScreenshot.getPriority())
472 }, scProductScreenshot);
473 }
474 }
475
476 return scProductScreenshot;
477 }
478
479 protected SCProductScreenshot toUnwrappedModel(
480 SCProductScreenshot scProductScreenshot) {
481 if (scProductScreenshot instanceof SCProductScreenshotImpl) {
482 return scProductScreenshot;
483 }
484
485 SCProductScreenshotImpl scProductScreenshotImpl = new SCProductScreenshotImpl();
486
487 scProductScreenshotImpl.setNew(scProductScreenshot.isNew());
488 scProductScreenshotImpl.setPrimaryKey(scProductScreenshot.getPrimaryKey());
489
490 scProductScreenshotImpl.setProductScreenshotId(scProductScreenshot.getProductScreenshotId());
491 scProductScreenshotImpl.setCompanyId(scProductScreenshot.getCompanyId());
492 scProductScreenshotImpl.setGroupId(scProductScreenshot.getGroupId());
493 scProductScreenshotImpl.setProductEntryId(scProductScreenshot.getProductEntryId());
494 scProductScreenshotImpl.setThumbnailId(scProductScreenshot.getThumbnailId());
495 scProductScreenshotImpl.setFullImageId(scProductScreenshot.getFullImageId());
496 scProductScreenshotImpl.setPriority(scProductScreenshot.getPriority());
497
498 return scProductScreenshotImpl;
499 }
500
501
509 @Override
510 public SCProductScreenshot findByPrimaryKey(Serializable primaryKey)
511 throws NoSuchModelException, SystemException {
512 return findByPrimaryKey(((Long)primaryKey).longValue());
513 }
514
515
523 public SCProductScreenshot findByPrimaryKey(long productScreenshotId)
524 throws NoSuchProductScreenshotException, SystemException {
525 SCProductScreenshot scProductScreenshot = fetchByPrimaryKey(productScreenshotId);
526
527 if (scProductScreenshot == null) {
528 if (_log.isWarnEnabled()) {
529 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
530 productScreenshotId);
531 }
532
533 throw new NoSuchProductScreenshotException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
534 productScreenshotId);
535 }
536
537 return scProductScreenshot;
538 }
539
540
547 @Override
548 public SCProductScreenshot fetchByPrimaryKey(Serializable primaryKey)
549 throws SystemException {
550 return fetchByPrimaryKey(((Long)primaryKey).longValue());
551 }
552
553
560 public SCProductScreenshot fetchByPrimaryKey(long productScreenshotId)
561 throws SystemException {
562 SCProductScreenshot scProductScreenshot = (SCProductScreenshot)EntityCacheUtil.getResult(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
563 SCProductScreenshotImpl.class, productScreenshotId);
564
565 if (scProductScreenshot == _nullSCProductScreenshot) {
566 return null;
567 }
568
569 if (scProductScreenshot == null) {
570 Session session = null;
571
572 boolean hasException = false;
573
574 try {
575 session = openSession();
576
577 scProductScreenshot = (SCProductScreenshot)session.get(SCProductScreenshotImpl.class,
578 Long.valueOf(productScreenshotId));
579 }
580 catch (Exception e) {
581 hasException = true;
582
583 throw processException(e);
584 }
585 finally {
586 if (scProductScreenshot != null) {
587 cacheResult(scProductScreenshot);
588 }
589 else if (!hasException) {
590 EntityCacheUtil.putResult(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
591 SCProductScreenshotImpl.class, productScreenshotId,
592 _nullSCProductScreenshot);
593 }
594
595 closeSession(session);
596 }
597 }
598
599 return scProductScreenshot;
600 }
601
602
609 public List<SCProductScreenshot> findByProductEntryId(long productEntryId)
610 throws SystemException {
611 return findByProductEntryId(productEntryId, QueryUtil.ALL_POS,
612 QueryUtil.ALL_POS, null);
613 }
614
615
628 public List<SCProductScreenshot> findByProductEntryId(long productEntryId,
629 int start, int end) throws SystemException {
630 return findByProductEntryId(productEntryId, start, end, null);
631 }
632
633
647 public List<SCProductScreenshot> findByProductEntryId(long productEntryId,
648 int start, int end, OrderByComparator orderByComparator)
649 throws SystemException {
650 FinderPath finderPath = null;
651 Object[] finderArgs = null;
652
653 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
654 (orderByComparator == null)) {
655 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PRODUCTENTRYID;
656 finderArgs = new Object[] { productEntryId };
657 }
658 else {
659 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PRODUCTENTRYID;
660 finderArgs = new Object[] {
661 productEntryId,
662
663 start, end, orderByComparator
664 };
665 }
666
667 List<SCProductScreenshot> list = (List<SCProductScreenshot>)FinderCacheUtil.getResult(finderPath,
668 finderArgs, this);
669
670 if ((list != null) && !list.isEmpty()) {
671 for (SCProductScreenshot scProductScreenshot : list) {
672 if ((productEntryId != scProductScreenshot.getProductEntryId())) {
673 list = null;
674
675 break;
676 }
677 }
678 }
679
680 if (list == null) {
681 StringBundler query = null;
682
683 if (orderByComparator != null) {
684 query = new StringBundler(3 +
685 (orderByComparator.getOrderByFields().length * 3));
686 }
687 else {
688 query = new StringBundler(3);
689 }
690
691 query.append(_SQL_SELECT_SCPRODUCTSCREENSHOT_WHERE);
692
693 query.append(_FINDER_COLUMN_PRODUCTENTRYID_PRODUCTENTRYID_2);
694
695 if (orderByComparator != null) {
696 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
697 orderByComparator);
698 }
699
700 else {
701 query.append(SCProductScreenshotModelImpl.ORDER_BY_JPQL);
702 }
703
704 String sql = query.toString();
705
706 Session session = null;
707
708 try {
709 session = openSession();
710
711 Query q = session.createQuery(sql);
712
713 QueryPos qPos = QueryPos.getInstance(q);
714
715 qPos.add(productEntryId);
716
717 list = (List<SCProductScreenshot>)QueryUtil.list(q,
718 getDialect(), start, end);
719 }
720 catch (Exception e) {
721 throw processException(e);
722 }
723 finally {
724 if (list == null) {
725 FinderCacheUtil.removeResult(finderPath, finderArgs);
726 }
727 else {
728 cacheResult(list);
729
730 FinderCacheUtil.putResult(finderPath, finderArgs, list);
731 }
732
733 closeSession(session);
734 }
735 }
736
737 return list;
738 }
739
740
753 public SCProductScreenshot findByProductEntryId_First(long productEntryId,
754 OrderByComparator orderByComparator)
755 throws NoSuchProductScreenshotException, SystemException {
756 List<SCProductScreenshot> list = findByProductEntryId(productEntryId,
757 0, 1, orderByComparator);
758
759 if (list.isEmpty()) {
760 StringBundler msg = new StringBundler(4);
761
762 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
763
764 msg.append("productEntryId=");
765 msg.append(productEntryId);
766
767 msg.append(StringPool.CLOSE_CURLY_BRACE);
768
769 throw new NoSuchProductScreenshotException(msg.toString());
770 }
771 else {
772 return list.get(0);
773 }
774 }
775
776
789 public SCProductScreenshot findByProductEntryId_Last(long productEntryId,
790 OrderByComparator orderByComparator)
791 throws NoSuchProductScreenshotException, SystemException {
792 int count = countByProductEntryId(productEntryId);
793
794 List<SCProductScreenshot> list = findByProductEntryId(productEntryId,
795 count - 1, count, orderByComparator);
796
797 if (list.isEmpty()) {
798 StringBundler msg = new StringBundler(4);
799
800 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
801
802 msg.append("productEntryId=");
803 msg.append(productEntryId);
804
805 msg.append(StringPool.CLOSE_CURLY_BRACE);
806
807 throw new NoSuchProductScreenshotException(msg.toString());
808 }
809 else {
810 return list.get(0);
811 }
812 }
813
814
828 public SCProductScreenshot[] findByProductEntryId_PrevAndNext(
829 long productScreenshotId, long productEntryId,
830 OrderByComparator orderByComparator)
831 throws NoSuchProductScreenshotException, SystemException {
832 SCProductScreenshot scProductScreenshot = findByPrimaryKey(productScreenshotId);
833
834 Session session = null;
835
836 try {
837 session = openSession();
838
839 SCProductScreenshot[] array = new SCProductScreenshotImpl[3];
840
841 array[0] = getByProductEntryId_PrevAndNext(session,
842 scProductScreenshot, productEntryId, orderByComparator, true);
843
844 array[1] = scProductScreenshot;
845
846 array[2] = getByProductEntryId_PrevAndNext(session,
847 scProductScreenshot, productEntryId, orderByComparator,
848 false);
849
850 return array;
851 }
852 catch (Exception e) {
853 throw processException(e);
854 }
855 finally {
856 closeSession(session);
857 }
858 }
859
860 protected SCProductScreenshot getByProductEntryId_PrevAndNext(
861 Session session, SCProductScreenshot scProductScreenshot,
862 long productEntryId, OrderByComparator orderByComparator,
863 boolean previous) {
864 StringBundler query = null;
865
866 if (orderByComparator != null) {
867 query = new StringBundler(6 +
868 (orderByComparator.getOrderByFields().length * 6));
869 }
870 else {
871 query = new StringBundler(3);
872 }
873
874 query.append(_SQL_SELECT_SCPRODUCTSCREENSHOT_WHERE);
875
876 query.append(_FINDER_COLUMN_PRODUCTENTRYID_PRODUCTENTRYID_2);
877
878 if (orderByComparator != null) {
879 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
880
881 if (orderByConditionFields.length > 0) {
882 query.append(WHERE_AND);
883 }
884
885 for (int i = 0; i < orderByConditionFields.length; i++) {
886 query.append(_ORDER_BY_ENTITY_ALIAS);
887 query.append(orderByConditionFields[i]);
888
889 if ((i + 1) < orderByConditionFields.length) {
890 if (orderByComparator.isAscending() ^ previous) {
891 query.append(WHERE_GREATER_THAN_HAS_NEXT);
892 }
893 else {
894 query.append(WHERE_LESSER_THAN_HAS_NEXT);
895 }
896 }
897 else {
898 if (orderByComparator.isAscending() ^ previous) {
899 query.append(WHERE_GREATER_THAN);
900 }
901 else {
902 query.append(WHERE_LESSER_THAN);
903 }
904 }
905 }
906
907 query.append(ORDER_BY_CLAUSE);
908
909 String[] orderByFields = orderByComparator.getOrderByFields();
910
911 for (int i = 0; i < orderByFields.length; i++) {
912 query.append(_ORDER_BY_ENTITY_ALIAS);
913 query.append(orderByFields[i]);
914
915 if ((i + 1) < orderByFields.length) {
916 if (orderByComparator.isAscending() ^ previous) {
917 query.append(ORDER_BY_ASC_HAS_NEXT);
918 }
919 else {
920 query.append(ORDER_BY_DESC_HAS_NEXT);
921 }
922 }
923 else {
924 if (orderByComparator.isAscending() ^ previous) {
925 query.append(ORDER_BY_ASC);
926 }
927 else {
928 query.append(ORDER_BY_DESC);
929 }
930 }
931 }
932 }
933
934 else {
935 query.append(SCProductScreenshotModelImpl.ORDER_BY_JPQL);
936 }
937
938 String sql = query.toString();
939
940 Query q = session.createQuery(sql);
941
942 q.setFirstResult(0);
943 q.setMaxResults(2);
944
945 QueryPos qPos = QueryPos.getInstance(q);
946
947 qPos.add(productEntryId);
948
949 if (orderByComparator != null) {
950 Object[] values = orderByComparator.getOrderByConditionValues(scProductScreenshot);
951
952 for (Object value : values) {
953 qPos.add(value);
954 }
955 }
956
957 List<SCProductScreenshot> list = q.list();
958
959 if (list.size() == 2) {
960 return list.get(1);
961 }
962 else {
963 return null;
964 }
965 }
966
967
975 public SCProductScreenshot findByThumbnailId(long thumbnailId)
976 throws NoSuchProductScreenshotException, SystemException {
977 SCProductScreenshot scProductScreenshot = fetchByThumbnailId(thumbnailId);
978
979 if (scProductScreenshot == null) {
980 StringBundler msg = new StringBundler(4);
981
982 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
983
984 msg.append("thumbnailId=");
985 msg.append(thumbnailId);
986
987 msg.append(StringPool.CLOSE_CURLY_BRACE);
988
989 if (_log.isWarnEnabled()) {
990 _log.warn(msg.toString());
991 }
992
993 throw new NoSuchProductScreenshotException(msg.toString());
994 }
995
996 return scProductScreenshot;
997 }
998
999
1006 public SCProductScreenshot fetchByThumbnailId(long thumbnailId)
1007 throws SystemException {
1008 return fetchByThumbnailId(thumbnailId, true);
1009 }
1010
1011
1019 public SCProductScreenshot fetchByThumbnailId(long thumbnailId,
1020 boolean retrieveFromCache) throws SystemException {
1021 Object[] finderArgs = new Object[] { thumbnailId };
1022
1023 Object result = null;
1024
1025 if (retrieveFromCache) {
1026 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_THUMBNAILID,
1027 finderArgs, this);
1028 }
1029
1030 if (result instanceof SCProductScreenshot) {
1031 SCProductScreenshot scProductScreenshot = (SCProductScreenshot)result;
1032
1033 if ((thumbnailId != scProductScreenshot.getThumbnailId())) {
1034 result = null;
1035 }
1036 }
1037
1038 if (result == null) {
1039 StringBundler query = new StringBundler(3);
1040
1041 query.append(_SQL_SELECT_SCPRODUCTSCREENSHOT_WHERE);
1042
1043 query.append(_FINDER_COLUMN_THUMBNAILID_THUMBNAILID_2);
1044
1045 query.append(SCProductScreenshotModelImpl.ORDER_BY_JPQL);
1046
1047 String sql = query.toString();
1048
1049 Session session = null;
1050
1051 try {
1052 session = openSession();
1053
1054 Query q = session.createQuery(sql);
1055
1056 QueryPos qPos = QueryPos.getInstance(q);
1057
1058 qPos.add(thumbnailId);
1059
1060 List<SCProductScreenshot> list = q.list();
1061
1062 result = list;
1063
1064 SCProductScreenshot scProductScreenshot = null;
1065
1066 if (list.isEmpty()) {
1067 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_THUMBNAILID,
1068 finderArgs, list);
1069 }
1070 else {
1071 scProductScreenshot = list.get(0);
1072
1073 cacheResult(scProductScreenshot);
1074
1075 if ((scProductScreenshot.getThumbnailId() != thumbnailId)) {
1076 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_THUMBNAILID,
1077 finderArgs, scProductScreenshot);
1078 }
1079 }
1080
1081 return scProductScreenshot;
1082 }
1083 catch (Exception e) {
1084 throw processException(e);
1085 }
1086 finally {
1087 if (result == null) {
1088 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_THUMBNAILID,
1089 finderArgs);
1090 }
1091
1092 closeSession(session);
1093 }
1094 }
1095 else {
1096 if (result instanceof List<?>) {
1097 return null;
1098 }
1099 else {
1100 return (SCProductScreenshot)result;
1101 }
1102 }
1103 }
1104
1105
1113 public SCProductScreenshot findByFullImageId(long fullImageId)
1114 throws NoSuchProductScreenshotException, SystemException {
1115 SCProductScreenshot scProductScreenshot = fetchByFullImageId(fullImageId);
1116
1117 if (scProductScreenshot == null) {
1118 StringBundler msg = new StringBundler(4);
1119
1120 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1121
1122 msg.append("fullImageId=");
1123 msg.append(fullImageId);
1124
1125 msg.append(StringPool.CLOSE_CURLY_BRACE);
1126
1127 if (_log.isWarnEnabled()) {
1128 _log.warn(msg.toString());
1129 }
1130
1131 throw new NoSuchProductScreenshotException(msg.toString());
1132 }
1133
1134 return scProductScreenshot;
1135 }
1136
1137
1144 public SCProductScreenshot fetchByFullImageId(long fullImageId)
1145 throws SystemException {
1146 return fetchByFullImageId(fullImageId, true);
1147 }
1148
1149
1157 public SCProductScreenshot fetchByFullImageId(long fullImageId,
1158 boolean retrieveFromCache) throws SystemException {
1159 Object[] finderArgs = new Object[] { fullImageId };
1160
1161 Object result = null;
1162
1163 if (retrieveFromCache) {
1164 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_FULLIMAGEID,
1165 finderArgs, this);
1166 }
1167
1168 if (result instanceof SCProductScreenshot) {
1169 SCProductScreenshot scProductScreenshot = (SCProductScreenshot)result;
1170
1171 if ((fullImageId != scProductScreenshot.getFullImageId())) {
1172 result = null;
1173 }
1174 }
1175
1176 if (result == null) {
1177 StringBundler query = new StringBundler(3);
1178
1179 query.append(_SQL_SELECT_SCPRODUCTSCREENSHOT_WHERE);
1180
1181 query.append(_FINDER_COLUMN_FULLIMAGEID_FULLIMAGEID_2);
1182
1183 query.append(SCProductScreenshotModelImpl.ORDER_BY_JPQL);
1184
1185 String sql = query.toString();
1186
1187 Session session = null;
1188
1189 try {
1190 session = openSession();
1191
1192 Query q = session.createQuery(sql);
1193
1194 QueryPos qPos = QueryPos.getInstance(q);
1195
1196 qPos.add(fullImageId);
1197
1198 List<SCProductScreenshot> list = q.list();
1199
1200 result = list;
1201
1202 SCProductScreenshot scProductScreenshot = null;
1203
1204 if (list.isEmpty()) {
1205 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_FULLIMAGEID,
1206 finderArgs, list);
1207 }
1208 else {
1209 scProductScreenshot = list.get(0);
1210
1211 cacheResult(scProductScreenshot);
1212
1213 if ((scProductScreenshot.getFullImageId() != fullImageId)) {
1214 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_FULLIMAGEID,
1215 finderArgs, scProductScreenshot);
1216 }
1217 }
1218
1219 return scProductScreenshot;
1220 }
1221 catch (Exception e) {
1222 throw processException(e);
1223 }
1224 finally {
1225 if (result == null) {
1226 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_FULLIMAGEID,
1227 finderArgs);
1228 }
1229
1230 closeSession(session);
1231 }
1232 }
1233 else {
1234 if (result instanceof List<?>) {
1235 return null;
1236 }
1237 else {
1238 return (SCProductScreenshot)result;
1239 }
1240 }
1241 }
1242
1243
1252 public SCProductScreenshot findByP_P(long productEntryId, int priority)
1253 throws NoSuchProductScreenshotException, SystemException {
1254 SCProductScreenshot scProductScreenshot = fetchByP_P(productEntryId,
1255 priority);
1256
1257 if (scProductScreenshot == null) {
1258 StringBundler msg = new StringBundler(6);
1259
1260 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1261
1262 msg.append("productEntryId=");
1263 msg.append(productEntryId);
1264
1265 msg.append(", priority=");
1266 msg.append(priority);
1267
1268 msg.append(StringPool.CLOSE_CURLY_BRACE);
1269
1270 if (_log.isWarnEnabled()) {
1271 _log.warn(msg.toString());
1272 }
1273
1274 throw new NoSuchProductScreenshotException(msg.toString());
1275 }
1276
1277 return scProductScreenshot;
1278 }
1279
1280
1288 public SCProductScreenshot fetchByP_P(long productEntryId, int priority)
1289 throws SystemException {
1290 return fetchByP_P(productEntryId, priority, true);
1291 }
1292
1293
1302 public SCProductScreenshot fetchByP_P(long productEntryId, int priority,
1303 boolean retrieveFromCache) throws SystemException {
1304 Object[] finderArgs = new Object[] { productEntryId, priority };
1305
1306 Object result = null;
1307
1308 if (retrieveFromCache) {
1309 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_P_P,
1310 finderArgs, this);
1311 }
1312
1313 if (result instanceof SCProductScreenshot) {
1314 SCProductScreenshot scProductScreenshot = (SCProductScreenshot)result;
1315
1316 if ((productEntryId != scProductScreenshot.getProductEntryId()) ||
1317 (priority != scProductScreenshot.getPriority())) {
1318 result = null;
1319 }
1320 }
1321
1322 if (result == null) {
1323 StringBundler query = new StringBundler(4);
1324
1325 query.append(_SQL_SELECT_SCPRODUCTSCREENSHOT_WHERE);
1326
1327 query.append(_FINDER_COLUMN_P_P_PRODUCTENTRYID_2);
1328
1329 query.append(_FINDER_COLUMN_P_P_PRIORITY_2);
1330
1331 query.append(SCProductScreenshotModelImpl.ORDER_BY_JPQL);
1332
1333 String sql = query.toString();
1334
1335 Session session = null;
1336
1337 try {
1338 session = openSession();
1339
1340 Query q = session.createQuery(sql);
1341
1342 QueryPos qPos = QueryPos.getInstance(q);
1343
1344 qPos.add(productEntryId);
1345
1346 qPos.add(priority);
1347
1348 List<SCProductScreenshot> list = q.list();
1349
1350 result = list;
1351
1352 SCProductScreenshot scProductScreenshot = null;
1353
1354 if (list.isEmpty()) {
1355 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_P,
1356 finderArgs, list);
1357 }
1358 else {
1359 scProductScreenshot = list.get(0);
1360
1361 cacheResult(scProductScreenshot);
1362
1363 if ((scProductScreenshot.getProductEntryId() != productEntryId) ||
1364 (scProductScreenshot.getPriority() != priority)) {
1365 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_P,
1366 finderArgs, scProductScreenshot);
1367 }
1368 }
1369
1370 return scProductScreenshot;
1371 }
1372 catch (Exception e) {
1373 throw processException(e);
1374 }
1375 finally {
1376 if (result == null) {
1377 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_P,
1378 finderArgs);
1379 }
1380
1381 closeSession(session);
1382 }
1383 }
1384 else {
1385 if (result instanceof List<?>) {
1386 return null;
1387 }
1388 else {
1389 return (SCProductScreenshot)result;
1390 }
1391 }
1392 }
1393
1394
1400 public List<SCProductScreenshot> findAll() throws SystemException {
1401 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1402 }
1403
1404
1416 public List<SCProductScreenshot> findAll(int start, int end)
1417 throws SystemException {
1418 return findAll(start, end, null);
1419 }
1420
1421
1434 public List<SCProductScreenshot> findAll(int start, int end,
1435 OrderByComparator orderByComparator) throws SystemException {
1436 FinderPath finderPath = null;
1437 Object[] finderArgs = new Object[] { start, end, orderByComparator };
1438
1439 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1440 (orderByComparator == null)) {
1441 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1442 finderArgs = FINDER_ARGS_EMPTY;
1443 }
1444 else {
1445 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1446 finderArgs = new Object[] { start, end, orderByComparator };
1447 }
1448
1449 List<SCProductScreenshot> list = (List<SCProductScreenshot>)FinderCacheUtil.getResult(finderPath,
1450 finderArgs, this);
1451
1452 if (list == null) {
1453 StringBundler query = null;
1454 String sql = null;
1455
1456 if (orderByComparator != null) {
1457 query = new StringBundler(2 +
1458 (orderByComparator.getOrderByFields().length * 3));
1459
1460 query.append(_SQL_SELECT_SCPRODUCTSCREENSHOT);
1461
1462 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1463 orderByComparator);
1464
1465 sql = query.toString();
1466 }
1467 else {
1468 sql = _SQL_SELECT_SCPRODUCTSCREENSHOT.concat(SCProductScreenshotModelImpl.ORDER_BY_JPQL);
1469 }
1470
1471 Session session = null;
1472
1473 try {
1474 session = openSession();
1475
1476 Query q = session.createQuery(sql);
1477
1478 if (orderByComparator == null) {
1479 list = (List<SCProductScreenshot>)QueryUtil.list(q,
1480 getDialect(), start, end, false);
1481
1482 Collections.sort(list);
1483 }
1484 else {
1485 list = (List<SCProductScreenshot>)QueryUtil.list(q,
1486 getDialect(), start, end);
1487 }
1488 }
1489 catch (Exception e) {
1490 throw processException(e);
1491 }
1492 finally {
1493 if (list == null) {
1494 FinderCacheUtil.removeResult(finderPath, finderArgs);
1495 }
1496 else {
1497 cacheResult(list);
1498
1499 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1500 }
1501
1502 closeSession(session);
1503 }
1504 }
1505
1506 return list;
1507 }
1508
1509
1515 public void removeByProductEntryId(long productEntryId)
1516 throws SystemException {
1517 for (SCProductScreenshot scProductScreenshot : findByProductEntryId(
1518 productEntryId)) {
1519 remove(scProductScreenshot);
1520 }
1521 }
1522
1523
1529 public void removeByThumbnailId(long thumbnailId)
1530 throws NoSuchProductScreenshotException, SystemException {
1531 SCProductScreenshot scProductScreenshot = findByThumbnailId(thumbnailId);
1532
1533 remove(scProductScreenshot);
1534 }
1535
1536
1542 public void removeByFullImageId(long fullImageId)
1543 throws NoSuchProductScreenshotException, SystemException {
1544 SCProductScreenshot scProductScreenshot = findByFullImageId(fullImageId);
1545
1546 remove(scProductScreenshot);
1547 }
1548
1549
1556 public void removeByP_P(long productEntryId, int priority)
1557 throws NoSuchProductScreenshotException, SystemException {
1558 SCProductScreenshot scProductScreenshot = findByP_P(productEntryId,
1559 priority);
1560
1561 remove(scProductScreenshot);
1562 }
1563
1564
1569 public void removeAll() throws SystemException {
1570 for (SCProductScreenshot scProductScreenshot : findAll()) {
1571 remove(scProductScreenshot);
1572 }
1573 }
1574
1575
1582 public int countByProductEntryId(long productEntryId)
1583 throws SystemException {
1584 Object[] finderArgs = new Object[] { productEntryId };
1585
1586 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PRODUCTENTRYID,
1587 finderArgs, this);
1588
1589 if (count == null) {
1590 StringBundler query = new StringBundler(2);
1591
1592 query.append(_SQL_COUNT_SCPRODUCTSCREENSHOT_WHERE);
1593
1594 query.append(_FINDER_COLUMN_PRODUCTENTRYID_PRODUCTENTRYID_2);
1595
1596 String sql = query.toString();
1597
1598 Session session = null;
1599
1600 try {
1601 session = openSession();
1602
1603 Query q = session.createQuery(sql);
1604
1605 QueryPos qPos = QueryPos.getInstance(q);
1606
1607 qPos.add(productEntryId);
1608
1609 count = (Long)q.uniqueResult();
1610 }
1611 catch (Exception e) {
1612 throw processException(e);
1613 }
1614 finally {
1615 if (count == null) {
1616 count = Long.valueOf(0);
1617 }
1618
1619 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PRODUCTENTRYID,
1620 finderArgs, count);
1621
1622 closeSession(session);
1623 }
1624 }
1625
1626 return count.intValue();
1627 }
1628
1629
1636 public int countByThumbnailId(long thumbnailId) throws SystemException {
1637 Object[] finderArgs = new Object[] { thumbnailId };
1638
1639 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_THUMBNAILID,
1640 finderArgs, this);
1641
1642 if (count == null) {
1643 StringBundler query = new StringBundler(2);
1644
1645 query.append(_SQL_COUNT_SCPRODUCTSCREENSHOT_WHERE);
1646
1647 query.append(_FINDER_COLUMN_THUMBNAILID_THUMBNAILID_2);
1648
1649 String sql = query.toString();
1650
1651 Session session = null;
1652
1653 try {
1654 session = openSession();
1655
1656 Query q = session.createQuery(sql);
1657
1658 QueryPos qPos = QueryPos.getInstance(q);
1659
1660 qPos.add(thumbnailId);
1661
1662 count = (Long)q.uniqueResult();
1663 }
1664 catch (Exception e) {
1665 throw processException(e);
1666 }
1667 finally {
1668 if (count == null) {
1669 count = Long.valueOf(0);
1670 }
1671
1672 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_THUMBNAILID,
1673 finderArgs, count);
1674
1675 closeSession(session);
1676 }
1677 }
1678
1679 return count.intValue();
1680 }
1681
1682
1689 public int countByFullImageId(long fullImageId) throws SystemException {
1690 Object[] finderArgs = new Object[] { fullImageId };
1691
1692 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_FULLIMAGEID,
1693 finderArgs, this);
1694
1695 if (count == null) {
1696 StringBundler query = new StringBundler(2);
1697
1698 query.append(_SQL_COUNT_SCPRODUCTSCREENSHOT_WHERE);
1699
1700 query.append(_FINDER_COLUMN_FULLIMAGEID_FULLIMAGEID_2);
1701
1702 String sql = query.toString();
1703
1704 Session session = null;
1705
1706 try {
1707 session = openSession();
1708
1709 Query q = session.createQuery(sql);
1710
1711 QueryPos qPos = QueryPos.getInstance(q);
1712
1713 qPos.add(fullImageId);
1714
1715 count = (Long)q.uniqueResult();
1716 }
1717 catch (Exception e) {
1718 throw processException(e);
1719 }
1720 finally {
1721 if (count == null) {
1722 count = Long.valueOf(0);
1723 }
1724
1725 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_FULLIMAGEID,
1726 finderArgs, count);
1727
1728 closeSession(session);
1729 }
1730 }
1731
1732 return count.intValue();
1733 }
1734
1735
1743 public int countByP_P(long productEntryId, int priority)
1744 throws SystemException {
1745 Object[] finderArgs = new Object[] { productEntryId, priority };
1746
1747 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_P,
1748 finderArgs, this);
1749
1750 if (count == null) {
1751 StringBundler query = new StringBundler(3);
1752
1753 query.append(_SQL_COUNT_SCPRODUCTSCREENSHOT_WHERE);
1754
1755 query.append(_FINDER_COLUMN_P_P_PRODUCTENTRYID_2);
1756
1757 query.append(_FINDER_COLUMN_P_P_PRIORITY_2);
1758
1759 String sql = query.toString();
1760
1761 Session session = null;
1762
1763 try {
1764 session = openSession();
1765
1766 Query q = session.createQuery(sql);
1767
1768 QueryPos qPos = QueryPos.getInstance(q);
1769
1770 qPos.add(productEntryId);
1771
1772 qPos.add(priority);
1773
1774 count = (Long)q.uniqueResult();
1775 }
1776 catch (Exception e) {
1777 throw processException(e);
1778 }
1779 finally {
1780 if (count == null) {
1781 count = Long.valueOf(0);
1782 }
1783
1784 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_P, finderArgs,
1785 count);
1786
1787 closeSession(session);
1788 }
1789 }
1790
1791 return count.intValue();
1792 }
1793
1794
1800 public int countAll() throws SystemException {
1801 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1802 FINDER_ARGS_EMPTY, this);
1803
1804 if (count == null) {
1805 Session session = null;
1806
1807 try {
1808 session = openSession();
1809
1810 Query q = session.createQuery(_SQL_COUNT_SCPRODUCTSCREENSHOT);
1811
1812 count = (Long)q.uniqueResult();
1813 }
1814 catch (Exception e) {
1815 throw processException(e);
1816 }
1817 finally {
1818 if (count == null) {
1819 count = Long.valueOf(0);
1820 }
1821
1822 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1823 FINDER_ARGS_EMPTY, count);
1824
1825 closeSession(session);
1826 }
1827 }
1828
1829 return count.intValue();
1830 }
1831
1832
1835 public void afterPropertiesSet() {
1836 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1837 com.liferay.portal.util.PropsUtil.get(
1838 "value.object.listener.com.liferay.portlet.softwarecatalog.model.SCProductScreenshot")));
1839
1840 if (listenerClassNames.length > 0) {
1841 try {
1842 List<ModelListener<SCProductScreenshot>> listenersList = new ArrayList<ModelListener<SCProductScreenshot>>();
1843
1844 for (String listenerClassName : listenerClassNames) {
1845 listenersList.add((ModelListener<SCProductScreenshot>)InstanceFactory.newInstance(
1846 listenerClassName));
1847 }
1848
1849 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1850 }
1851 catch (Exception e) {
1852 _log.error(e);
1853 }
1854 }
1855 }
1856
1857 public void destroy() {
1858 EntityCacheUtil.removeCache(SCProductScreenshotImpl.class.getName());
1859 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1860 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1861 }
1862
1863 @BeanReference(type = SCFrameworkVersionPersistence.class)
1864 protected SCFrameworkVersionPersistence scFrameworkVersionPersistence;
1865 @BeanReference(type = SCLicensePersistence.class)
1866 protected SCLicensePersistence scLicensePersistence;
1867 @BeanReference(type = SCProductEntryPersistence.class)
1868 protected SCProductEntryPersistence scProductEntryPersistence;
1869 @BeanReference(type = SCProductScreenshotPersistence.class)
1870 protected SCProductScreenshotPersistence scProductScreenshotPersistence;
1871 @BeanReference(type = SCProductVersionPersistence.class)
1872 protected SCProductVersionPersistence scProductVersionPersistence;
1873 @BeanReference(type = ImagePersistence.class)
1874 protected ImagePersistence imagePersistence;
1875 @BeanReference(type = ResourcePersistence.class)
1876 protected ResourcePersistence resourcePersistence;
1877 @BeanReference(type = UserPersistence.class)
1878 protected UserPersistence userPersistence;
1879 private static final String _SQL_SELECT_SCPRODUCTSCREENSHOT = "SELECT scProductScreenshot FROM SCProductScreenshot scProductScreenshot";
1880 private static final String _SQL_SELECT_SCPRODUCTSCREENSHOT_WHERE = "SELECT scProductScreenshot FROM SCProductScreenshot scProductScreenshot WHERE ";
1881 private static final String _SQL_COUNT_SCPRODUCTSCREENSHOT = "SELECT COUNT(scProductScreenshot) FROM SCProductScreenshot scProductScreenshot";
1882 private static final String _SQL_COUNT_SCPRODUCTSCREENSHOT_WHERE = "SELECT COUNT(scProductScreenshot) FROM SCProductScreenshot scProductScreenshot WHERE ";
1883 private static final String _FINDER_COLUMN_PRODUCTENTRYID_PRODUCTENTRYID_2 = "scProductScreenshot.productEntryId = ?";
1884 private static final String _FINDER_COLUMN_THUMBNAILID_THUMBNAILID_2 = "scProductScreenshot.thumbnailId = ?";
1885 private static final String _FINDER_COLUMN_FULLIMAGEID_FULLIMAGEID_2 = "scProductScreenshot.fullImageId = ?";
1886 private static final String _FINDER_COLUMN_P_P_PRODUCTENTRYID_2 = "scProductScreenshot.productEntryId = ? AND ";
1887 private static final String _FINDER_COLUMN_P_P_PRIORITY_2 = "scProductScreenshot.priority = ?";
1888 private static final String _ORDER_BY_ENTITY_ALIAS = "scProductScreenshot.";
1889 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SCProductScreenshot exists with the primary key ";
1890 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SCProductScreenshot exists with the key {";
1891 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1892 private static Log _log = LogFactoryUtil.getLog(SCProductScreenshotPersistenceImpl.class);
1893 private static SCProductScreenshot _nullSCProductScreenshot = new SCProductScreenshotImpl() {
1894 @Override
1895 public Object clone() {
1896 return this;
1897 }
1898
1899 @Override
1900 public CacheModel<SCProductScreenshot> toCacheModel() {
1901 return _nullSCProductScreenshotCacheModel;
1902 }
1903 };
1904
1905 private static CacheModel<SCProductScreenshot> _nullSCProductScreenshotCacheModel =
1906 new CacheModel<SCProductScreenshot>() {
1907 public SCProductScreenshot toEntityModel() {
1908 return _nullSCProductScreenshot;
1909 }
1910 };
1911 }