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.OrderByComparator;
29 import com.liferay.portal.kernel.util.StringMaker;
30 import com.liferay.portal.kernel.util.StringPool;
31 import com.liferay.portal.service.persistence.BasePersistence;
32 import com.liferay.portal.spring.hibernate.FinderCache;
33 import com.liferay.portal.spring.hibernate.HibernateUtil;
34
35 import com.liferay.portlet.softwarecatalog.NoSuchProductVersionException;
36 import com.liferay.portlet.softwarecatalog.model.SCProductVersion;
37 import com.liferay.portlet.softwarecatalog.model.impl.SCProductVersionImpl;
38
39 import com.liferay.util.dao.hibernate.QueryPos;
40 import com.liferay.util.dao.hibernate.QueryUtil;
41
42 import org.apache.commons.logging.Log;
43 import org.apache.commons.logging.LogFactory;
44
45 import org.hibernate.Hibernate;
46 import org.hibernate.Query;
47 import org.hibernate.SQLQuery;
48 import org.hibernate.Session;
49
50 import org.springframework.dao.DataAccessException;
51
52 import org.springframework.jdbc.core.SqlParameter;
53 import org.springframework.jdbc.object.MappingSqlQuery;
54 import org.springframework.jdbc.object.SqlUpdate;
55
56 import java.sql.ResultSet;
57 import java.sql.SQLException;
58 import java.sql.Types;
59
60 import java.util.Collections;
61 import java.util.Iterator;
62 import java.util.List;
63
64
70 public class SCProductVersionPersistenceImpl extends BasePersistence
71 implements SCProductVersionPersistence {
72 public SCProductVersion create(long productVersionId) {
73 SCProductVersion scProductVersion = new SCProductVersionImpl();
74 scProductVersion.setNew(true);
75 scProductVersion.setPrimaryKey(productVersionId);
76
77 return scProductVersion;
78 }
79
80 public SCProductVersion remove(long productVersionId)
81 throws NoSuchProductVersionException, SystemException {
82 Session session = null;
83
84 try {
85 session = openSession();
86
87 SCProductVersion scProductVersion = (SCProductVersion)session.get(SCProductVersionImpl.class,
88 new Long(productVersionId));
89
90 if (scProductVersion == null) {
91 if (_log.isWarnEnabled()) {
92 _log.warn(
93 "No SCProductVersion exists with the primary key " +
94 productVersionId);
95 }
96
97 throw new NoSuchProductVersionException(
98 "No SCProductVersion exists with the primary key " +
99 productVersionId);
100 }
101
102 return remove(scProductVersion);
103 }
104 catch (NoSuchProductVersionException nsee) {
105 throw nsee;
106 }
107 catch (Exception e) {
108 throw HibernateUtil.processException(e);
109 }
110 finally {
111 closeSession(session);
112 }
113 }
114
115 public SCProductVersion remove(SCProductVersion scProductVersion)
116 throws SystemException {
117 try {
118 clearSCFrameworkVersions.clear(scProductVersion.getPrimaryKey());
119 }
120 catch (Exception e) {
121 throw HibernateUtil.processException(e);
122 }
123 finally {
124 FinderCache.clearCache("SCFrameworkVersi_SCProductVers");
125 }
126
127 Session session = null;
128
129 try {
130 session = openSession();
131 session.delete(scProductVersion);
132 session.flush();
133
134 return scProductVersion;
135 }
136 catch (Exception e) {
137 throw HibernateUtil.processException(e);
138 }
139 finally {
140 closeSession(session);
141 FinderCache.clearCache(SCProductVersion.class.getName());
142 }
143 }
144
145 public SCProductVersion update(
146 com.liferay.portlet.softwarecatalog.model.SCProductVersion scProductVersion)
147 throws SystemException {
148 return update(scProductVersion, false);
149 }
150
151 public SCProductVersion update(
152 com.liferay.portlet.softwarecatalog.model.SCProductVersion scProductVersion,
153 boolean merge) throws SystemException {
154 FinderCache.clearCache("SCFrameworkVersi_SCProductVers");
155
156 Session session = null;
157
158 try {
159 session = openSession();
160
161 if (merge) {
162 session.merge(scProductVersion);
163 }
164 else {
165 if (scProductVersion.isNew()) {
166 session.save(scProductVersion);
167 }
168 }
169
170 session.flush();
171 scProductVersion.setNew(false);
172
173 return scProductVersion;
174 }
175 catch (Exception e) {
176 throw HibernateUtil.processException(e);
177 }
178 finally {
179 closeSession(session);
180 FinderCache.clearCache(SCProductVersion.class.getName());
181 }
182 }
183
184 public SCProductVersion findByPrimaryKey(long productVersionId)
185 throws NoSuchProductVersionException, SystemException {
186 SCProductVersion scProductVersion = fetchByPrimaryKey(productVersionId);
187
188 if (scProductVersion == null) {
189 if (_log.isWarnEnabled()) {
190 _log.warn("No SCProductVersion exists with the primary key " +
191 productVersionId);
192 }
193
194 throw new NoSuchProductVersionException(
195 "No SCProductVersion exists with the primary key " +
196 productVersionId);
197 }
198
199 return scProductVersion;
200 }
201
202 public SCProductVersion fetchByPrimaryKey(long productVersionId)
203 throws SystemException {
204 Session session = null;
205
206 try {
207 session = openSession();
208
209 return (SCProductVersion)session.get(SCProductVersionImpl.class,
210 new Long(productVersionId));
211 }
212 catch (Exception e) {
213 throw HibernateUtil.processException(e);
214 }
215 finally {
216 closeSession(session);
217 }
218 }
219
220 public List findByProductEntryId(long productEntryId)
221 throws SystemException {
222 String finderClassName = SCProductVersion.class.getName();
223 String finderMethodName = "findByProductEntryId";
224 String[] finderParams = new String[] { Long.class.getName() };
225 Object[] finderArgs = new Object[] { new Long(productEntryId) };
226 Object result = FinderCache.getResult(finderClassName,
227 finderMethodName, finderParams, finderArgs, getSessionFactory());
228
229 if (result == null) {
230 Session session = null;
231
232 try {
233 session = openSession();
234
235 StringMaker query = new StringMaker();
236 query.append(
237 "FROM com.liferay.portlet.softwarecatalog.model.SCProductVersion WHERE ");
238 query.append("productEntryId = ?");
239 query.append(" ");
240 query.append("ORDER BY ");
241 query.append("createDate DESC");
242
243 Query q = session.createQuery(query.toString());
244 int queryPos = 0;
245 q.setLong(queryPos++, productEntryId);
246
247 List list = q.list();
248 FinderCache.putResult(finderClassName, finderMethodName,
249 finderParams, finderArgs, list);
250
251 return list;
252 }
253 catch (Exception e) {
254 throw HibernateUtil.processException(e);
255 }
256 finally {
257 closeSession(session);
258 }
259 }
260 else {
261 return (List)result;
262 }
263 }
264
265 public List findByProductEntryId(long productEntryId, int begin, int end)
266 throws SystemException {
267 return findByProductEntryId(productEntryId, begin, end, null);
268 }
269
270 public List findByProductEntryId(long productEntryId, int begin, int end,
271 OrderByComparator obc) throws SystemException {
272 String finderClassName = SCProductVersion.class.getName();
273 String finderMethodName = "findByProductEntryId";
274 String[] finderParams = new String[] {
275 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
276 "com.liferay.portal.kernel.util.OrderByComparator"
277 };
278 Object[] finderArgs = new Object[] {
279 new Long(productEntryId), String.valueOf(begin),
280 String.valueOf(end), String.valueOf(obc)
281 };
282 Object result = FinderCache.getResult(finderClassName,
283 finderMethodName, finderParams, finderArgs, getSessionFactory());
284
285 if (result == null) {
286 Session session = null;
287
288 try {
289 session = openSession();
290
291 StringMaker query = new StringMaker();
292 query.append(
293 "FROM com.liferay.portlet.softwarecatalog.model.SCProductVersion WHERE ");
294 query.append("productEntryId = ?");
295 query.append(" ");
296
297 if (obc != null) {
298 query.append("ORDER BY ");
299 query.append(obc.getOrderBy());
300 }
301 else {
302 query.append("ORDER BY ");
303 query.append("createDate DESC");
304 }
305
306 Query q = session.createQuery(query.toString());
307 int queryPos = 0;
308 q.setLong(queryPos++, productEntryId);
309
310 List list = QueryUtil.list(q, getDialect(), begin, end);
311 FinderCache.putResult(finderClassName, finderMethodName,
312 finderParams, finderArgs, list);
313
314 return list;
315 }
316 catch (Exception e) {
317 throw HibernateUtil.processException(e);
318 }
319 finally {
320 closeSession(session);
321 }
322 }
323 else {
324 return (List)result;
325 }
326 }
327
328 public SCProductVersion findByProductEntryId_First(long productEntryId,
329 OrderByComparator obc)
330 throws NoSuchProductVersionException, SystemException {
331 List list = findByProductEntryId(productEntryId, 0, 1, obc);
332
333 if (list.size() == 0) {
334 StringMaker msg = new StringMaker();
335 msg.append("No SCProductVersion exists with the key ");
336 msg.append(StringPool.OPEN_CURLY_BRACE);
337 msg.append("productEntryId=");
338 msg.append(productEntryId);
339 msg.append(StringPool.CLOSE_CURLY_BRACE);
340 throw new NoSuchProductVersionException(msg.toString());
341 }
342 else {
343 return (SCProductVersion)list.get(0);
344 }
345 }
346
347 public SCProductVersion findByProductEntryId_Last(long productEntryId,
348 OrderByComparator obc)
349 throws NoSuchProductVersionException, SystemException {
350 int count = countByProductEntryId(productEntryId);
351 List list = findByProductEntryId(productEntryId, count - 1, count, obc);
352
353 if (list.size() == 0) {
354 StringMaker msg = new StringMaker();
355 msg.append("No SCProductVersion exists with the key ");
356 msg.append(StringPool.OPEN_CURLY_BRACE);
357 msg.append("productEntryId=");
358 msg.append(productEntryId);
359 msg.append(StringPool.CLOSE_CURLY_BRACE);
360 throw new NoSuchProductVersionException(msg.toString());
361 }
362 else {
363 return (SCProductVersion)list.get(0);
364 }
365 }
366
367 public SCProductVersion[] findByProductEntryId_PrevAndNext(
368 long productVersionId, long productEntryId, OrderByComparator obc)
369 throws NoSuchProductVersionException, SystemException {
370 SCProductVersion scProductVersion = findByPrimaryKey(productVersionId);
371 int count = countByProductEntryId(productEntryId);
372 Session session = null;
373
374 try {
375 session = openSession();
376
377 StringMaker query = new StringMaker();
378 query.append(
379 "FROM com.liferay.portlet.softwarecatalog.model.SCProductVersion WHERE ");
380 query.append("productEntryId = ?");
381 query.append(" ");
382
383 if (obc != null) {
384 query.append("ORDER BY ");
385 query.append(obc.getOrderBy());
386 }
387 else {
388 query.append("ORDER BY ");
389 query.append("createDate DESC");
390 }
391
392 Query q = session.createQuery(query.toString());
393 int queryPos = 0;
394 q.setLong(queryPos++, productEntryId);
395
396 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
397 scProductVersion);
398 SCProductVersion[] array = new SCProductVersionImpl[3];
399 array[0] = (SCProductVersion)objArray[0];
400 array[1] = (SCProductVersion)objArray[1];
401 array[2] = (SCProductVersion)objArray[2];
402
403 return array;
404 }
405 catch (Exception e) {
406 throw HibernateUtil.processException(e);
407 }
408 finally {
409 closeSession(session);
410 }
411 }
412
413 public List findWithDynamicQuery(DynamicQueryInitializer queryInitializer)
414 throws SystemException {
415 Session session = null;
416
417 try {
418 session = openSession();
419
420 DynamicQuery query = queryInitializer.initialize(session);
421
422 return query.list();
423 }
424 catch (Exception e) {
425 throw HibernateUtil.processException(e);
426 }
427 finally {
428 closeSession(session);
429 }
430 }
431
432 public List findWithDynamicQuery(DynamicQueryInitializer queryInitializer,
433 int begin, int end) throws SystemException {
434 Session session = null;
435
436 try {
437 session = openSession();
438
439 DynamicQuery query = queryInitializer.initialize(session);
440 query.setLimit(begin, end);
441
442 return query.list();
443 }
444 catch (Exception e) {
445 throw HibernateUtil.processException(e);
446 }
447 finally {
448 closeSession(session);
449 }
450 }
451
452 public List findAll() throws SystemException {
453 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
454 }
455
456 public List findAll(int begin, int end) throws SystemException {
457 return findAll(begin, end, null);
458 }
459
460 public List findAll(int begin, int end, OrderByComparator obc)
461 throws SystemException {
462 String finderClassName = SCProductVersion.class.getName();
463 String finderMethodName = "findAll";
464 String[] finderParams = new String[] {
465 "java.lang.Integer", "java.lang.Integer",
466 "com.liferay.portal.kernel.util.OrderByComparator"
467 };
468 Object[] finderArgs = new Object[] {
469 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
470 };
471 Object result = FinderCache.getResult(finderClassName,
472 finderMethodName, finderParams, finderArgs, getSessionFactory());
473
474 if (result == null) {
475 Session session = null;
476
477 try {
478 session = openSession();
479
480 StringMaker query = new StringMaker();
481 query.append(
482 "FROM com.liferay.portlet.softwarecatalog.model.SCProductVersion ");
483
484 if (obc != null) {
485 query.append("ORDER BY ");
486 query.append(obc.getOrderBy());
487 }
488 else {
489 query.append("ORDER BY ");
490 query.append("createDate DESC");
491 }
492
493 Query q = session.createQuery(query.toString());
494 List list = QueryUtil.list(q, getDialect(), begin, end);
495
496 if (obc == null) {
497 Collections.sort(list);
498 }
499
500 FinderCache.putResult(finderClassName, finderMethodName,
501 finderParams, finderArgs, list);
502
503 return list;
504 }
505 catch (Exception e) {
506 throw HibernateUtil.processException(e);
507 }
508 finally {
509 closeSession(session);
510 }
511 }
512 else {
513 return (List)result;
514 }
515 }
516
517 public void removeByProductEntryId(long productEntryId)
518 throws SystemException {
519 Iterator itr = findByProductEntryId(productEntryId).iterator();
520
521 while (itr.hasNext()) {
522 SCProductVersion scProductVersion = (SCProductVersion)itr.next();
523 remove(scProductVersion);
524 }
525 }
526
527 public void removeAll() throws SystemException {
528 Iterator itr = findAll().iterator();
529
530 while (itr.hasNext()) {
531 remove((SCProductVersion)itr.next());
532 }
533 }
534
535 public int countByProductEntryId(long productEntryId)
536 throws SystemException {
537 String finderClassName = SCProductVersion.class.getName();
538 String finderMethodName = "countByProductEntryId";
539 String[] finderParams = new String[] { Long.class.getName() };
540 Object[] finderArgs = new Object[] { new Long(productEntryId) };
541 Object result = FinderCache.getResult(finderClassName,
542 finderMethodName, finderParams, finderArgs, getSessionFactory());
543
544 if (result == null) {
545 Session session = null;
546
547 try {
548 session = openSession();
549
550 StringMaker query = new StringMaker();
551 query.append("SELECT COUNT(*) ");
552 query.append(
553 "FROM com.liferay.portlet.softwarecatalog.model.SCProductVersion WHERE ");
554 query.append("productEntryId = ?");
555 query.append(" ");
556
557 Query q = session.createQuery(query.toString());
558 int queryPos = 0;
559 q.setLong(queryPos++, productEntryId);
560
561 Long count = null;
562 Iterator itr = q.list().iterator();
563
564 if (itr.hasNext()) {
565 count = (Long)itr.next();
566 }
567
568 if (count == null) {
569 count = new Long(0);
570 }
571
572 FinderCache.putResult(finderClassName, finderMethodName,
573 finderParams, finderArgs, count);
574
575 return count.intValue();
576 }
577 catch (Exception e) {
578 throw HibernateUtil.processException(e);
579 }
580 finally {
581 closeSession(session);
582 }
583 }
584 else {
585 return ((Long)result).intValue();
586 }
587 }
588
589 public int countAll() throws SystemException {
590 String finderClassName = SCProductVersion.class.getName();
591 String finderMethodName = "countAll";
592 String[] finderParams = new String[] { };
593 Object[] finderArgs = new Object[] { };
594 Object result = FinderCache.getResult(finderClassName,
595 finderMethodName, finderParams, finderArgs, getSessionFactory());
596
597 if (result == null) {
598 Session session = null;
599
600 try {
601 session = openSession();
602
603 StringMaker query = new StringMaker();
604 query.append("SELECT COUNT(*) ");
605 query.append(
606 "FROM com.liferay.portlet.softwarecatalog.model.SCProductVersion");
607
608 Query q = session.createQuery(query.toString());
609 Long count = null;
610 Iterator itr = q.list().iterator();
611
612 if (itr.hasNext()) {
613 count = (Long)itr.next();
614 }
615
616 if (count == null) {
617 count = new Long(0);
618 }
619
620 FinderCache.putResult(finderClassName, finderMethodName,
621 finderParams, finderArgs, count);
622
623 return count.intValue();
624 }
625 catch (Exception e) {
626 throw HibernateUtil.processException(e);
627 }
628 finally {
629 closeSession(session);
630 }
631 }
632 else {
633 return ((Long)result).intValue();
634 }
635 }
636
637 public List getSCFrameworkVersions(long pk)
638 throws NoSuchProductVersionException, SystemException {
639 return getSCFrameworkVersions(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
640 }
641
642 public List getSCFrameworkVersions(long pk, int begin, int end)
643 throws NoSuchProductVersionException, SystemException {
644 return getSCFrameworkVersions(pk, begin, end, null);
645 }
646
647 public List getSCFrameworkVersions(long pk, int begin, int end,
648 OrderByComparator obc)
649 throws NoSuchProductVersionException, SystemException {
650 String finderClassName = "SCFrameworkVersi_SCProductVers";
651 String finderMethodName = "getSCFrameworkVersions";
652 String[] finderParams = new String[] {
653 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
654 "com.liferay.portal.kernel.util.OrderByComparator"
655 };
656 Object[] finderArgs = new Object[] {
657 new Long(pk), String.valueOf(begin), String.valueOf(end),
658 String.valueOf(obc)
659 };
660 Object result = FinderCache.getResult(finderClassName,
661 finderMethodName, finderParams, finderArgs, getSessionFactory());
662
663 if (result == null) {
664 Session session = null;
665
666 try {
667 session = HibernateUtil.openSession();
668
669 StringMaker sm = new StringMaker();
670 sm.append(_SQL_GETSCFRAMEWORKVERSIONS);
671
672 if (obc != null) {
673 sm.append("ORDER BY ");
674 sm.append(obc.getOrderBy());
675 }
676 else {
677 sm.append("ORDER BY ");
678 sm.append("SCFrameworkVersion.priority ASC");
679 sm.append(", ");
680 sm.append("SCFrameworkVersion.name ASC");
681 }
682
683 String sql = sm.toString();
684 SQLQuery q = session.createSQLQuery(sql);
685 q.addEntity("SCFrameworkVersion",
686 com.liferay.portlet.softwarecatalog.model.impl.SCFrameworkVersionImpl.class);
687
688 QueryPos qPos = QueryPos.getInstance(q);
689 qPos.add(pk);
690
691 List list = QueryUtil.list(q, getDialect(), begin, end);
692 FinderCache.putResult(finderClassName, finderMethodName,
693 finderParams, finderArgs, list);
694
695 return list;
696 }
697 catch (Exception e) {
698 throw new SystemException(e);
699 }
700 finally {
701 closeSession(session);
702 }
703 }
704 else {
705 return (List)result;
706 }
707 }
708
709 public int getSCFrameworkVersionsSize(long pk) throws SystemException {
710 String finderClassName = "SCFrameworkVersi_SCProductVers";
711 String finderMethodName = "getSCFrameworkVersionsSize";
712 String[] finderParams = new String[] { Long.class.getName() };
713 Object[] finderArgs = new Object[] { new Long(pk) };
714 Object result = FinderCache.getResult(finderClassName,
715 finderMethodName, finderParams, finderArgs, getSessionFactory());
716
717 if (result == null) {
718 Session session = null;
719
720 try {
721 session = openSession();
722
723 SQLQuery q = session.createSQLQuery(_SQL_GETSCFRAMEWORKVERSIONSSIZE);
724 q.addScalar(HibernateUtil.getCountColumnName(), Hibernate.LONG);
725
726 QueryPos qPos = QueryPos.getInstance(q);
727 qPos.add(pk);
728
729 Long count = null;
730 Iterator itr = q.list().iterator();
731
732 if (itr.hasNext()) {
733 count = (Long)itr.next();
734 }
735
736 if (count == null) {
737 count = new Long(0);
738 }
739
740 FinderCache.putResult(finderClassName, finderMethodName,
741 finderParams, finderArgs, count);
742
743 return count.intValue();
744 }
745 catch (Exception e) {
746 throw HibernateUtil.processException(e);
747 }
748 finally {
749 closeSession(session);
750 }
751 }
752 else {
753 return ((Long)result).intValue();
754 }
755 }
756
757 public boolean containsSCFrameworkVersion(long pk, long scFrameworkVersionPK)
758 throws SystemException {
759 String finderClassName = "SCFrameworkVersi_SCProductVers";
760 String finderMethodName = "containsSCFrameworkVersions";
761 String[] finderParams = new String[] {
762 Long.class.getName(), Long.class.getName()
763 };
764 Object[] finderArgs = new Object[] {
765 new Long(pk), new Long(scFrameworkVersionPK)
766 };
767 Object result = FinderCache.getResult(finderClassName,
768 finderMethodName, finderParams, finderArgs, getSessionFactory());
769
770 if (result == null) {
771 try {
772 Boolean value = Boolean.valueOf(containsSCFrameworkVersion.contains(
773 pk, scFrameworkVersionPK));
774 FinderCache.putResult(finderClassName, finderMethodName,
775 finderParams, finderArgs, value);
776
777 return value.booleanValue();
778 }
779 catch (DataAccessException dae) {
780 throw new SystemException(dae);
781 }
782 }
783 else {
784 return ((Boolean)result).booleanValue();
785 }
786 }
787
788 public boolean containsSCFrameworkVersions(long pk)
789 throws SystemException {
790 if (getSCFrameworkVersionsSize(pk) > 0) {
791 return true;
792 }
793 else {
794 return false;
795 }
796 }
797
798 public void addSCFrameworkVersion(long pk, long scFrameworkVersionPK)
799 throws NoSuchProductVersionException,
800 com.liferay.portlet.softwarecatalog.NoSuchFrameworkVersionException,
801 SystemException {
802 try {
803 addSCFrameworkVersion.add(pk, scFrameworkVersionPK);
804 }
805 catch (DataAccessException dae) {
806 throw new SystemException(dae);
807 }
808 finally {
809 FinderCache.clearCache("SCFrameworkVersi_SCProductVers");
810 }
811 }
812
813 public void addSCFrameworkVersion(long pk,
814 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion)
815 throws NoSuchProductVersionException,
816 com.liferay.portlet.softwarecatalog.NoSuchFrameworkVersionException,
817 SystemException {
818 try {
819 addSCFrameworkVersion.add(pk, scFrameworkVersion.getPrimaryKey());
820 }
821 catch (DataAccessException dae) {
822 throw new SystemException(dae);
823 }
824 finally {
825 FinderCache.clearCache("SCFrameworkVersi_SCProductVers");
826 }
827 }
828
829 public void addSCFrameworkVersions(long pk, long[] scFrameworkVersionPKs)
830 throws NoSuchProductVersionException,
831 com.liferay.portlet.softwarecatalog.NoSuchFrameworkVersionException,
832 SystemException {
833 try {
834 for (int i = 0; i < scFrameworkVersionPKs.length; i++) {
835 addSCFrameworkVersion.add(pk, scFrameworkVersionPKs[i]);
836 }
837 }
838 catch (DataAccessException dae) {
839 throw new SystemException(dae);
840 }
841 finally {
842 FinderCache.clearCache("SCFrameworkVersi_SCProductVers");
843 }
844 }
845
846 public void addSCFrameworkVersions(long pk, List scFrameworkVersions)
847 throws NoSuchProductVersionException,
848 com.liferay.portlet.softwarecatalog.NoSuchFrameworkVersionException,
849 SystemException {
850 try {
851 for (int i = 0; i < scFrameworkVersions.size(); i++) {
852 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion =
853 (com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion)scFrameworkVersions.get(i);
854 addSCFrameworkVersion.add(pk, scFrameworkVersion.getPrimaryKey());
855 }
856 }
857 catch (DataAccessException dae) {
858 throw new SystemException(dae);
859 }
860 finally {
861 FinderCache.clearCache("SCFrameworkVersi_SCProductVers");
862 }
863 }
864
865 public void clearSCFrameworkVersions(long pk)
866 throws NoSuchProductVersionException, SystemException {
867 try {
868 clearSCFrameworkVersions.clear(pk);
869 }
870 catch (DataAccessException dae) {
871 throw new SystemException(dae);
872 }
873 finally {
874 FinderCache.clearCache("SCFrameworkVersi_SCProductVers");
875 }
876 }
877
878 public void removeSCFrameworkVersion(long pk, long scFrameworkVersionPK)
879 throws NoSuchProductVersionException,
880 com.liferay.portlet.softwarecatalog.NoSuchFrameworkVersionException,
881 SystemException {
882 try {
883 removeSCFrameworkVersion.remove(pk, scFrameworkVersionPK);
884 }
885 catch (DataAccessException dae) {
886 throw new SystemException(dae);
887 }
888 finally {
889 FinderCache.clearCache("SCFrameworkVersi_SCProductVers");
890 }
891 }
892
893 public void removeSCFrameworkVersion(long pk,
894 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion)
895 throws NoSuchProductVersionException,
896 com.liferay.portlet.softwarecatalog.NoSuchFrameworkVersionException,
897 SystemException {
898 try {
899 removeSCFrameworkVersion.remove(pk,
900 scFrameworkVersion.getPrimaryKey());
901 }
902 catch (DataAccessException dae) {
903 throw new SystemException(dae);
904 }
905 finally {
906 FinderCache.clearCache("SCFrameworkVersi_SCProductVers");
907 }
908 }
909
910 public void removeSCFrameworkVersions(long pk, long[] scFrameworkVersionPKs)
911 throws NoSuchProductVersionException,
912 com.liferay.portlet.softwarecatalog.NoSuchFrameworkVersionException,
913 SystemException {
914 try {
915 for (int i = 0; i < scFrameworkVersionPKs.length; i++) {
916 removeSCFrameworkVersion.remove(pk, scFrameworkVersionPKs[i]);
917 }
918 }
919 catch (DataAccessException dae) {
920 throw new SystemException(dae);
921 }
922 finally {
923 FinderCache.clearCache("SCFrameworkVersi_SCProductVers");
924 }
925 }
926
927 public void removeSCFrameworkVersions(long pk, List scFrameworkVersions)
928 throws NoSuchProductVersionException,
929 com.liferay.portlet.softwarecatalog.NoSuchFrameworkVersionException,
930 SystemException {
931 try {
932 for (int i = 0; i < scFrameworkVersions.size(); i++) {
933 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion =
934 (com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion)scFrameworkVersions.get(i);
935 removeSCFrameworkVersion.remove(pk,
936 scFrameworkVersion.getPrimaryKey());
937 }
938 }
939 catch (DataAccessException dae) {
940 throw new SystemException(dae);
941 }
942 finally {
943 FinderCache.clearCache("SCFrameworkVersi_SCProductVers");
944 }
945 }
946
947 public void setSCFrameworkVersions(long pk, long[] scFrameworkVersionPKs)
948 throws NoSuchProductVersionException,
949 com.liferay.portlet.softwarecatalog.NoSuchFrameworkVersionException,
950 SystemException {
951 try {
952 clearSCFrameworkVersions.clear(pk);
953
954 for (int i = 0; i < scFrameworkVersionPKs.length; i++) {
955 addSCFrameworkVersion.add(pk, scFrameworkVersionPKs[i]);
956 }
957 }
958 catch (DataAccessException dae) {
959 throw new SystemException(dae);
960 }
961 finally {
962 FinderCache.clearCache("SCFrameworkVersi_SCProductVers");
963 }
964 }
965
966 public void setSCFrameworkVersions(long pk, List scFrameworkVersions)
967 throws NoSuchProductVersionException,
968 com.liferay.portlet.softwarecatalog.NoSuchFrameworkVersionException,
969 SystemException {
970 try {
971 clearSCFrameworkVersions.clear(pk);
972
973 for (int i = 0; i < scFrameworkVersions.size(); i++) {
974 com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion =
975 (com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion)scFrameworkVersions.get(i);
976 addSCFrameworkVersion.add(pk, scFrameworkVersion.getPrimaryKey());
977 }
978 }
979 catch (DataAccessException dae) {
980 throw new SystemException(dae);
981 }
982 finally {
983 FinderCache.clearCache("SCFrameworkVersi_SCProductVers");
984 }
985 }
986
987 protected void initDao() {
988 containsSCFrameworkVersion = new ContainsSCFrameworkVersion(this);
989 addSCFrameworkVersion = new AddSCFrameworkVersion(this);
990 clearSCFrameworkVersions = new ClearSCFrameworkVersions(this);
991 removeSCFrameworkVersion = new RemoveSCFrameworkVersion(this);
992 }
993
994 protected ContainsSCFrameworkVersion containsSCFrameworkVersion;
995 protected AddSCFrameworkVersion addSCFrameworkVersion;
996 protected ClearSCFrameworkVersions clearSCFrameworkVersions;
997 protected RemoveSCFrameworkVersion removeSCFrameworkVersion;
998
999 protected class ContainsSCFrameworkVersion extends MappingSqlQuery {
1000 protected ContainsSCFrameworkVersion(
1001 SCProductVersionPersistenceImpl persistenceImpl) {
1002 super(persistenceImpl.getDataSource(),
1003 _SQL_CONTAINSSCFRAMEWORKVERSION);
1004 declareParameter(new SqlParameter(Types.BIGINT));
1005 declareParameter(new SqlParameter(Types.BIGINT));
1006 compile();
1007 }
1008
1009 protected Object mapRow(ResultSet rs, int rowNumber)
1010 throws SQLException {
1011 return new Integer(rs.getInt("COUNT_VALUE"));
1012 }
1013
1014 protected boolean contains(long productVersionId,
1015 long frameworkVersionId) {
1016 List results = execute(new Object[] {
1017 new Long(productVersionId), new Long(frameworkVersionId)
1018 });
1019
1020 if (results.size() > 0) {
1021 Integer count = (Integer)results.get(0);
1022
1023 if (count.intValue() > 0) {
1024 return true;
1025 }
1026 }
1027
1028 return false;
1029 }
1030 }
1031
1032 protected class AddSCFrameworkVersion extends SqlUpdate {
1033 protected AddSCFrameworkVersion(
1034 SCProductVersionPersistenceImpl persistenceImpl) {
1035 super(persistenceImpl.getDataSource(),
1036 "INSERT INTO SCFrameworkVersi_SCProductVers (productVersionId, frameworkVersionId) VALUES (?, ?)");
1037 _persistenceImpl = persistenceImpl;
1038 declareParameter(new SqlParameter(Types.BIGINT));
1039 declareParameter(new SqlParameter(Types.BIGINT));
1040 compile();
1041 }
1042
1043 protected void add(long productVersionId, long frameworkVersionId) {
1044 if (!_persistenceImpl.containsSCFrameworkVersion.contains(
1045 productVersionId, frameworkVersionId)) {
1046 update(new Object[] {
1047 new Long(productVersionId), new Long(frameworkVersionId)
1048 });
1049 }
1050 }
1051
1052 private SCProductVersionPersistenceImpl _persistenceImpl;
1053 }
1054
1055 protected class ClearSCFrameworkVersions extends SqlUpdate {
1056 protected ClearSCFrameworkVersions(
1057 SCProductVersionPersistenceImpl persistenceImpl) {
1058 super(persistenceImpl.getDataSource(),
1059 "DELETE FROM SCFrameworkVersi_SCProductVers WHERE productVersionId = ?");
1060 declareParameter(new SqlParameter(Types.BIGINT));
1061 compile();
1062 }
1063
1064 protected void clear(long productVersionId) {
1065 update(new Object[] { new Long(productVersionId) });
1066 }
1067 }
1068
1069 protected class RemoveSCFrameworkVersion extends SqlUpdate {
1070 protected RemoveSCFrameworkVersion(
1071 SCProductVersionPersistenceImpl persistenceImpl) {
1072 super(persistenceImpl.getDataSource(),
1073 "DELETE FROM SCFrameworkVersi_SCProductVers WHERE productVersionId = ? AND frameworkVersionId = ?");
1074 declareParameter(new SqlParameter(Types.BIGINT));
1075 declareParameter(new SqlParameter(Types.BIGINT));
1076 compile();
1077 }
1078
1079 protected void remove(long productVersionId, long frameworkVersionId) {
1080 update(new Object[] {
1081 new Long(productVersionId), new Long(frameworkVersionId)
1082 });
1083 }
1084 }
1085
1086 private static final String _SQL_GETSCFRAMEWORKVERSIONS = "SELECT {SCFrameworkVersion.*} FROM SCFrameworkVersion INNER JOIN SCFrameworkVersi_SCProductVers ON (SCFrameworkVersi_SCProductVers.frameworkVersionId = SCFrameworkVersion.frameworkVersionId) WHERE (SCFrameworkVersi_SCProductVers.productVersionId = ?)";
1087 private static final String _SQL_GETSCFRAMEWORKVERSIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCFrameworkVersi_SCProductVers WHERE productVersionId = ?";
1088 private static final String _SQL_CONTAINSSCFRAMEWORKVERSION = "SELECT COUNT(*) AS COUNT_VALUE FROM SCFrameworkVersi_SCProductVers WHERE productVersionId = ? AND frameworkVersionId = ?";
1089 private static Log _log = LogFactory.getLog(SCProductVersionPersistenceImpl.class);
1090}