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