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