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_WITHOUT_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_WITH_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
380 else {
381 if ((scProductScreenshotModelImpl.getColumnBitmask() &
382 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PRODUCTENTRYID.getColumnBitmask()) != 0) {
383 Object[] args = new Object[] {
384 Long.valueOf(scProductScreenshotModelImpl.getOriginalProductEntryId())
385 };
386
387 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PRODUCTENTRYID,
388 args);
389 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PRODUCTENTRYID,
390 args);
391
392 args = new Object[] {
393 Long.valueOf(scProductScreenshotModelImpl.getProductEntryId())
394 };
395
396 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PRODUCTENTRYID,
397 args);
398 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PRODUCTENTRYID,
399 args);
400 }
401 }
402
403 EntityCacheUtil.putResult(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
404 SCProductScreenshotImpl.class, scProductScreenshot.getPrimaryKey(),
405 scProductScreenshot);
406
407 if (isNew) {
408 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_THUMBNAILID,
409 new Object[] { Long.valueOf(
410 scProductScreenshot.getThumbnailId()) },
411 scProductScreenshot);
412
413 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_FULLIMAGEID,
414 new Object[] { Long.valueOf(
415 scProductScreenshot.getFullImageId()) },
416 scProductScreenshot);
417
418 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_P,
419 new Object[] {
420 Long.valueOf(scProductScreenshot.getProductEntryId()),
421 Integer.valueOf(scProductScreenshot.getPriority())
422 }, scProductScreenshot);
423 }
424 else {
425 if ((scProductScreenshotModelImpl.getColumnBitmask() &
426 FINDER_PATH_FETCH_BY_THUMBNAILID.getColumnBitmask()) != 0) {
427 Object[] args = new Object[] {
428 Long.valueOf(scProductScreenshotModelImpl.getOriginalThumbnailId())
429 };
430
431 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_THUMBNAILID,
432 args);
433 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_THUMBNAILID,
434 args);
435
436 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_THUMBNAILID,
437 new Object[] {
438 Long.valueOf(scProductScreenshot.getThumbnailId())
439 }, scProductScreenshot);
440 }
441
442 if ((scProductScreenshotModelImpl.getColumnBitmask() &
443 FINDER_PATH_FETCH_BY_FULLIMAGEID.getColumnBitmask()) != 0) {
444 Object[] args = new Object[] {
445 Long.valueOf(scProductScreenshotModelImpl.getOriginalFullImageId())
446 };
447
448 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FULLIMAGEID,
449 args);
450 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_FULLIMAGEID,
451 args);
452
453 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_FULLIMAGEID,
454 new Object[] {
455 Long.valueOf(scProductScreenshot.getFullImageId())
456 }, scProductScreenshot);
457 }
458
459 if ((scProductScreenshotModelImpl.getColumnBitmask() &
460 FINDER_PATH_FETCH_BY_P_P.getColumnBitmask()) != 0) {
461 Object[] args = new Object[] {
462 Long.valueOf(scProductScreenshotModelImpl.getOriginalProductEntryId()),
463 Integer.valueOf(scProductScreenshotModelImpl.getOriginalPriority())
464 };
465
466 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_P, args);
467 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_P, args);
468
469 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_P,
470 new Object[] {
471 Long.valueOf(scProductScreenshot.getProductEntryId()),
472 Integer.valueOf(scProductScreenshot.getPriority())
473 }, scProductScreenshot);
474 }
475 }
476
477 return scProductScreenshot;
478 }
479
480 protected SCProductScreenshot toUnwrappedModel(
481 SCProductScreenshot scProductScreenshot) {
482 if (scProductScreenshot instanceof SCProductScreenshotImpl) {
483 return scProductScreenshot;
484 }
485
486 SCProductScreenshotImpl scProductScreenshotImpl = new SCProductScreenshotImpl();
487
488 scProductScreenshotImpl.setNew(scProductScreenshot.isNew());
489 scProductScreenshotImpl.setPrimaryKey(scProductScreenshot.getPrimaryKey());
490
491 scProductScreenshotImpl.setProductScreenshotId(scProductScreenshot.getProductScreenshotId());
492 scProductScreenshotImpl.setCompanyId(scProductScreenshot.getCompanyId());
493 scProductScreenshotImpl.setGroupId(scProductScreenshot.getGroupId());
494 scProductScreenshotImpl.setProductEntryId(scProductScreenshot.getProductEntryId());
495 scProductScreenshotImpl.setThumbnailId(scProductScreenshot.getThumbnailId());
496 scProductScreenshotImpl.setFullImageId(scProductScreenshot.getFullImageId());
497 scProductScreenshotImpl.setPriority(scProductScreenshot.getPriority());
498
499 return scProductScreenshotImpl;
500 }
501
502
510 @Override
511 public SCProductScreenshot findByPrimaryKey(Serializable primaryKey)
512 throws NoSuchModelException, SystemException {
513 return findByPrimaryKey(((Long)primaryKey).longValue());
514 }
515
516
524 public SCProductScreenshot findByPrimaryKey(long productScreenshotId)
525 throws NoSuchProductScreenshotException, SystemException {
526 SCProductScreenshot scProductScreenshot = fetchByPrimaryKey(productScreenshotId);
527
528 if (scProductScreenshot == null) {
529 if (_log.isWarnEnabled()) {
530 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
531 productScreenshotId);
532 }
533
534 throw new NoSuchProductScreenshotException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
535 productScreenshotId);
536 }
537
538 return scProductScreenshot;
539 }
540
541
548 @Override
549 public SCProductScreenshot fetchByPrimaryKey(Serializable primaryKey)
550 throws SystemException {
551 return fetchByPrimaryKey(((Long)primaryKey).longValue());
552 }
553
554
561 public SCProductScreenshot fetchByPrimaryKey(long productScreenshotId)
562 throws SystemException {
563 SCProductScreenshot scProductScreenshot = (SCProductScreenshot)EntityCacheUtil.getResult(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
564 SCProductScreenshotImpl.class, productScreenshotId);
565
566 if (scProductScreenshot == _nullSCProductScreenshot) {
567 return null;
568 }
569
570 if (scProductScreenshot == null) {
571 Session session = null;
572
573 boolean hasException = false;
574
575 try {
576 session = openSession();
577
578 scProductScreenshot = (SCProductScreenshot)session.get(SCProductScreenshotImpl.class,
579 Long.valueOf(productScreenshotId));
580 }
581 catch (Exception e) {
582 hasException = true;
583
584 throw processException(e);
585 }
586 finally {
587 if (scProductScreenshot != null) {
588 cacheResult(scProductScreenshot);
589 }
590 else if (!hasException) {
591 EntityCacheUtil.putResult(SCProductScreenshotModelImpl.ENTITY_CACHE_ENABLED,
592 SCProductScreenshotImpl.class, productScreenshotId,
593 _nullSCProductScreenshot);
594 }
595
596 closeSession(session);
597 }
598 }
599
600 return scProductScreenshot;
601 }
602
603
610 public List<SCProductScreenshot> findByProductEntryId(long productEntryId)
611 throws SystemException {
612 return findByProductEntryId(productEntryId, QueryUtil.ALL_POS,
613 QueryUtil.ALL_POS, null);
614 }
615
616
629 public List<SCProductScreenshot> findByProductEntryId(long productEntryId,
630 int start, int end) throws SystemException {
631 return findByProductEntryId(productEntryId, start, end, null);
632 }
633
634
648 public List<SCProductScreenshot> findByProductEntryId(long productEntryId,
649 int start, int end, OrderByComparator orderByComparator)
650 throws SystemException {
651 FinderPath finderPath = null;
652 Object[] finderArgs = null;
653
654 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
655 (orderByComparator == null)) {
656 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PRODUCTENTRYID;
657 finderArgs = new Object[] { productEntryId };
658 }
659 else {
660 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PRODUCTENTRYID;
661 finderArgs = new Object[] {
662 productEntryId,
663
664 start, end, orderByComparator
665 };
666 }
667
668 List<SCProductScreenshot> list = (List<SCProductScreenshot>)FinderCacheUtil.getResult(finderPath,
669 finderArgs, this);
670
671 if (list == null) {
672 StringBundler query = null;
673
674 if (orderByComparator != null) {
675 query = new StringBundler(3 +
676 (orderByComparator.getOrderByFields().length * 3));
677 }
678 else {
679 query = new StringBundler(3);
680 }
681
682 query.append(_SQL_SELECT_SCPRODUCTSCREENSHOT_WHERE);
683
684 query.append(_FINDER_COLUMN_PRODUCTENTRYID_PRODUCTENTRYID_2);
685
686 if (orderByComparator != null) {
687 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
688 orderByComparator);
689 }
690
691 else {
692 query.append(SCProductScreenshotModelImpl.ORDER_BY_JPQL);
693 }
694
695 String sql = query.toString();
696
697 Session session = null;
698
699 try {
700 session = openSession();
701
702 Query q = session.createQuery(sql);
703
704 QueryPos qPos = QueryPos.getInstance(q);
705
706 qPos.add(productEntryId);
707
708 list = (List<SCProductScreenshot>)QueryUtil.list(q,
709 getDialect(), start, end);
710 }
711 catch (Exception e) {
712 throw processException(e);
713 }
714 finally {
715 if (list == null) {
716 FinderCacheUtil.removeResult(finderPath, finderArgs);
717 }
718 else {
719 cacheResult(list);
720
721 FinderCacheUtil.putResult(finderPath, finderArgs, list);
722 }
723
724 closeSession(session);
725 }
726 }
727
728 return list;
729 }
730
731
744 public SCProductScreenshot findByProductEntryId_First(long productEntryId,
745 OrderByComparator orderByComparator)
746 throws NoSuchProductScreenshotException, SystemException {
747 List<SCProductScreenshot> list = findByProductEntryId(productEntryId,
748 0, 1, orderByComparator);
749
750 if (list.isEmpty()) {
751 StringBundler msg = new StringBundler(4);
752
753 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
754
755 msg.append("productEntryId=");
756 msg.append(productEntryId);
757
758 msg.append(StringPool.CLOSE_CURLY_BRACE);
759
760 throw new NoSuchProductScreenshotException(msg.toString());
761 }
762 else {
763 return list.get(0);
764 }
765 }
766
767
780 public SCProductScreenshot findByProductEntryId_Last(long productEntryId,
781 OrderByComparator orderByComparator)
782 throws NoSuchProductScreenshotException, SystemException {
783 int count = countByProductEntryId(productEntryId);
784
785 List<SCProductScreenshot> list = findByProductEntryId(productEntryId,
786 count - 1, count, orderByComparator);
787
788 if (list.isEmpty()) {
789 StringBundler msg = new StringBundler(4);
790
791 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
792
793 msg.append("productEntryId=");
794 msg.append(productEntryId);
795
796 msg.append(StringPool.CLOSE_CURLY_BRACE);
797
798 throw new NoSuchProductScreenshotException(msg.toString());
799 }
800 else {
801 return list.get(0);
802 }
803 }
804
805
819 public SCProductScreenshot[] findByProductEntryId_PrevAndNext(
820 long productScreenshotId, long productEntryId,
821 OrderByComparator orderByComparator)
822 throws NoSuchProductScreenshotException, SystemException {
823 SCProductScreenshot scProductScreenshot = findByPrimaryKey(productScreenshotId);
824
825 Session session = null;
826
827 try {
828 session = openSession();
829
830 SCProductScreenshot[] array = new SCProductScreenshotImpl[3];
831
832 array[0] = getByProductEntryId_PrevAndNext(session,
833 scProductScreenshot, productEntryId, orderByComparator, true);
834
835 array[1] = scProductScreenshot;
836
837 array[2] = getByProductEntryId_PrevAndNext(session,
838 scProductScreenshot, productEntryId, orderByComparator,
839 false);
840
841 return array;
842 }
843 catch (Exception e) {
844 throw processException(e);
845 }
846 finally {
847 closeSession(session);
848 }
849 }
850
851 protected SCProductScreenshot getByProductEntryId_PrevAndNext(
852 Session session, SCProductScreenshot scProductScreenshot,
853 long productEntryId, OrderByComparator orderByComparator,
854 boolean previous) {
855 StringBundler query = null;
856
857 if (orderByComparator != null) {
858 query = new StringBundler(6 +
859 (orderByComparator.getOrderByFields().length * 6));
860 }
861 else {
862 query = new StringBundler(3);
863 }
864
865 query.append(_SQL_SELECT_SCPRODUCTSCREENSHOT_WHERE);
866
867 query.append(_FINDER_COLUMN_PRODUCTENTRYID_PRODUCTENTRYID_2);
868
869 if (orderByComparator != null) {
870 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
871
872 if (orderByConditionFields.length > 0) {
873 query.append(WHERE_AND);
874 }
875
876 for (int i = 0; i < orderByConditionFields.length; i++) {
877 query.append(_ORDER_BY_ENTITY_ALIAS);
878 query.append(orderByConditionFields[i]);
879
880 if ((i + 1) < orderByConditionFields.length) {
881 if (orderByComparator.isAscending() ^ previous) {
882 query.append(WHERE_GREATER_THAN_HAS_NEXT);
883 }
884 else {
885 query.append(WHERE_LESSER_THAN_HAS_NEXT);
886 }
887 }
888 else {
889 if (orderByComparator.isAscending() ^ previous) {
890 query.append(WHERE_GREATER_THAN);
891 }
892 else {
893 query.append(WHERE_LESSER_THAN);
894 }
895 }
896 }
897
898 query.append(ORDER_BY_CLAUSE);
899
900 String[] orderByFields = orderByComparator.getOrderByFields();
901
902 for (int i = 0; i < orderByFields.length; i++) {
903 query.append(_ORDER_BY_ENTITY_ALIAS);
904 query.append(orderByFields[i]);
905
906 if ((i + 1) < orderByFields.length) {
907 if (orderByComparator.isAscending() ^ previous) {
908 query.append(ORDER_BY_ASC_HAS_NEXT);
909 }
910 else {
911 query.append(ORDER_BY_DESC_HAS_NEXT);
912 }
913 }
914 else {
915 if (orderByComparator.isAscending() ^ previous) {
916 query.append(ORDER_BY_ASC);
917 }
918 else {
919 query.append(ORDER_BY_DESC);
920 }
921 }
922 }
923 }
924
925 else {
926 query.append(SCProductScreenshotModelImpl.ORDER_BY_JPQL);
927 }
928
929 String sql = query.toString();
930
931 Query q = session.createQuery(sql);
932
933 q.setFirstResult(0);
934 q.setMaxResults(2);
935
936 QueryPos qPos = QueryPos.getInstance(q);
937
938 qPos.add(productEntryId);
939
940 if (orderByComparator != null) {
941 Object[] values = orderByComparator.getOrderByConditionValues(scProductScreenshot);
942
943 for (Object value : values) {
944 qPos.add(value);
945 }
946 }
947
948 List<SCProductScreenshot> list = q.list();
949
950 if (list.size() == 2) {
951 return list.get(1);
952 }
953 else {
954 return null;
955 }
956 }
957
958
966 public SCProductScreenshot findByThumbnailId(long thumbnailId)
967 throws NoSuchProductScreenshotException, SystemException {
968 SCProductScreenshot scProductScreenshot = fetchByThumbnailId(thumbnailId);
969
970 if (scProductScreenshot == null) {
971 StringBundler msg = new StringBundler(4);
972
973 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
974
975 msg.append("thumbnailId=");
976 msg.append(thumbnailId);
977
978 msg.append(StringPool.CLOSE_CURLY_BRACE);
979
980 if (_log.isWarnEnabled()) {
981 _log.warn(msg.toString());
982 }
983
984 throw new NoSuchProductScreenshotException(msg.toString());
985 }
986
987 return scProductScreenshot;
988 }
989
990
997 public SCProductScreenshot fetchByThumbnailId(long thumbnailId)
998 throws SystemException {
999 return fetchByThumbnailId(thumbnailId, true);
1000 }
1001
1002
1010 public SCProductScreenshot fetchByThumbnailId(long thumbnailId,
1011 boolean retrieveFromCache) throws SystemException {
1012 Object[] finderArgs = new Object[] { thumbnailId };
1013
1014 Object result = null;
1015
1016 if (retrieveFromCache) {
1017 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_THUMBNAILID,
1018 finderArgs, this);
1019 }
1020
1021 if (result == null) {
1022 StringBundler query = new StringBundler(3);
1023
1024 query.append(_SQL_SELECT_SCPRODUCTSCREENSHOT_WHERE);
1025
1026 query.append(_FINDER_COLUMN_THUMBNAILID_THUMBNAILID_2);
1027
1028 query.append(SCProductScreenshotModelImpl.ORDER_BY_JPQL);
1029
1030 String sql = query.toString();
1031
1032 Session session = null;
1033
1034 try {
1035 session = openSession();
1036
1037 Query q = session.createQuery(sql);
1038
1039 QueryPos qPos = QueryPos.getInstance(q);
1040
1041 qPos.add(thumbnailId);
1042
1043 List<SCProductScreenshot> list = q.list();
1044
1045 result = list;
1046
1047 SCProductScreenshot scProductScreenshot = null;
1048
1049 if (list.isEmpty()) {
1050 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_THUMBNAILID,
1051 finderArgs, list);
1052 }
1053 else {
1054 scProductScreenshot = list.get(0);
1055
1056 cacheResult(scProductScreenshot);
1057
1058 if ((scProductScreenshot.getThumbnailId() != thumbnailId)) {
1059 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_THUMBNAILID,
1060 finderArgs, scProductScreenshot);
1061 }
1062 }
1063
1064 return scProductScreenshot;
1065 }
1066 catch (Exception e) {
1067 throw processException(e);
1068 }
1069 finally {
1070 if (result == null) {
1071 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_THUMBNAILID,
1072 finderArgs);
1073 }
1074
1075 closeSession(session);
1076 }
1077 }
1078 else {
1079 if (result instanceof List<?>) {
1080 return null;
1081 }
1082 else {
1083 return (SCProductScreenshot)result;
1084 }
1085 }
1086 }
1087
1088
1096 public SCProductScreenshot findByFullImageId(long fullImageId)
1097 throws NoSuchProductScreenshotException, SystemException {
1098 SCProductScreenshot scProductScreenshot = fetchByFullImageId(fullImageId);
1099
1100 if (scProductScreenshot == null) {
1101 StringBundler msg = new StringBundler(4);
1102
1103 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1104
1105 msg.append("fullImageId=");
1106 msg.append(fullImageId);
1107
1108 msg.append(StringPool.CLOSE_CURLY_BRACE);
1109
1110 if (_log.isWarnEnabled()) {
1111 _log.warn(msg.toString());
1112 }
1113
1114 throw new NoSuchProductScreenshotException(msg.toString());
1115 }
1116
1117 return scProductScreenshot;
1118 }
1119
1120
1127 public SCProductScreenshot fetchByFullImageId(long fullImageId)
1128 throws SystemException {
1129 return fetchByFullImageId(fullImageId, true);
1130 }
1131
1132
1140 public SCProductScreenshot fetchByFullImageId(long fullImageId,
1141 boolean retrieveFromCache) throws SystemException {
1142 Object[] finderArgs = new Object[] { fullImageId };
1143
1144 Object result = null;
1145
1146 if (retrieveFromCache) {
1147 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_FULLIMAGEID,
1148 finderArgs, this);
1149 }
1150
1151 if (result == null) {
1152 StringBundler query = new StringBundler(3);
1153
1154 query.append(_SQL_SELECT_SCPRODUCTSCREENSHOT_WHERE);
1155
1156 query.append(_FINDER_COLUMN_FULLIMAGEID_FULLIMAGEID_2);
1157
1158 query.append(SCProductScreenshotModelImpl.ORDER_BY_JPQL);
1159
1160 String sql = query.toString();
1161
1162 Session session = null;
1163
1164 try {
1165 session = openSession();
1166
1167 Query q = session.createQuery(sql);
1168
1169 QueryPos qPos = QueryPos.getInstance(q);
1170
1171 qPos.add(fullImageId);
1172
1173 List<SCProductScreenshot> list = q.list();
1174
1175 result = list;
1176
1177 SCProductScreenshot scProductScreenshot = null;
1178
1179 if (list.isEmpty()) {
1180 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_FULLIMAGEID,
1181 finderArgs, list);
1182 }
1183 else {
1184 scProductScreenshot = list.get(0);
1185
1186 cacheResult(scProductScreenshot);
1187
1188 if ((scProductScreenshot.getFullImageId() != fullImageId)) {
1189 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_FULLIMAGEID,
1190 finderArgs, scProductScreenshot);
1191 }
1192 }
1193
1194 return scProductScreenshot;
1195 }
1196 catch (Exception e) {
1197 throw processException(e);
1198 }
1199 finally {
1200 if (result == null) {
1201 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_FULLIMAGEID,
1202 finderArgs);
1203 }
1204
1205 closeSession(session);
1206 }
1207 }
1208 else {
1209 if (result instanceof List<?>) {
1210 return null;
1211 }
1212 else {
1213 return (SCProductScreenshot)result;
1214 }
1215 }
1216 }
1217
1218
1227 public SCProductScreenshot findByP_P(long productEntryId, int priority)
1228 throws NoSuchProductScreenshotException, SystemException {
1229 SCProductScreenshot scProductScreenshot = fetchByP_P(productEntryId,
1230 priority);
1231
1232 if (scProductScreenshot == null) {
1233 StringBundler msg = new StringBundler(6);
1234
1235 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1236
1237 msg.append("productEntryId=");
1238 msg.append(productEntryId);
1239
1240 msg.append(", priority=");
1241 msg.append(priority);
1242
1243 msg.append(StringPool.CLOSE_CURLY_BRACE);
1244
1245 if (_log.isWarnEnabled()) {
1246 _log.warn(msg.toString());
1247 }
1248
1249 throw new NoSuchProductScreenshotException(msg.toString());
1250 }
1251
1252 return scProductScreenshot;
1253 }
1254
1255
1263 public SCProductScreenshot fetchByP_P(long productEntryId, int priority)
1264 throws SystemException {
1265 return fetchByP_P(productEntryId, priority, true);
1266 }
1267
1268
1277 public SCProductScreenshot fetchByP_P(long productEntryId, int priority,
1278 boolean retrieveFromCache) throws SystemException {
1279 Object[] finderArgs = new Object[] { productEntryId, priority };
1280
1281 Object result = null;
1282
1283 if (retrieveFromCache) {
1284 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_P_P,
1285 finderArgs, this);
1286 }
1287
1288 if (result == null) {
1289 StringBundler query = new StringBundler(4);
1290
1291 query.append(_SQL_SELECT_SCPRODUCTSCREENSHOT_WHERE);
1292
1293 query.append(_FINDER_COLUMN_P_P_PRODUCTENTRYID_2);
1294
1295 query.append(_FINDER_COLUMN_P_P_PRIORITY_2);
1296
1297 query.append(SCProductScreenshotModelImpl.ORDER_BY_JPQL);
1298
1299 String sql = query.toString();
1300
1301 Session session = null;
1302
1303 try {
1304 session = openSession();
1305
1306 Query q = session.createQuery(sql);
1307
1308 QueryPos qPos = QueryPos.getInstance(q);
1309
1310 qPos.add(productEntryId);
1311
1312 qPos.add(priority);
1313
1314 List<SCProductScreenshot> list = q.list();
1315
1316 result = list;
1317
1318 SCProductScreenshot scProductScreenshot = null;
1319
1320 if (list.isEmpty()) {
1321 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_P,
1322 finderArgs, list);
1323 }
1324 else {
1325 scProductScreenshot = list.get(0);
1326
1327 cacheResult(scProductScreenshot);
1328
1329 if ((scProductScreenshot.getProductEntryId() != productEntryId) ||
1330 (scProductScreenshot.getPriority() != priority)) {
1331 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_P,
1332 finderArgs, scProductScreenshot);
1333 }
1334 }
1335
1336 return scProductScreenshot;
1337 }
1338 catch (Exception e) {
1339 throw processException(e);
1340 }
1341 finally {
1342 if (result == null) {
1343 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_P,
1344 finderArgs);
1345 }
1346
1347 closeSession(session);
1348 }
1349 }
1350 else {
1351 if (result instanceof List<?>) {
1352 return null;
1353 }
1354 else {
1355 return (SCProductScreenshot)result;
1356 }
1357 }
1358 }
1359
1360
1366 public List<SCProductScreenshot> findAll() throws SystemException {
1367 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1368 }
1369
1370
1382 public List<SCProductScreenshot> findAll(int start, int end)
1383 throws SystemException {
1384 return findAll(start, end, null);
1385 }
1386
1387
1400 public List<SCProductScreenshot> findAll(int start, int end,
1401 OrderByComparator orderByComparator) throws SystemException {
1402 FinderPath finderPath = null;
1403 Object[] finderArgs = new Object[] { start, end, orderByComparator };
1404
1405 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1406 (orderByComparator == null)) {
1407 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1408 finderArgs = FINDER_ARGS_EMPTY;
1409 }
1410 else {
1411 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1412 finderArgs = new Object[] { start, end, orderByComparator };
1413 }
1414
1415 List<SCProductScreenshot> list = (List<SCProductScreenshot>)FinderCacheUtil.getResult(finderPath,
1416 finderArgs, this);
1417
1418 if (list == null) {
1419 StringBundler query = null;
1420 String sql = null;
1421
1422 if (orderByComparator != null) {
1423 query = new StringBundler(2 +
1424 (orderByComparator.getOrderByFields().length * 3));
1425
1426 query.append(_SQL_SELECT_SCPRODUCTSCREENSHOT);
1427
1428 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1429 orderByComparator);
1430
1431 sql = query.toString();
1432 }
1433 else {
1434 sql = _SQL_SELECT_SCPRODUCTSCREENSHOT.concat(SCProductScreenshotModelImpl.ORDER_BY_JPQL);
1435 }
1436
1437 Session session = null;
1438
1439 try {
1440 session = openSession();
1441
1442 Query q = session.createQuery(sql);
1443
1444 if (orderByComparator == null) {
1445 list = (List<SCProductScreenshot>)QueryUtil.list(q,
1446 getDialect(), start, end, false);
1447
1448 Collections.sort(list);
1449 }
1450 else {
1451 list = (List<SCProductScreenshot>)QueryUtil.list(q,
1452 getDialect(), start, end);
1453 }
1454 }
1455 catch (Exception e) {
1456 throw processException(e);
1457 }
1458 finally {
1459 if (list == null) {
1460 FinderCacheUtil.removeResult(finderPath, finderArgs);
1461 }
1462 else {
1463 cacheResult(list);
1464
1465 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1466 }
1467
1468 closeSession(session);
1469 }
1470 }
1471
1472 return list;
1473 }
1474
1475
1481 public void removeByProductEntryId(long productEntryId)
1482 throws SystemException {
1483 for (SCProductScreenshot scProductScreenshot : findByProductEntryId(
1484 productEntryId)) {
1485 remove(scProductScreenshot);
1486 }
1487 }
1488
1489
1495 public void removeByThumbnailId(long thumbnailId)
1496 throws NoSuchProductScreenshotException, SystemException {
1497 SCProductScreenshot scProductScreenshot = findByThumbnailId(thumbnailId);
1498
1499 remove(scProductScreenshot);
1500 }
1501
1502
1508 public void removeByFullImageId(long fullImageId)
1509 throws NoSuchProductScreenshotException, SystemException {
1510 SCProductScreenshot scProductScreenshot = findByFullImageId(fullImageId);
1511
1512 remove(scProductScreenshot);
1513 }
1514
1515
1522 public void removeByP_P(long productEntryId, int priority)
1523 throws NoSuchProductScreenshotException, SystemException {
1524 SCProductScreenshot scProductScreenshot = findByP_P(productEntryId,
1525 priority);
1526
1527 remove(scProductScreenshot);
1528 }
1529
1530
1535 public void removeAll() throws SystemException {
1536 for (SCProductScreenshot scProductScreenshot : findAll()) {
1537 remove(scProductScreenshot);
1538 }
1539 }
1540
1541
1548 public int countByProductEntryId(long productEntryId)
1549 throws SystemException {
1550 Object[] finderArgs = new Object[] { productEntryId };
1551
1552 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PRODUCTENTRYID,
1553 finderArgs, this);
1554
1555 if (count == null) {
1556 StringBundler query = new StringBundler(2);
1557
1558 query.append(_SQL_COUNT_SCPRODUCTSCREENSHOT_WHERE);
1559
1560 query.append(_FINDER_COLUMN_PRODUCTENTRYID_PRODUCTENTRYID_2);
1561
1562 String sql = query.toString();
1563
1564 Session session = null;
1565
1566 try {
1567 session = openSession();
1568
1569 Query q = session.createQuery(sql);
1570
1571 QueryPos qPos = QueryPos.getInstance(q);
1572
1573 qPos.add(productEntryId);
1574
1575 count = (Long)q.uniqueResult();
1576 }
1577 catch (Exception e) {
1578 throw processException(e);
1579 }
1580 finally {
1581 if (count == null) {
1582 count = Long.valueOf(0);
1583 }
1584
1585 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PRODUCTENTRYID,
1586 finderArgs, count);
1587
1588 closeSession(session);
1589 }
1590 }
1591
1592 return count.intValue();
1593 }
1594
1595
1602 public int countByThumbnailId(long thumbnailId) throws SystemException {
1603 Object[] finderArgs = new Object[] { thumbnailId };
1604
1605 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_THUMBNAILID,
1606 finderArgs, this);
1607
1608 if (count == null) {
1609 StringBundler query = new StringBundler(2);
1610
1611 query.append(_SQL_COUNT_SCPRODUCTSCREENSHOT_WHERE);
1612
1613 query.append(_FINDER_COLUMN_THUMBNAILID_THUMBNAILID_2);
1614
1615 String sql = query.toString();
1616
1617 Session session = null;
1618
1619 try {
1620 session = openSession();
1621
1622 Query q = session.createQuery(sql);
1623
1624 QueryPos qPos = QueryPos.getInstance(q);
1625
1626 qPos.add(thumbnailId);
1627
1628 count = (Long)q.uniqueResult();
1629 }
1630 catch (Exception e) {
1631 throw processException(e);
1632 }
1633 finally {
1634 if (count == null) {
1635 count = Long.valueOf(0);
1636 }
1637
1638 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_THUMBNAILID,
1639 finderArgs, count);
1640
1641 closeSession(session);
1642 }
1643 }
1644
1645 return count.intValue();
1646 }
1647
1648
1655 public int countByFullImageId(long fullImageId) throws SystemException {
1656 Object[] finderArgs = new Object[] { fullImageId };
1657
1658 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_FULLIMAGEID,
1659 finderArgs, this);
1660
1661 if (count == null) {
1662 StringBundler query = new StringBundler(2);
1663
1664 query.append(_SQL_COUNT_SCPRODUCTSCREENSHOT_WHERE);
1665
1666 query.append(_FINDER_COLUMN_FULLIMAGEID_FULLIMAGEID_2);
1667
1668 String sql = query.toString();
1669
1670 Session session = null;
1671
1672 try {
1673 session = openSession();
1674
1675 Query q = session.createQuery(sql);
1676
1677 QueryPos qPos = QueryPos.getInstance(q);
1678
1679 qPos.add(fullImageId);
1680
1681 count = (Long)q.uniqueResult();
1682 }
1683 catch (Exception e) {
1684 throw processException(e);
1685 }
1686 finally {
1687 if (count == null) {
1688 count = Long.valueOf(0);
1689 }
1690
1691 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_FULLIMAGEID,
1692 finderArgs, count);
1693
1694 closeSession(session);
1695 }
1696 }
1697
1698 return count.intValue();
1699 }
1700
1701
1709 public int countByP_P(long productEntryId, int priority)
1710 throws SystemException {
1711 Object[] finderArgs = new Object[] { productEntryId, priority };
1712
1713 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_P,
1714 finderArgs, this);
1715
1716 if (count == null) {
1717 StringBundler query = new StringBundler(3);
1718
1719 query.append(_SQL_COUNT_SCPRODUCTSCREENSHOT_WHERE);
1720
1721 query.append(_FINDER_COLUMN_P_P_PRODUCTENTRYID_2);
1722
1723 query.append(_FINDER_COLUMN_P_P_PRIORITY_2);
1724
1725 String sql = query.toString();
1726
1727 Session session = null;
1728
1729 try {
1730 session = openSession();
1731
1732 Query q = session.createQuery(sql);
1733
1734 QueryPos qPos = QueryPos.getInstance(q);
1735
1736 qPos.add(productEntryId);
1737
1738 qPos.add(priority);
1739
1740 count = (Long)q.uniqueResult();
1741 }
1742 catch (Exception e) {
1743 throw processException(e);
1744 }
1745 finally {
1746 if (count == null) {
1747 count = Long.valueOf(0);
1748 }
1749
1750 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_P, finderArgs,
1751 count);
1752
1753 closeSession(session);
1754 }
1755 }
1756
1757 return count.intValue();
1758 }
1759
1760
1766 public int countAll() throws SystemException {
1767 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1768 FINDER_ARGS_EMPTY, this);
1769
1770 if (count == null) {
1771 Session session = null;
1772
1773 try {
1774 session = openSession();
1775
1776 Query q = session.createQuery(_SQL_COUNT_SCPRODUCTSCREENSHOT);
1777
1778 count = (Long)q.uniqueResult();
1779 }
1780 catch (Exception e) {
1781 throw processException(e);
1782 }
1783 finally {
1784 if (count == null) {
1785 count = Long.valueOf(0);
1786 }
1787
1788 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1789 FINDER_ARGS_EMPTY, count);
1790
1791 closeSession(session);
1792 }
1793 }
1794
1795 return count.intValue();
1796 }
1797
1798
1801 public void afterPropertiesSet() {
1802 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1803 com.liferay.portal.util.PropsUtil.get(
1804 "value.object.listener.com.liferay.portlet.softwarecatalog.model.SCProductScreenshot")));
1805
1806 if (listenerClassNames.length > 0) {
1807 try {
1808 List<ModelListener<SCProductScreenshot>> listenersList = new ArrayList<ModelListener<SCProductScreenshot>>();
1809
1810 for (String listenerClassName : listenerClassNames) {
1811 listenersList.add((ModelListener<SCProductScreenshot>)InstanceFactory.newInstance(
1812 listenerClassName));
1813 }
1814
1815 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1816 }
1817 catch (Exception e) {
1818 _log.error(e);
1819 }
1820 }
1821 }
1822
1823 public void destroy() {
1824 EntityCacheUtil.removeCache(SCProductScreenshotImpl.class.getName());
1825 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1826 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1827 }
1828
1829 @BeanReference(type = SCFrameworkVersionPersistence.class)
1830 protected SCFrameworkVersionPersistence scFrameworkVersionPersistence;
1831 @BeanReference(type = SCLicensePersistence.class)
1832 protected SCLicensePersistence scLicensePersistence;
1833 @BeanReference(type = SCProductEntryPersistence.class)
1834 protected SCProductEntryPersistence scProductEntryPersistence;
1835 @BeanReference(type = SCProductScreenshotPersistence.class)
1836 protected SCProductScreenshotPersistence scProductScreenshotPersistence;
1837 @BeanReference(type = SCProductVersionPersistence.class)
1838 protected SCProductVersionPersistence scProductVersionPersistence;
1839 @BeanReference(type = ImagePersistence.class)
1840 protected ImagePersistence imagePersistence;
1841 @BeanReference(type = ResourcePersistence.class)
1842 protected ResourcePersistence resourcePersistence;
1843 @BeanReference(type = UserPersistence.class)
1844 protected UserPersistence userPersistence;
1845 private static final String _SQL_SELECT_SCPRODUCTSCREENSHOT = "SELECT scProductScreenshot FROM SCProductScreenshot scProductScreenshot";
1846 private static final String _SQL_SELECT_SCPRODUCTSCREENSHOT_WHERE = "SELECT scProductScreenshot FROM SCProductScreenshot scProductScreenshot WHERE ";
1847 private static final String _SQL_COUNT_SCPRODUCTSCREENSHOT = "SELECT COUNT(scProductScreenshot) FROM SCProductScreenshot scProductScreenshot";
1848 private static final String _SQL_COUNT_SCPRODUCTSCREENSHOT_WHERE = "SELECT COUNT(scProductScreenshot) FROM SCProductScreenshot scProductScreenshot WHERE ";
1849 private static final String _FINDER_COLUMN_PRODUCTENTRYID_PRODUCTENTRYID_2 = "scProductScreenshot.productEntryId = ?";
1850 private static final String _FINDER_COLUMN_THUMBNAILID_THUMBNAILID_2 = "scProductScreenshot.thumbnailId = ?";
1851 private static final String _FINDER_COLUMN_FULLIMAGEID_FULLIMAGEID_2 = "scProductScreenshot.fullImageId = ?";
1852 private static final String _FINDER_COLUMN_P_P_PRODUCTENTRYID_2 = "scProductScreenshot.productEntryId = ? AND ";
1853 private static final String _FINDER_COLUMN_P_P_PRIORITY_2 = "scProductScreenshot.priority = ?";
1854 private static final String _ORDER_BY_ENTITY_ALIAS = "scProductScreenshot.";
1855 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SCProductScreenshot exists with the primary key ";
1856 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SCProductScreenshot exists with the key {";
1857 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1858 private static Log _log = LogFactoryUtil.getLog(SCProductScreenshotPersistenceImpl.class);
1859 private static SCProductScreenshot _nullSCProductScreenshot = new SCProductScreenshotImpl() {
1860 @Override
1861 public Object clone() {
1862 return this;
1863 }
1864
1865 @Override
1866 public CacheModel<SCProductScreenshot> toCacheModel() {
1867 return _nullSCProductScreenshotCacheModel;
1868 }
1869 };
1870
1871 private static CacheModel<SCProductScreenshot> _nullSCProductScreenshotCacheModel =
1872 new CacheModel<SCProductScreenshot>() {
1873 public SCProductScreenshot toEntityModel() {
1874 return _nullSCProductScreenshot;
1875 }
1876 };
1877 }