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.Validator;
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.NoSuchProductEntryException;
40 import com.liferay.portlet.softwarecatalog.model.SCProductEntry;
41 import com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryImpl;
42 import com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl;
43
44 import com.liferay.util.dao.hibernate.QueryPos;
45 import com.liferay.util.dao.hibernate.QueryUtil;
46
47 import org.apache.commons.logging.Log;
48 import org.apache.commons.logging.LogFactory;
49
50 import org.hibernate.Hibernate;
51 import org.hibernate.Query;
52 import org.hibernate.SQLQuery;
53 import org.hibernate.Session;
54
55 import org.springframework.dao.DataAccessException;
56
57 import org.springframework.jdbc.core.SqlParameter;
58 import org.springframework.jdbc.object.MappingSqlQuery;
59 import org.springframework.jdbc.object.SqlUpdate;
60
61 import java.sql.ResultSet;
62 import java.sql.SQLException;
63 import java.sql.Types;
64
65 import java.util.Collections;
66 import java.util.Iterator;
67 import java.util.List;
68
69
75 public class SCProductEntryPersistenceImpl extends BasePersistence
76 implements SCProductEntryPersistence {
77 public SCProductEntry create(long productEntryId) {
78 SCProductEntry scProductEntry = new SCProductEntryImpl();
79
80 scProductEntry.setNew(true);
81 scProductEntry.setPrimaryKey(productEntryId);
82
83 return scProductEntry;
84 }
85
86 public SCProductEntry remove(long productEntryId)
87 throws NoSuchProductEntryException, SystemException {
88 Session session = null;
89
90 try {
91 session = openSession();
92
93 SCProductEntry scProductEntry = (SCProductEntry)session.get(SCProductEntryImpl.class,
94 new Long(productEntryId));
95
96 if (scProductEntry == null) {
97 if (_log.isWarnEnabled()) {
98 _log.warn("No SCProductEntry exists with the primary key " +
99 productEntryId);
100 }
101
102 throw new NoSuchProductEntryException(
103 "No SCProductEntry exists with the primary key " +
104 productEntryId);
105 }
106
107 return remove(scProductEntry);
108 }
109 catch (NoSuchProductEntryException nsee) {
110 throw nsee;
111 }
112 catch (Exception e) {
113 throw HibernateUtil.processException(e);
114 }
115 finally {
116 closeSession(session);
117 }
118 }
119
120 public SCProductEntry remove(SCProductEntry scProductEntry)
121 throws SystemException {
122 ModelListener listener = _getListener();
123
124 if (listener != null) {
125 listener.onBeforeRemove(scProductEntry);
126 }
127
128 scProductEntry = removeImpl(scProductEntry);
129
130 if (listener != null) {
131 listener.onAfterRemove(scProductEntry);
132 }
133
134 return scProductEntry;
135 }
136
137 protected SCProductEntry removeImpl(SCProductEntry scProductEntry)
138 throws SystemException {
139 try {
140 clearSCLicenses.clear(scProductEntry.getPrimaryKey());
141 }
142 catch (Exception e) {
143 throw HibernateUtil.processException(e);
144 }
145 finally {
146 FinderCache.clearCache("SCLicenses_SCProductEntries");
147 }
148
149 Session session = null;
150
151 try {
152 session = openSession();
153
154 session.delete(scProductEntry);
155
156 session.flush();
157
158 return scProductEntry;
159 }
160 catch (Exception e) {
161 throw HibernateUtil.processException(e);
162 }
163 finally {
164 closeSession(session);
165
166 FinderCache.clearCache(SCProductEntry.class.getName());
167 }
168 }
169
170 public SCProductEntry update(SCProductEntry scProductEntry)
171 throws SystemException {
172 return update(scProductEntry, false);
173 }
174
175 public SCProductEntry update(SCProductEntry scProductEntry, boolean merge)
176 throws SystemException {
177 ModelListener listener = _getListener();
178
179 boolean isNew = scProductEntry.isNew();
180
181 if (listener != null) {
182 if (isNew) {
183 listener.onBeforeCreate(scProductEntry);
184 }
185 else {
186 listener.onBeforeUpdate(scProductEntry);
187 }
188 }
189
190 scProductEntry = updateImpl(scProductEntry, merge);
191
192 if (listener != null) {
193 if (isNew) {
194 listener.onAfterCreate(scProductEntry);
195 }
196 else {
197 listener.onAfterUpdate(scProductEntry);
198 }
199 }
200
201 return scProductEntry;
202 }
203
204 public SCProductEntry updateImpl(
205 com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry,
206 boolean merge) throws SystemException {
207 FinderCache.clearCache("SCLicenses_SCProductEntries");
208
209 Session session = null;
210
211 try {
212 session = openSession();
213
214 if (merge) {
215 session.merge(scProductEntry);
216 }
217 else {
218 if (scProductEntry.isNew()) {
219 session.save(scProductEntry);
220 }
221 }
222
223 session.flush();
224
225 scProductEntry.setNew(false);
226
227 return scProductEntry;
228 }
229 catch (Exception e) {
230 throw HibernateUtil.processException(e);
231 }
232 finally {
233 closeSession(session);
234
235 FinderCache.clearCache(SCProductEntry.class.getName());
236 }
237 }
238
239 public SCProductEntry findByPrimaryKey(long productEntryId)
240 throws NoSuchProductEntryException, SystemException {
241 SCProductEntry scProductEntry = fetchByPrimaryKey(productEntryId);
242
243 if (scProductEntry == null) {
244 if (_log.isWarnEnabled()) {
245 _log.warn("No SCProductEntry exists with the primary key " +
246 productEntryId);
247 }
248
249 throw new NoSuchProductEntryException(
250 "No SCProductEntry exists with the primary key " +
251 productEntryId);
252 }
253
254 return scProductEntry;
255 }
256
257 public SCProductEntry fetchByPrimaryKey(long productEntryId)
258 throws SystemException {
259 Session session = null;
260
261 try {
262 session = openSession();
263
264 return (SCProductEntry)session.get(SCProductEntryImpl.class,
265 new Long(productEntryId));
266 }
267 catch (Exception e) {
268 throw HibernateUtil.processException(e);
269 }
270 finally {
271 closeSession(session);
272 }
273 }
274
275 public List findByGroupId(long groupId) throws SystemException {
276 boolean finderClassNameCacheEnabled = SCProductEntryModelImpl.CACHE_ENABLED;
277 String finderClassName = SCProductEntry.class.getName();
278 String finderMethodName = "findByGroupId";
279 String[] finderParams = new String[] { Long.class.getName() };
280 Object[] finderArgs = new Object[] { new Long(groupId) };
281
282 Object result = null;
283
284 if (finderClassNameCacheEnabled) {
285 result = FinderCache.getResult(finderClassName, finderMethodName,
286 finderParams, finderArgs, getSessionFactory());
287 }
288
289 if (result == null) {
290 Session session = null;
291
292 try {
293 session = openSession();
294
295 StringMaker query = new StringMaker();
296
297 query.append(
298 "FROM com.liferay.portlet.softwarecatalog.model.SCProductEntry WHERE ");
299
300 query.append("groupId = ?");
301
302 query.append(" ");
303
304 query.append("ORDER BY ");
305
306 query.append("modifiedDate DESC, ");
307 query.append("name DESC");
308
309 Query q = session.createQuery(query.toString());
310
311 int queryPos = 0;
312
313 q.setLong(queryPos++, groupId);
314
315 List list = q.list();
316
317 FinderCache.putResult(finderClassNameCacheEnabled,
318 finderClassName, finderMethodName, finderParams,
319 finderArgs, list);
320
321 return list;
322 }
323 catch (Exception e) {
324 throw HibernateUtil.processException(e);
325 }
326 finally {
327 closeSession(session);
328 }
329 }
330 else {
331 return (List)result;
332 }
333 }
334
335 public List findByGroupId(long groupId, int begin, int end)
336 throws SystemException {
337 return findByGroupId(groupId, begin, end, null);
338 }
339
340 public List findByGroupId(long groupId, int begin, int end,
341 OrderByComparator obc) throws SystemException {
342 boolean finderClassNameCacheEnabled = SCProductEntryModelImpl.CACHE_ENABLED;
343 String finderClassName = SCProductEntry.class.getName();
344 String finderMethodName = "findByGroupId";
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(groupId),
353
354 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
355 };
356
357 Object result = null;
358
359 if (finderClassNameCacheEnabled) {
360 result = FinderCache.getResult(finderClassName, finderMethodName,
361 finderParams, finderArgs, getSessionFactory());
362 }
363
364 if (result == null) {
365 Session session = null;
366
367 try {
368 session = openSession();
369
370 StringMaker query = new StringMaker();
371
372 query.append(
373 "FROM com.liferay.portlet.softwarecatalog.model.SCProductEntry WHERE ");
374
375 query.append("groupId = ?");
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("modifiedDate DESC, ");
388 query.append("name DESC");
389 }
390
391 Query q = session.createQuery(query.toString());
392
393 int queryPos = 0;
394
395 q.setLong(queryPos++, groupId);
396
397 List list = QueryUtil.list(q, getDialect(), begin, end);
398
399 FinderCache.putResult(finderClassNameCacheEnabled,
400 finderClassName, finderMethodName, finderParams,
401 finderArgs, list);
402
403 return list;
404 }
405 catch (Exception e) {
406 throw HibernateUtil.processException(e);
407 }
408 finally {
409 closeSession(session);
410 }
411 }
412 else {
413 return (List)result;
414 }
415 }
416
417 public SCProductEntry findByGroupId_First(long groupId,
418 OrderByComparator obc)
419 throws NoSuchProductEntryException, SystemException {
420 List list = findByGroupId(groupId, 0, 1, obc);
421
422 if (list.size() == 0) {
423 StringMaker msg = new StringMaker();
424
425 msg.append("No SCProductEntry exists with the key {");
426
427 msg.append("groupId=" + groupId);
428
429 msg.append(StringPool.CLOSE_CURLY_BRACE);
430
431 throw new NoSuchProductEntryException(msg.toString());
432 }
433 else {
434 return (SCProductEntry)list.get(0);
435 }
436 }
437
438 public SCProductEntry findByGroupId_Last(long groupId, OrderByComparator obc)
439 throws NoSuchProductEntryException, SystemException {
440 int count = countByGroupId(groupId);
441
442 List list = findByGroupId(groupId, count - 1, count, obc);
443
444 if (list.size() == 0) {
445 StringMaker msg = new StringMaker();
446
447 msg.append("No SCProductEntry exists with the key {");
448
449 msg.append("groupId=" + groupId);
450
451 msg.append(StringPool.CLOSE_CURLY_BRACE);
452
453 throw new NoSuchProductEntryException(msg.toString());
454 }
455 else {
456 return (SCProductEntry)list.get(0);
457 }
458 }
459
460 public SCProductEntry[] findByGroupId_PrevAndNext(long productEntryId,
461 long groupId, OrderByComparator obc)
462 throws NoSuchProductEntryException, SystemException {
463 SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
464
465 int count = countByGroupId(groupId);
466
467 Session session = null;
468
469 try {
470 session = openSession();
471
472 StringMaker query = new StringMaker();
473
474 query.append(
475 "FROM com.liferay.portlet.softwarecatalog.model.SCProductEntry WHERE ");
476
477 query.append("groupId = ?");
478
479 query.append(" ");
480
481 if (obc != null) {
482 query.append("ORDER BY ");
483 query.append(obc.getOrderBy());
484 }
485
486 else {
487 query.append("ORDER BY ");
488
489 query.append("modifiedDate DESC, ");
490 query.append("name DESC");
491 }
492
493 Query q = session.createQuery(query.toString());
494
495 int queryPos = 0;
496
497 q.setLong(queryPos++, groupId);
498
499 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
500 scProductEntry);
501
502 SCProductEntry[] array = new SCProductEntryImpl[3];
503
504 array[0] = (SCProductEntry)objArray[0];
505 array[1] = (SCProductEntry)objArray[1];
506 array[2] = (SCProductEntry)objArray[2];
507
508 return array;
509 }
510 catch (Exception e) {
511 throw HibernateUtil.processException(e);
512 }
513 finally {
514 closeSession(session);
515 }
516 }
517
518 public List findByCompanyId(long companyId) throws SystemException {
519 boolean finderClassNameCacheEnabled = SCProductEntryModelImpl.CACHE_ENABLED;
520 String finderClassName = SCProductEntry.class.getName();
521 String finderMethodName = "findByCompanyId";
522 String[] finderParams = new String[] { Long.class.getName() };
523 Object[] finderArgs = new Object[] { new Long(companyId) };
524
525 Object result = null;
526
527 if (finderClassNameCacheEnabled) {
528 result = FinderCache.getResult(finderClassName, finderMethodName,
529 finderParams, finderArgs, getSessionFactory());
530 }
531
532 if (result == null) {
533 Session session = null;
534
535 try {
536 session = openSession();
537
538 StringMaker query = new StringMaker();
539
540 query.append(
541 "FROM com.liferay.portlet.softwarecatalog.model.SCProductEntry WHERE ");
542
543 query.append("companyId = ?");
544
545 query.append(" ");
546
547 query.append("ORDER BY ");
548
549 query.append("modifiedDate DESC, ");
550 query.append("name DESC");
551
552 Query q = session.createQuery(query.toString());
553
554 int queryPos = 0;
555
556 q.setLong(queryPos++, companyId);
557
558 List list = q.list();
559
560 FinderCache.putResult(finderClassNameCacheEnabled,
561 finderClassName, finderMethodName, finderParams,
562 finderArgs, list);
563
564 return list;
565 }
566 catch (Exception e) {
567 throw HibernateUtil.processException(e);
568 }
569 finally {
570 closeSession(session);
571 }
572 }
573 else {
574 return (List)result;
575 }
576 }
577
578 public List findByCompanyId(long companyId, int begin, int end)
579 throws SystemException {
580 return findByCompanyId(companyId, begin, end, null);
581 }
582
583 public List findByCompanyId(long companyId, int begin, int end,
584 OrderByComparator obc) throws SystemException {
585 boolean finderClassNameCacheEnabled = SCProductEntryModelImpl.CACHE_ENABLED;
586 String finderClassName = SCProductEntry.class.getName();
587 String finderMethodName = "findByCompanyId";
588 String[] finderParams = new String[] {
589 Long.class.getName(),
590
591 "java.lang.Integer", "java.lang.Integer",
592 "com.liferay.portal.kernel.util.OrderByComparator"
593 };
594 Object[] finderArgs = new Object[] {
595 new Long(companyId),
596
597 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
598 };
599
600 Object result = null;
601
602 if (finderClassNameCacheEnabled) {
603 result = FinderCache.getResult(finderClassName, finderMethodName,
604 finderParams, finderArgs, getSessionFactory());
605 }
606
607 if (result == null) {
608 Session session = null;
609
610 try {
611 session = openSession();
612
613 StringMaker query = new StringMaker();
614
615 query.append(
616 "FROM com.liferay.portlet.softwarecatalog.model.SCProductEntry WHERE ");
617
618 query.append("companyId = ?");
619
620 query.append(" ");
621
622 if (obc != null) {
623 query.append("ORDER BY ");
624 query.append(obc.getOrderBy());
625 }
626
627 else {
628 query.append("ORDER BY ");
629
630 query.append("modifiedDate DESC, ");
631 query.append("name DESC");
632 }
633
634 Query q = session.createQuery(query.toString());
635
636 int queryPos = 0;
637
638 q.setLong(queryPos++, companyId);
639
640 List list = QueryUtil.list(q, getDialect(), begin, end);
641
642 FinderCache.putResult(finderClassNameCacheEnabled,
643 finderClassName, finderMethodName, finderParams,
644 finderArgs, list);
645
646 return list;
647 }
648 catch (Exception e) {
649 throw HibernateUtil.processException(e);
650 }
651 finally {
652 closeSession(session);
653 }
654 }
655 else {
656 return (List)result;
657 }
658 }
659
660 public SCProductEntry findByCompanyId_First(long companyId,
661 OrderByComparator obc)
662 throws NoSuchProductEntryException, SystemException {
663 List list = findByCompanyId(companyId, 0, 1, obc);
664
665 if (list.size() == 0) {
666 StringMaker msg = new StringMaker();
667
668 msg.append("No SCProductEntry exists with the key {");
669
670 msg.append("companyId=" + companyId);
671
672 msg.append(StringPool.CLOSE_CURLY_BRACE);
673
674 throw new NoSuchProductEntryException(msg.toString());
675 }
676 else {
677 return (SCProductEntry)list.get(0);
678 }
679 }
680
681 public SCProductEntry findByCompanyId_Last(long companyId,
682 OrderByComparator obc)
683 throws NoSuchProductEntryException, SystemException {
684 int count = countByCompanyId(companyId);
685
686 List list = findByCompanyId(companyId, count - 1, count, obc);
687
688 if (list.size() == 0) {
689 StringMaker msg = new StringMaker();
690
691 msg.append("No SCProductEntry exists with the key {");
692
693 msg.append("companyId=" + companyId);
694
695 msg.append(StringPool.CLOSE_CURLY_BRACE);
696
697 throw new NoSuchProductEntryException(msg.toString());
698 }
699 else {
700 return (SCProductEntry)list.get(0);
701 }
702 }
703
704 public SCProductEntry[] findByCompanyId_PrevAndNext(long productEntryId,
705 long companyId, OrderByComparator obc)
706 throws NoSuchProductEntryException, SystemException {
707 SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
708
709 int count = countByCompanyId(companyId);
710
711 Session session = null;
712
713 try {
714 session = openSession();
715
716 StringMaker query = new StringMaker();
717
718 query.append(
719 "FROM com.liferay.portlet.softwarecatalog.model.SCProductEntry WHERE ");
720
721 query.append("companyId = ?");
722
723 query.append(" ");
724
725 if (obc != null) {
726 query.append("ORDER BY ");
727 query.append(obc.getOrderBy());
728 }
729
730 else {
731 query.append("ORDER BY ");
732
733 query.append("modifiedDate DESC, ");
734 query.append("name DESC");
735 }
736
737 Query q = session.createQuery(query.toString());
738
739 int queryPos = 0;
740
741 q.setLong(queryPos++, companyId);
742
743 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
744 scProductEntry);
745
746 SCProductEntry[] array = new SCProductEntryImpl[3];
747
748 array[0] = (SCProductEntry)objArray[0];
749 array[1] = (SCProductEntry)objArray[1];
750 array[2] = (SCProductEntry)objArray[2];
751
752 return array;
753 }
754 catch (Exception e) {
755 throw HibernateUtil.processException(e);
756 }
757 finally {
758 closeSession(session);
759 }
760 }
761
762 public List findByG_U(long groupId, long userId) throws SystemException {
763 boolean finderClassNameCacheEnabled = SCProductEntryModelImpl.CACHE_ENABLED;
764 String finderClassName = SCProductEntry.class.getName();
765 String finderMethodName = "findByG_U";
766 String[] finderParams = new String[] {
767 Long.class.getName(), Long.class.getName()
768 };
769 Object[] finderArgs = new Object[] { new Long(groupId), new Long(userId) };
770
771 Object result = null;
772
773 if (finderClassNameCacheEnabled) {
774 result = FinderCache.getResult(finderClassName, finderMethodName,
775 finderParams, finderArgs, getSessionFactory());
776 }
777
778 if (result == null) {
779 Session session = null;
780
781 try {
782 session = openSession();
783
784 StringMaker query = new StringMaker();
785
786 query.append(
787 "FROM com.liferay.portlet.softwarecatalog.model.SCProductEntry WHERE ");
788
789 query.append("groupId = ?");
790
791 query.append(" AND ");
792
793 query.append("userId = ?");
794
795 query.append(" ");
796
797 query.append("ORDER BY ");
798
799 query.append("modifiedDate DESC, ");
800 query.append("name DESC");
801
802 Query q = session.createQuery(query.toString());
803
804 int queryPos = 0;
805
806 q.setLong(queryPos++, groupId);
807
808 q.setLong(queryPos++, userId);
809
810 List list = q.list();
811
812 FinderCache.putResult(finderClassNameCacheEnabled,
813 finderClassName, finderMethodName, finderParams,
814 finderArgs, list);
815
816 return list;
817 }
818 catch (Exception e) {
819 throw HibernateUtil.processException(e);
820 }
821 finally {
822 closeSession(session);
823 }
824 }
825 else {
826 return (List)result;
827 }
828 }
829
830 public List findByG_U(long groupId, long userId, int begin, int end)
831 throws SystemException {
832 return findByG_U(groupId, userId, begin, end, null);
833 }
834
835 public List findByG_U(long groupId, long userId, int begin, int end,
836 OrderByComparator obc) throws SystemException {
837 boolean finderClassNameCacheEnabled = SCProductEntryModelImpl.CACHE_ENABLED;
838 String finderClassName = SCProductEntry.class.getName();
839 String finderMethodName = "findByG_U";
840 String[] finderParams = new String[] {
841 Long.class.getName(), Long.class.getName(),
842
843 "java.lang.Integer", "java.lang.Integer",
844 "com.liferay.portal.kernel.util.OrderByComparator"
845 };
846 Object[] finderArgs = new Object[] {
847 new Long(groupId), new Long(userId),
848
849 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
850 };
851
852 Object result = null;
853
854 if (finderClassNameCacheEnabled) {
855 result = FinderCache.getResult(finderClassName, finderMethodName,
856 finderParams, finderArgs, getSessionFactory());
857 }
858
859 if (result == null) {
860 Session session = null;
861
862 try {
863 session = openSession();
864
865 StringMaker query = new StringMaker();
866
867 query.append(
868 "FROM com.liferay.portlet.softwarecatalog.model.SCProductEntry WHERE ");
869
870 query.append("groupId = ?");
871
872 query.append(" AND ");
873
874 query.append("userId = ?");
875
876 query.append(" ");
877
878 if (obc != null) {
879 query.append("ORDER BY ");
880 query.append(obc.getOrderBy());
881 }
882
883 else {
884 query.append("ORDER BY ");
885
886 query.append("modifiedDate DESC, ");
887 query.append("name DESC");
888 }
889
890 Query q = session.createQuery(query.toString());
891
892 int queryPos = 0;
893
894 q.setLong(queryPos++, groupId);
895
896 q.setLong(queryPos++, userId);
897
898 List list = QueryUtil.list(q, getDialect(), begin, end);
899
900 FinderCache.putResult(finderClassNameCacheEnabled,
901 finderClassName, finderMethodName, finderParams,
902 finderArgs, list);
903
904 return list;
905 }
906 catch (Exception e) {
907 throw HibernateUtil.processException(e);
908 }
909 finally {
910 closeSession(session);
911 }
912 }
913 else {
914 return (List)result;
915 }
916 }
917
918 public SCProductEntry findByG_U_First(long groupId, long userId,
919 OrderByComparator obc)
920 throws NoSuchProductEntryException, SystemException {
921 List list = findByG_U(groupId, userId, 0, 1, obc);
922
923 if (list.size() == 0) {
924 StringMaker msg = new StringMaker();
925
926 msg.append("No SCProductEntry exists with the key {");
927
928 msg.append("groupId=" + groupId);
929
930 msg.append(", ");
931 msg.append("userId=" + userId);
932
933 msg.append(StringPool.CLOSE_CURLY_BRACE);
934
935 throw new NoSuchProductEntryException(msg.toString());
936 }
937 else {
938 return (SCProductEntry)list.get(0);
939 }
940 }
941
942 public SCProductEntry findByG_U_Last(long groupId, long userId,
943 OrderByComparator obc)
944 throws NoSuchProductEntryException, SystemException {
945 int count = countByG_U(groupId, userId);
946
947 List list = findByG_U(groupId, userId, count - 1, count, obc);
948
949 if (list.size() == 0) {
950 StringMaker msg = new StringMaker();
951
952 msg.append("No SCProductEntry exists with the key {");
953
954 msg.append("groupId=" + groupId);
955
956 msg.append(", ");
957 msg.append("userId=" + userId);
958
959 msg.append(StringPool.CLOSE_CURLY_BRACE);
960
961 throw new NoSuchProductEntryException(msg.toString());
962 }
963 else {
964 return (SCProductEntry)list.get(0);
965 }
966 }
967
968 public SCProductEntry[] findByG_U_PrevAndNext(long productEntryId,
969 long groupId, long userId, OrderByComparator obc)
970 throws NoSuchProductEntryException, SystemException {
971 SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
972
973 int count = countByG_U(groupId, userId);
974
975 Session session = null;
976
977 try {
978 session = openSession();
979
980 StringMaker query = new StringMaker();
981
982 query.append(
983 "FROM com.liferay.portlet.softwarecatalog.model.SCProductEntry WHERE ");
984
985 query.append("groupId = ?");
986
987 query.append(" AND ");
988
989 query.append("userId = ?");
990
991 query.append(" ");
992
993 if (obc != null) {
994 query.append("ORDER BY ");
995 query.append(obc.getOrderBy());
996 }
997
998 else {
999 query.append("ORDER BY ");
1000
1001 query.append("modifiedDate DESC, ");
1002 query.append("name DESC");
1003 }
1004
1005 Query q = session.createQuery(query.toString());
1006
1007 int queryPos = 0;
1008
1009 q.setLong(queryPos++, groupId);
1010
1011 q.setLong(queryPos++, userId);
1012
1013 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1014 scProductEntry);
1015
1016 SCProductEntry[] array = new SCProductEntryImpl[3];
1017
1018 array[0] = (SCProductEntry)objArray[0];
1019 array[1] = (SCProductEntry)objArray[1];
1020 array[2] = (SCProductEntry)objArray[2];
1021
1022 return array;
1023 }
1024 catch (Exception e) {
1025 throw HibernateUtil.processException(e);
1026 }
1027 finally {
1028 closeSession(session);
1029 }
1030 }
1031
1032 public List findWithDynamicQuery(DynamicQueryInitializer queryInitializer)
1033 throws SystemException {
1034 Session session = null;
1035
1036 try {
1037 session = openSession();
1038
1039 DynamicQuery query = queryInitializer.initialize(session);
1040
1041 return query.list();
1042 }
1043 catch (Exception e) {
1044 throw HibernateUtil.processException(e);
1045 }
1046 finally {
1047 closeSession(session);
1048 }
1049 }
1050
1051 public List findWithDynamicQuery(DynamicQueryInitializer queryInitializer,
1052 int begin, int end) throws SystemException {
1053 Session session = null;
1054
1055 try {
1056 session = openSession();
1057
1058 DynamicQuery query = queryInitializer.initialize(session);
1059
1060 query.setLimit(begin, end);
1061
1062 return query.list();
1063 }
1064 catch (Exception e) {
1065 throw HibernateUtil.processException(e);
1066 }
1067 finally {
1068 closeSession(session);
1069 }
1070 }
1071
1072 public List findAll() throws SystemException {
1073 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1074 }
1075
1076 public List findAll(int begin, int end) throws SystemException {
1077 return findAll(begin, end, null);
1078 }
1079
1080 public List findAll(int begin, int end, OrderByComparator obc)
1081 throws SystemException {
1082 boolean finderClassNameCacheEnabled = SCProductEntryModelImpl.CACHE_ENABLED;
1083 String finderClassName = SCProductEntry.class.getName();
1084 String finderMethodName = "findAll";
1085 String[] finderParams = new String[] {
1086 "java.lang.Integer", "java.lang.Integer",
1087 "com.liferay.portal.kernel.util.OrderByComparator"
1088 };
1089 Object[] finderArgs = new Object[] {
1090 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
1091 };
1092
1093 Object result = null;
1094
1095 if (finderClassNameCacheEnabled) {
1096 result = FinderCache.getResult(finderClassName, finderMethodName,
1097 finderParams, finderArgs, getSessionFactory());
1098 }
1099
1100 if (result == null) {
1101 Session session = null;
1102
1103 try {
1104 session = openSession();
1105
1106 StringMaker query = new StringMaker();
1107
1108 query.append(
1109 "FROM com.liferay.portlet.softwarecatalog.model.SCProductEntry ");
1110
1111 if (obc != null) {
1112 query.append("ORDER BY ");
1113 query.append(obc.getOrderBy());
1114 }
1115
1116 else {
1117 query.append("ORDER BY ");
1118
1119 query.append("modifiedDate DESC, ");
1120 query.append("name DESC");
1121 }
1122
1123 Query q = session.createQuery(query.toString());
1124
1125 List list = QueryUtil.list(q, getDialect(), begin, end);
1126
1127 if (obc == null) {
1128 Collections.sort(list);
1129 }
1130
1131 FinderCache.putResult(finderClassNameCacheEnabled,
1132 finderClassName, finderMethodName, finderParams,
1133 finderArgs, list);
1134
1135 return list;
1136 }
1137 catch (Exception e) {
1138 throw HibernateUtil.processException(e);
1139 }
1140 finally {
1141 closeSession(session);
1142 }
1143 }
1144 else {
1145 return (List)result;
1146 }
1147 }
1148
1149 public void removeByGroupId(long groupId) throws SystemException {
1150 Iterator itr = findByGroupId(groupId).iterator();
1151
1152 while (itr.hasNext()) {
1153 SCProductEntry scProductEntry = (SCProductEntry)itr.next();
1154
1155 remove(scProductEntry);
1156 }
1157 }
1158
1159 public void removeByCompanyId(long companyId) throws SystemException {
1160 Iterator itr = findByCompanyId(companyId).iterator();
1161
1162 while (itr.hasNext()) {
1163 SCProductEntry scProductEntry = (SCProductEntry)itr.next();
1164
1165 remove(scProductEntry);
1166 }
1167 }
1168
1169 public void removeByG_U(long groupId, long userId)
1170 throws SystemException {
1171 Iterator itr = findByG_U(groupId, userId).iterator();
1172
1173 while (itr.hasNext()) {
1174 SCProductEntry scProductEntry = (SCProductEntry)itr.next();
1175
1176 remove(scProductEntry);
1177 }
1178 }
1179
1180 public void removeAll() throws SystemException {
1181 Iterator itr = findAll().iterator();
1182
1183 while (itr.hasNext()) {
1184 remove((SCProductEntry)itr.next());
1185 }
1186 }
1187
1188 public int countByGroupId(long groupId) throws SystemException {
1189 boolean finderClassNameCacheEnabled = SCProductEntryModelImpl.CACHE_ENABLED;
1190 String finderClassName = SCProductEntry.class.getName();
1191 String finderMethodName = "countByGroupId";
1192 String[] finderParams = new String[] { Long.class.getName() };
1193 Object[] finderArgs = new Object[] { new Long(groupId) };
1194
1195 Object result = null;
1196
1197 if (finderClassNameCacheEnabled) {
1198 result = FinderCache.getResult(finderClassName, finderMethodName,
1199 finderParams, finderArgs, getSessionFactory());
1200 }
1201
1202 if (result == null) {
1203 Session session = null;
1204
1205 try {
1206 session = openSession();
1207
1208 StringMaker query = new StringMaker();
1209
1210 query.append("SELECT COUNT(*) ");
1211 query.append(
1212 "FROM com.liferay.portlet.softwarecatalog.model.SCProductEntry WHERE ");
1213
1214 query.append("groupId = ?");
1215
1216 query.append(" ");
1217
1218 Query q = session.createQuery(query.toString());
1219
1220 int queryPos = 0;
1221
1222 q.setLong(queryPos++, groupId);
1223
1224 Long count = null;
1225
1226 Iterator itr = q.list().iterator();
1227
1228 if (itr.hasNext()) {
1229 count = (Long)itr.next();
1230 }
1231
1232 if (count == null) {
1233 count = new Long(0);
1234 }
1235
1236 FinderCache.putResult(finderClassNameCacheEnabled,
1237 finderClassName, finderMethodName, finderParams,
1238 finderArgs, count);
1239
1240 return count.intValue();
1241 }
1242 catch (Exception e) {
1243 throw HibernateUtil.processException(e);
1244 }
1245 finally {
1246 closeSession(session);
1247 }
1248 }
1249 else {
1250 return ((Long)result).intValue();
1251 }
1252 }
1253
1254 public int countByCompanyId(long companyId) throws SystemException {
1255 boolean finderClassNameCacheEnabled = SCProductEntryModelImpl.CACHE_ENABLED;
1256 String finderClassName = SCProductEntry.class.getName();
1257 String finderMethodName = "countByCompanyId";
1258 String[] finderParams = new String[] { Long.class.getName() };
1259 Object[] finderArgs = new Object[] { new Long(companyId) };
1260
1261 Object result = null;
1262
1263 if (finderClassNameCacheEnabled) {
1264 result = FinderCache.getResult(finderClassName, finderMethodName,
1265 finderParams, finderArgs, getSessionFactory());
1266 }
1267
1268 if (result == null) {
1269 Session session = null;
1270
1271 try {
1272 session = openSession();
1273
1274 StringMaker query = new StringMaker();
1275
1276 query.append("SELECT COUNT(*) ");
1277 query.append(
1278 "FROM com.liferay.portlet.softwarecatalog.model.SCProductEntry WHERE ");
1279
1280 query.append("companyId = ?");
1281
1282 query.append(" ");
1283
1284 Query q = session.createQuery(query.toString());
1285
1286 int queryPos = 0;
1287
1288 q.setLong(queryPos++, companyId);
1289
1290 Long count = null;
1291
1292 Iterator itr = q.list().iterator();
1293
1294 if (itr.hasNext()) {
1295 count = (Long)itr.next();
1296 }
1297
1298 if (count == null) {
1299 count = new Long(0);
1300 }
1301
1302 FinderCache.putResult(finderClassNameCacheEnabled,
1303 finderClassName, finderMethodName, finderParams,
1304 finderArgs, count);
1305
1306 return count.intValue();
1307 }
1308 catch (Exception e) {
1309 throw HibernateUtil.processException(e);
1310 }
1311 finally {
1312 closeSession(session);
1313 }
1314 }
1315 else {
1316 return ((Long)result).intValue();
1317 }
1318 }
1319
1320 public int countByG_U(long groupId, long userId) throws SystemException {
1321 boolean finderClassNameCacheEnabled = SCProductEntryModelImpl.CACHE_ENABLED;
1322 String finderClassName = SCProductEntry.class.getName();
1323 String finderMethodName = "countByG_U";
1324 String[] finderParams = new String[] {
1325 Long.class.getName(), Long.class.getName()
1326 };
1327 Object[] finderArgs = new Object[] { new Long(groupId), new Long(userId) };
1328
1329 Object result = null;
1330
1331 if (finderClassNameCacheEnabled) {
1332 result = FinderCache.getResult(finderClassName, finderMethodName,
1333 finderParams, finderArgs, getSessionFactory());
1334 }
1335
1336 if (result == null) {
1337 Session session = null;
1338
1339 try {
1340 session = openSession();
1341
1342 StringMaker query = new StringMaker();
1343
1344 query.append("SELECT COUNT(*) ");
1345 query.append(
1346 "FROM com.liferay.portlet.softwarecatalog.model.SCProductEntry WHERE ");
1347
1348 query.append("groupId = ?");
1349
1350 query.append(" AND ");
1351
1352 query.append("userId = ?");
1353
1354 query.append(" ");
1355
1356 Query q = session.createQuery(query.toString());
1357
1358 int queryPos = 0;
1359
1360 q.setLong(queryPos++, groupId);
1361
1362 q.setLong(queryPos++, userId);
1363
1364 Long count = null;
1365
1366 Iterator itr = q.list().iterator();
1367
1368 if (itr.hasNext()) {
1369 count = (Long)itr.next();
1370 }
1371
1372 if (count == null) {
1373 count = new Long(0);
1374 }
1375
1376 FinderCache.putResult(finderClassNameCacheEnabled,
1377 finderClassName, finderMethodName, finderParams,
1378 finderArgs, count);
1379
1380 return count.intValue();
1381 }
1382 catch (Exception e) {
1383 throw HibernateUtil.processException(e);
1384 }
1385 finally {
1386 closeSession(session);
1387 }
1388 }
1389 else {
1390 return ((Long)result).intValue();
1391 }
1392 }
1393
1394 public int countAll() throws SystemException {
1395 boolean finderClassNameCacheEnabled = SCProductEntryModelImpl.CACHE_ENABLED;
1396 String finderClassName = SCProductEntry.class.getName();
1397 String finderMethodName = "countAll";
1398 String[] finderParams = new String[] { };
1399 Object[] finderArgs = new Object[] { };
1400
1401 Object result = null;
1402
1403 if (finderClassNameCacheEnabled) {
1404 result = FinderCache.getResult(finderClassName, finderMethodName,
1405 finderParams, finderArgs, getSessionFactory());
1406 }
1407
1408 if (result == null) {
1409 Session session = null;
1410
1411 try {
1412 session = openSession();
1413
1414 Query q = session.createQuery(
1415 "SELECT COUNT(*) FROM com.liferay.portlet.softwarecatalog.model.SCProductEntry");
1416
1417 Long count = null;
1418
1419 Iterator itr = q.list().iterator();
1420
1421 if (itr.hasNext()) {
1422 count = (Long)itr.next();
1423 }
1424
1425 if (count == null) {
1426 count = new Long(0);
1427 }
1428
1429 FinderCache.putResult(finderClassNameCacheEnabled,
1430 finderClassName, finderMethodName, finderParams,
1431 finderArgs, count);
1432
1433 return count.intValue();
1434 }
1435 catch (Exception e) {
1436 throw HibernateUtil.processException(e);
1437 }
1438 finally {
1439 closeSession(session);
1440 }
1441 }
1442 else {
1443 return ((Long)result).intValue();
1444 }
1445 }
1446
1447 public List getSCLicenses(long pk)
1448 throws NoSuchProductEntryException, SystemException {
1449 return getSCLicenses(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1450 }
1451
1452 public List getSCLicenses(long pk, int begin, int end)
1453 throws NoSuchProductEntryException, SystemException {
1454 return getSCLicenses(pk, begin, end, null);
1455 }
1456
1457 public List getSCLicenses(long pk, int begin, int end, OrderByComparator obc)
1458 throws NoSuchProductEntryException, SystemException {
1459 boolean finderClassNameCacheEnabled = SCProductEntryModelImpl.CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES;
1460 String finderClassName = "SCLicenses_SCProductEntries";
1461 String finderMethodName = "getSCLicenses";
1462 String[] finderParams = new String[] {
1463 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1464 "com.liferay.portal.kernel.util.OrderByComparator"
1465 };
1466 Object[] finderArgs = new Object[] {
1467 new Long(pk), String.valueOf(begin), String.valueOf(end),
1468 String.valueOf(obc)
1469 };
1470
1471 Object result = null;
1472
1473 if (finderClassNameCacheEnabled) {
1474 result = FinderCache.getResult(finderClassName, finderMethodName,
1475 finderParams, finderArgs, getSessionFactory());
1476 }
1477
1478 if (result == null) {
1479 Session session = null;
1480
1481 try {
1482 session = HibernateUtil.openSession();
1483
1484 StringMaker sm = new StringMaker();
1485
1486 sm.append(_SQL_GETSCLICENSES);
1487
1488 if (obc != null) {
1489 sm.append("ORDER BY ");
1490 sm.append(obc.getOrderBy());
1491 }
1492
1493 else {
1494 sm.append("ORDER BY ");
1495
1496 sm.append("SCLicense.name ASC");
1497 }
1498
1499 String sql = sm.toString();
1500
1501 SQLQuery q = session.createSQLQuery(sql);
1502
1503 q.addEntity("SCLicense",
1504 com.liferay.portlet.softwarecatalog.model.impl.SCLicenseImpl.class);
1505
1506 QueryPos qPos = QueryPos.getInstance(q);
1507
1508 qPos.add(pk);
1509
1510 List list = QueryUtil.list(q, getDialect(), begin, end);
1511
1512 FinderCache.putResult(finderClassNameCacheEnabled,
1513 finderClassName, finderMethodName, finderParams,
1514 finderArgs, list);
1515
1516 return list;
1517 }
1518 catch (Exception e) {
1519 throw new SystemException(e);
1520 }
1521 finally {
1522 closeSession(session);
1523 }
1524 }
1525 else {
1526 return (List)result;
1527 }
1528 }
1529
1530 public int getSCLicensesSize(long pk) throws SystemException {
1531 boolean finderClassNameCacheEnabled = SCProductEntryModelImpl.CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES;
1532 String finderClassName = "SCLicenses_SCProductEntries";
1533 String finderMethodName = "getSCLicensesSize";
1534 String[] finderParams = new String[] { Long.class.getName() };
1535 Object[] finderArgs = new Object[] { new Long(pk) };
1536
1537 Object result = null;
1538
1539 if (finderClassNameCacheEnabled) {
1540 result = FinderCache.getResult(finderClassName, finderMethodName,
1541 finderParams, finderArgs, getSessionFactory());
1542 }
1543
1544 if (result == null) {
1545 Session session = null;
1546
1547 try {
1548 session = openSession();
1549
1550 SQLQuery q = session.createSQLQuery(_SQL_GETSCLICENSESSIZE);
1551
1552 q.addScalar(HibernateUtil.getCountColumnName(), Hibernate.LONG);
1553
1554 QueryPos qPos = QueryPos.getInstance(q);
1555
1556 qPos.add(pk);
1557
1558 Long count = null;
1559
1560 Iterator itr = q.list().iterator();
1561
1562 if (itr.hasNext()) {
1563 count = (Long)itr.next();
1564 }
1565
1566 if (count == null) {
1567 count = new Long(0);
1568 }
1569
1570 FinderCache.putResult(finderClassNameCacheEnabled,
1571 finderClassName, finderMethodName, finderParams,
1572 finderArgs, count);
1573
1574 return count.intValue();
1575 }
1576 catch (Exception e) {
1577 throw HibernateUtil.processException(e);
1578 }
1579 finally {
1580 closeSession(session);
1581 }
1582 }
1583 else {
1584 return ((Long)result).intValue();
1585 }
1586 }
1587
1588 public boolean containsSCLicense(long pk, long scLicensePK)
1589 throws SystemException {
1590 boolean finderClassNameCacheEnabled = SCProductEntryModelImpl.CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES;
1591 String finderClassName = "SCLicenses_SCProductEntries";
1592 String finderMethodName = "containsSCLicenses";
1593 String[] finderParams = new String[] {
1594 Long.class.getName(),
1595
1596 Long.class.getName()
1597 };
1598 Object[] finderArgs = new Object[] { new Long(pk), new Long(scLicensePK) };
1599
1600 Object result = null;
1601
1602 if (finderClassNameCacheEnabled) {
1603 result = FinderCache.getResult(finderClassName, finderMethodName,
1604 finderParams, finderArgs, getSessionFactory());
1605 }
1606
1607 if (result == null) {
1608 try {
1609 Boolean value = Boolean.valueOf(containsSCLicense.contains(pk,
1610 scLicensePK));
1611
1612 FinderCache.putResult(finderClassNameCacheEnabled,
1613 finderClassName, finderMethodName, finderParams,
1614 finderArgs, value);
1615
1616 return value.booleanValue();
1617 }
1618 catch (DataAccessException dae) {
1619 throw new SystemException(dae);
1620 }
1621 }
1622 else {
1623 return ((Boolean)result).booleanValue();
1624 }
1625 }
1626
1627 public boolean containsSCLicenses(long pk) throws SystemException {
1628 if (getSCLicensesSize(pk) > 0) {
1629 return true;
1630 }
1631 else {
1632 return false;
1633 }
1634 }
1635
1636 public void addSCLicense(long pk, long scLicensePK)
1637 throws NoSuchProductEntryException,
1638 com.liferay.portlet.softwarecatalog.NoSuchLicenseException,
1639 SystemException {
1640 try {
1641 addSCLicense.add(pk, scLicensePK);
1642 }
1643 catch (DataAccessException dae) {
1644 throw new SystemException(dae);
1645 }
1646 finally {
1647 FinderCache.clearCache("SCLicenses_SCProductEntries");
1648 }
1649 }
1650
1651 public void addSCLicense(long pk,
1652 com.liferay.portlet.softwarecatalog.model.SCLicense scLicense)
1653 throws NoSuchProductEntryException,
1654 com.liferay.portlet.softwarecatalog.NoSuchLicenseException,
1655 SystemException {
1656 try {
1657 addSCLicense.add(pk, scLicense.getPrimaryKey());
1658 }
1659 catch (DataAccessException dae) {
1660 throw new SystemException(dae);
1661 }
1662 finally {
1663 FinderCache.clearCache("SCLicenses_SCProductEntries");
1664 }
1665 }
1666
1667 public void addSCLicenses(long pk, long[] scLicensePKs)
1668 throws NoSuchProductEntryException,
1669 com.liferay.portlet.softwarecatalog.NoSuchLicenseException,
1670 SystemException {
1671 try {
1672 for (int i = 0; i < scLicensePKs.length; i++) {
1673 addSCLicense.add(pk, scLicensePKs[i]);
1674 }
1675 }
1676 catch (DataAccessException dae) {
1677 throw new SystemException(dae);
1678 }
1679 finally {
1680 FinderCache.clearCache("SCLicenses_SCProductEntries");
1681 }
1682 }
1683
1684 public void addSCLicenses(long pk, List scLicenses)
1685 throws NoSuchProductEntryException,
1686 com.liferay.portlet.softwarecatalog.NoSuchLicenseException,
1687 SystemException {
1688 try {
1689 for (int i = 0; i < scLicenses.size(); i++) {
1690 com.liferay.portlet.softwarecatalog.model.SCLicense scLicense = (com.liferay.portlet.softwarecatalog.model.SCLicense)scLicenses.get(i);
1691
1692 addSCLicense.add(pk, scLicense.getPrimaryKey());
1693 }
1694 }
1695 catch (DataAccessException dae) {
1696 throw new SystemException(dae);
1697 }
1698 finally {
1699 FinderCache.clearCache("SCLicenses_SCProductEntries");
1700 }
1701 }
1702
1703 public void clearSCLicenses(long pk)
1704 throws NoSuchProductEntryException, SystemException {
1705 try {
1706 clearSCLicenses.clear(pk);
1707 }
1708 catch (DataAccessException dae) {
1709 throw new SystemException(dae);
1710 }
1711 finally {
1712 FinderCache.clearCache("SCLicenses_SCProductEntries");
1713 }
1714 }
1715
1716 public void removeSCLicense(long pk, long scLicensePK)
1717 throws NoSuchProductEntryException,
1718 com.liferay.portlet.softwarecatalog.NoSuchLicenseException,
1719 SystemException {
1720 try {
1721 removeSCLicense.remove(pk, scLicensePK);
1722 }
1723 catch (DataAccessException dae) {
1724 throw new SystemException(dae);
1725 }
1726 finally {
1727 FinderCache.clearCache("SCLicenses_SCProductEntries");
1728 }
1729 }
1730
1731 public void removeSCLicense(long pk,
1732 com.liferay.portlet.softwarecatalog.model.SCLicense scLicense)
1733 throws NoSuchProductEntryException,
1734 com.liferay.portlet.softwarecatalog.NoSuchLicenseException,
1735 SystemException {
1736 try {
1737 removeSCLicense.remove(pk, scLicense.getPrimaryKey());
1738 }
1739 catch (DataAccessException dae) {
1740 throw new SystemException(dae);
1741 }
1742 finally {
1743 FinderCache.clearCache("SCLicenses_SCProductEntries");
1744 }
1745 }
1746
1747 public void removeSCLicenses(long pk, long[] scLicensePKs)
1748 throws NoSuchProductEntryException,
1749 com.liferay.portlet.softwarecatalog.NoSuchLicenseException,
1750 SystemException {
1751 try {
1752 for (int i = 0; i < scLicensePKs.length; i++) {
1753 removeSCLicense.remove(pk, scLicensePKs[i]);
1754 }
1755 }
1756 catch (DataAccessException dae) {
1757 throw new SystemException(dae);
1758 }
1759 finally {
1760 FinderCache.clearCache("SCLicenses_SCProductEntries");
1761 }
1762 }
1763
1764 public void removeSCLicenses(long pk, List scLicenses)
1765 throws NoSuchProductEntryException,
1766 com.liferay.portlet.softwarecatalog.NoSuchLicenseException,
1767 SystemException {
1768 try {
1769 for (int i = 0; i < scLicenses.size(); i++) {
1770 com.liferay.portlet.softwarecatalog.model.SCLicense scLicense = (com.liferay.portlet.softwarecatalog.model.SCLicense)scLicenses.get(i);
1771
1772 removeSCLicense.remove(pk, scLicense.getPrimaryKey());
1773 }
1774 }
1775 catch (DataAccessException dae) {
1776 throw new SystemException(dae);
1777 }
1778 finally {
1779 FinderCache.clearCache("SCLicenses_SCProductEntries");
1780 }
1781 }
1782
1783 public void setSCLicenses(long pk, long[] scLicensePKs)
1784 throws NoSuchProductEntryException,
1785 com.liferay.portlet.softwarecatalog.NoSuchLicenseException,
1786 SystemException {
1787 try {
1788 clearSCLicenses.clear(pk);
1789
1790 for (int i = 0; i < scLicensePKs.length; i++) {
1791 addSCLicense.add(pk, scLicensePKs[i]);
1792 }
1793 }
1794 catch (DataAccessException dae) {
1795 throw new SystemException(dae);
1796 }
1797 finally {
1798 FinderCache.clearCache("SCLicenses_SCProductEntries");
1799 }
1800 }
1801
1802 public void setSCLicenses(long pk, List scLicenses)
1803 throws NoSuchProductEntryException,
1804 com.liferay.portlet.softwarecatalog.NoSuchLicenseException,
1805 SystemException {
1806 try {
1807 clearSCLicenses.clear(pk);
1808
1809 for (int i = 0; i < scLicenses.size(); i++) {
1810 com.liferay.portlet.softwarecatalog.model.SCLicense scLicense = (com.liferay.portlet.softwarecatalog.model.SCLicense)scLicenses.get(i);
1811
1812 addSCLicense.add(pk, scLicense.getPrimaryKey());
1813 }
1814 }
1815 catch (DataAccessException dae) {
1816 throw new SystemException(dae);
1817 }
1818 finally {
1819 FinderCache.clearCache("SCLicenses_SCProductEntries");
1820 }
1821 }
1822
1823 protected void initDao() {
1824 containsSCLicense = new ContainsSCLicense(this);
1825
1826 addSCLicense = new AddSCLicense(this);
1827 clearSCLicenses = new ClearSCLicenses(this);
1828 removeSCLicense = new RemoveSCLicense(this);
1829 }
1830
1831 protected ContainsSCLicense containsSCLicense;
1832 protected AddSCLicense addSCLicense;
1833 protected ClearSCLicenses clearSCLicenses;
1834 protected RemoveSCLicense removeSCLicense;
1835
1836 protected class ContainsSCLicense extends MappingSqlQuery {
1837 protected ContainsSCLicense(
1838 SCProductEntryPersistenceImpl persistenceImpl) {
1839 super(persistenceImpl.getDataSource(), _SQL_CONTAINSSCLICENSE);
1840
1841 declareParameter(new SqlParameter(Types.BIGINT));
1842 declareParameter(new SqlParameter(Types.BIGINT));
1843
1844 compile();
1845 }
1846
1847 protected Object mapRow(ResultSet rs, int rowNumber)
1848 throws SQLException {
1849 return new Integer(rs.getInt("COUNT_VALUE"));
1850 }
1851
1852 protected boolean contains(long productEntryId, long licenseId) {
1853 List results = execute(new Object[] {
1854 new Long(productEntryId), new Long(licenseId)
1855 });
1856
1857 if (results.size() > 0) {
1858 Integer count = (Integer)results.get(0);
1859
1860 if (count.intValue() > 0) {
1861 return true;
1862 }
1863 }
1864
1865 return false;
1866 }
1867 }
1868
1869 protected class AddSCLicense extends SqlUpdate {
1870 protected AddSCLicense(SCProductEntryPersistenceImpl persistenceImpl) {
1871 super(persistenceImpl.getDataSource(),
1872 "INSERT INTO SCLicenses_SCProductEntries (productEntryId, licenseId) VALUES (?, ?)");
1873
1874 _persistenceImpl = persistenceImpl;
1875
1876 declareParameter(new SqlParameter(Types.BIGINT));
1877 declareParameter(new SqlParameter(Types.BIGINT));
1878
1879 compile();
1880 }
1881
1882 protected void add(long productEntryId, long licenseId) {
1883 if (!_persistenceImpl.containsSCLicense.contains(productEntryId,
1884 licenseId)) {
1885 update(new Object[] {
1886 new Long(productEntryId), new Long(licenseId)
1887 });
1888 }
1889 }
1890
1891 private SCProductEntryPersistenceImpl _persistenceImpl;
1892 }
1893
1894 protected class ClearSCLicenses extends SqlUpdate {
1895 protected ClearSCLicenses(SCProductEntryPersistenceImpl persistenceImpl) {
1896 super(persistenceImpl.getDataSource(),
1897 "DELETE FROM SCLicenses_SCProductEntries WHERE productEntryId = ?");
1898
1899 declareParameter(new SqlParameter(Types.BIGINT));
1900
1901 compile();
1902 }
1903
1904 protected void clear(long productEntryId) {
1905 update(new Object[] { new Long(productEntryId) });
1906 }
1907 }
1908
1909 protected class RemoveSCLicense extends SqlUpdate {
1910 protected RemoveSCLicense(SCProductEntryPersistenceImpl persistenceImpl) {
1911 super(persistenceImpl.getDataSource(),
1912 "DELETE FROM SCLicenses_SCProductEntries WHERE productEntryId = ? AND licenseId = ?");
1913
1914 declareParameter(new SqlParameter(Types.BIGINT));
1915 declareParameter(new SqlParameter(Types.BIGINT));
1916
1917 compile();
1918 }
1919
1920 protected void remove(long productEntryId, long licenseId) {
1921 update(new Object[] { new Long(productEntryId), new Long(licenseId) });
1922 }
1923 }
1924
1925 private static ModelListener _getListener() {
1926 if (Validator.isNotNull(_LISTENER)) {
1927 try {
1928 return (ModelListener)Class.forName(_LISTENER).newInstance();
1929 }
1930 catch (Exception e) {
1931 _log.error(e);
1932 }
1933 }
1934
1935 return null;
1936 }
1937
1938 private static final String _SQL_GETSCLICENSES = "SELECT {SCLicense.*} FROM SCLicense INNER JOIN SCLicenses_SCProductEntries ON (SCLicenses_SCProductEntries.licenseId = SCLicense.licenseId) WHERE (SCLicenses_SCProductEntries.productEntryId = ?)";
1939 private static final String _SQL_GETSCLICENSESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE productEntryId = ?";
1940 private static final String _SQL_CONTAINSSCLICENSE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE productEntryId = ? AND licenseId = ?";
1941 private static final String _LISTENER = GetterUtil.getString(PropsUtil.get(
1942 "value.object.listener.com.liferay.portlet.softwarecatalog.model.SCProductEntry"));
1943 private static Log _log = LogFactory.getLog(SCProductEntryPersistenceImpl.class);
1944}