001
014
015 package com.liferay.portlet.softwarecatalog.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.bean.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
021 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
022 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
023 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
024 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
025 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
026 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
027 import com.liferay.portal.kernel.dao.orm.FinderPath;
028 import com.liferay.portal.kernel.dao.orm.Query;
029 import com.liferay.portal.kernel.dao.orm.QueryPos;
030 import com.liferay.portal.kernel.dao.orm.QueryUtil;
031 import com.liferay.portal.kernel.dao.orm.SQLQuery;
032 import com.liferay.portal.kernel.dao.orm.Session;
033 import com.liferay.portal.kernel.exception.SystemException;
034 import com.liferay.portal.kernel.log.Log;
035 import com.liferay.portal.kernel.log.LogFactoryUtil;
036 import com.liferay.portal.kernel.util.GetterUtil;
037 import com.liferay.portal.kernel.util.InstanceFactory;
038 import com.liferay.portal.kernel.util.OrderByComparator;
039 import com.liferay.portal.kernel.util.SetUtil;
040 import com.liferay.portal.kernel.util.StringBundler;
041 import com.liferay.portal.kernel.util.StringPool;
042 import com.liferay.portal.kernel.util.StringUtil;
043 import com.liferay.portal.kernel.util.UnmodifiableList;
044 import com.liferay.portal.model.CacheModel;
045 import com.liferay.portal.model.ModelListener;
046 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
047 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
048
049 import com.liferay.portlet.softwarecatalog.NoSuchLicenseException;
050 import com.liferay.portlet.softwarecatalog.model.SCLicense;
051 import com.liferay.portlet.softwarecatalog.model.impl.SCLicenseImpl;
052 import com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl;
053
054 import java.io.Serializable;
055
056 import java.util.ArrayList;
057 import java.util.Collections;
058 import java.util.List;
059 import java.util.Set;
060
061
073 public class SCLicensePersistenceImpl extends BasePersistenceImpl<SCLicense>
074 implements SCLicensePersistence {
075
080 public static final String FINDER_CLASS_NAME_ENTITY = SCLicenseImpl.class.getName();
081 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
082 ".List1";
083 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
084 ".List2";
085 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
086 SCLicenseModelImpl.FINDER_CACHE_ENABLED, SCLicenseImpl.class,
087 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
088 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
089 SCLicenseModelImpl.FINDER_CACHE_ENABLED, SCLicenseImpl.class,
090 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
091 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
092 SCLicenseModelImpl.FINDER_CACHE_ENABLED, Long.class,
093 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
094 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_ACTIVE = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
095 SCLicenseModelImpl.FINDER_CACHE_ENABLED, SCLicenseImpl.class,
096 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByActive",
097 new String[] {
098 Boolean.class.getName(),
099
100 Integer.class.getName(), Integer.class.getName(),
101 OrderByComparator.class.getName()
102 });
103 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE =
104 new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
105 SCLicenseModelImpl.FINDER_CACHE_ENABLED, SCLicenseImpl.class,
106 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByActive",
107 new String[] { Boolean.class.getName() },
108 SCLicenseModelImpl.ACTIVE_COLUMN_BITMASK |
109 SCLicenseModelImpl.NAME_COLUMN_BITMASK);
110 public static final FinderPath FINDER_PATH_COUNT_BY_ACTIVE = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
111 SCLicenseModelImpl.FINDER_CACHE_ENABLED, Long.class,
112 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByActive",
113 new String[] { Boolean.class.getName() });
114
115
122 public List<SCLicense> findByActive(boolean active)
123 throws SystemException {
124 return findByActive(active, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
125 }
126
127
140 public List<SCLicense> findByActive(boolean active, int start, int end)
141 throws SystemException {
142 return findByActive(active, start, end, null);
143 }
144
145
159 public List<SCLicense> findByActive(boolean active, int start, int end,
160 OrderByComparator orderByComparator) throws SystemException {
161 boolean pagination = true;
162 FinderPath finderPath = null;
163 Object[] finderArgs = null;
164
165 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
166 (orderByComparator == null)) {
167 pagination = false;
168 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE;
169 finderArgs = new Object[] { active };
170 }
171 else {
172 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_ACTIVE;
173 finderArgs = new Object[] { active, start, end, orderByComparator };
174 }
175
176 List<SCLicense> list = (List<SCLicense>)FinderCacheUtil.getResult(finderPath,
177 finderArgs, this);
178
179 if ((list != null) && !list.isEmpty()) {
180 for (SCLicense scLicense : list) {
181 if ((active != scLicense.getActive())) {
182 list = null;
183
184 break;
185 }
186 }
187 }
188
189 if (list == null) {
190 StringBundler query = null;
191
192 if (orderByComparator != null) {
193 query = new StringBundler(3 +
194 (orderByComparator.getOrderByFields().length * 3));
195 }
196 else {
197 query = new StringBundler(3);
198 }
199
200 query.append(_SQL_SELECT_SCLICENSE_WHERE);
201
202 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
203
204 if (orderByComparator != null) {
205 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
206 orderByComparator);
207 }
208 else
209 if (pagination) {
210 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
211 }
212
213 String sql = query.toString();
214
215 Session session = null;
216
217 try {
218 session = openSession();
219
220 Query q = session.createQuery(sql);
221
222 QueryPos qPos = QueryPos.getInstance(q);
223
224 qPos.add(active);
225
226 if (!pagination) {
227 list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
228 start, end, false);
229
230 Collections.sort(list);
231
232 list = new UnmodifiableList<SCLicense>(list);
233 }
234 else {
235 list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
236 start, end);
237 }
238
239 cacheResult(list);
240
241 FinderCacheUtil.putResult(finderPath, finderArgs, list);
242 }
243 catch (Exception e) {
244 FinderCacheUtil.removeResult(finderPath, finderArgs);
245
246 throw processException(e);
247 }
248 finally {
249 closeSession(session);
250 }
251 }
252
253 return list;
254 }
255
256
265 public SCLicense findByActive_First(boolean active,
266 OrderByComparator orderByComparator)
267 throws NoSuchLicenseException, SystemException {
268 SCLicense scLicense = fetchByActive_First(active, orderByComparator);
269
270 if (scLicense != null) {
271 return scLicense;
272 }
273
274 StringBundler msg = new StringBundler(4);
275
276 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
277
278 msg.append("active=");
279 msg.append(active);
280
281 msg.append(StringPool.CLOSE_CURLY_BRACE);
282
283 throw new NoSuchLicenseException(msg.toString());
284 }
285
286
294 public SCLicense fetchByActive_First(boolean active,
295 OrderByComparator orderByComparator) throws SystemException {
296 List<SCLicense> list = findByActive(active, 0, 1, orderByComparator);
297
298 if (!list.isEmpty()) {
299 return list.get(0);
300 }
301
302 return null;
303 }
304
305
314 public SCLicense findByActive_Last(boolean active,
315 OrderByComparator orderByComparator)
316 throws NoSuchLicenseException, SystemException {
317 SCLicense scLicense = fetchByActive_Last(active, orderByComparator);
318
319 if (scLicense != null) {
320 return scLicense;
321 }
322
323 StringBundler msg = new StringBundler(4);
324
325 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
326
327 msg.append("active=");
328 msg.append(active);
329
330 msg.append(StringPool.CLOSE_CURLY_BRACE);
331
332 throw new NoSuchLicenseException(msg.toString());
333 }
334
335
343 public SCLicense fetchByActive_Last(boolean active,
344 OrderByComparator orderByComparator) throws SystemException {
345 int count = countByActive(active);
346
347 List<SCLicense> list = findByActive(active, count - 1, count,
348 orderByComparator);
349
350 if (!list.isEmpty()) {
351 return list.get(0);
352 }
353
354 return null;
355 }
356
357
367 public SCLicense[] findByActive_PrevAndNext(long licenseId, boolean active,
368 OrderByComparator orderByComparator)
369 throws NoSuchLicenseException, SystemException {
370 SCLicense scLicense = findByPrimaryKey(licenseId);
371
372 Session session = null;
373
374 try {
375 session = openSession();
376
377 SCLicense[] array = new SCLicenseImpl[3];
378
379 array[0] = getByActive_PrevAndNext(session, scLicense, active,
380 orderByComparator, true);
381
382 array[1] = scLicense;
383
384 array[2] = getByActive_PrevAndNext(session, scLicense, active,
385 orderByComparator, false);
386
387 return array;
388 }
389 catch (Exception e) {
390 throw processException(e);
391 }
392 finally {
393 closeSession(session);
394 }
395 }
396
397 protected SCLicense getByActive_PrevAndNext(Session session,
398 SCLicense scLicense, boolean active,
399 OrderByComparator orderByComparator, boolean previous) {
400 StringBundler query = null;
401
402 if (orderByComparator != null) {
403 query = new StringBundler(6 +
404 (orderByComparator.getOrderByFields().length * 6));
405 }
406 else {
407 query = new StringBundler(3);
408 }
409
410 query.append(_SQL_SELECT_SCLICENSE_WHERE);
411
412 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
413
414 if (orderByComparator != null) {
415 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
416
417 if (orderByConditionFields.length > 0) {
418 query.append(WHERE_AND);
419 }
420
421 for (int i = 0; i < orderByConditionFields.length; i++) {
422 query.append(_ORDER_BY_ENTITY_ALIAS);
423 query.append(orderByConditionFields[i]);
424
425 if ((i + 1) < orderByConditionFields.length) {
426 if (orderByComparator.isAscending() ^ previous) {
427 query.append(WHERE_GREATER_THAN_HAS_NEXT);
428 }
429 else {
430 query.append(WHERE_LESSER_THAN_HAS_NEXT);
431 }
432 }
433 else {
434 if (orderByComparator.isAscending() ^ previous) {
435 query.append(WHERE_GREATER_THAN);
436 }
437 else {
438 query.append(WHERE_LESSER_THAN);
439 }
440 }
441 }
442
443 query.append(ORDER_BY_CLAUSE);
444
445 String[] orderByFields = orderByComparator.getOrderByFields();
446
447 for (int i = 0; i < orderByFields.length; i++) {
448 query.append(_ORDER_BY_ENTITY_ALIAS);
449 query.append(orderByFields[i]);
450
451 if ((i + 1) < orderByFields.length) {
452 if (orderByComparator.isAscending() ^ previous) {
453 query.append(ORDER_BY_ASC_HAS_NEXT);
454 }
455 else {
456 query.append(ORDER_BY_DESC_HAS_NEXT);
457 }
458 }
459 else {
460 if (orderByComparator.isAscending() ^ previous) {
461 query.append(ORDER_BY_ASC);
462 }
463 else {
464 query.append(ORDER_BY_DESC);
465 }
466 }
467 }
468 }
469 else {
470 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
471 }
472
473 String sql = query.toString();
474
475 Query q = session.createQuery(sql);
476
477 q.setFirstResult(0);
478 q.setMaxResults(2);
479
480 QueryPos qPos = QueryPos.getInstance(q);
481
482 qPos.add(active);
483
484 if (orderByComparator != null) {
485 Object[] values = orderByComparator.getOrderByConditionValues(scLicense);
486
487 for (Object value : values) {
488 qPos.add(value);
489 }
490 }
491
492 List<SCLicense> list = q.list();
493
494 if (list.size() == 2) {
495 return list.get(1);
496 }
497 else {
498 return null;
499 }
500 }
501
502
509 public List<SCLicense> filterFindByActive(boolean active)
510 throws SystemException {
511 return filterFindByActive(active, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
512 null);
513 }
514
515
528 public List<SCLicense> filterFindByActive(boolean active, int start, int end)
529 throws SystemException {
530 return filterFindByActive(active, start, end, null);
531 }
532
533
547 public List<SCLicense> filterFindByActive(boolean active, int start,
548 int end, OrderByComparator orderByComparator) throws SystemException {
549 if (!InlineSQLHelperUtil.isEnabled()) {
550 return findByActive(active, start, end, orderByComparator);
551 }
552
553 StringBundler query = null;
554
555 if (orderByComparator != null) {
556 query = new StringBundler(3 +
557 (orderByComparator.getOrderByFields().length * 3));
558 }
559 else {
560 query = new StringBundler(3);
561 }
562
563 if (getDB().isSupportsInlineDistinct()) {
564 query.append(_FILTER_SQL_SELECT_SCLICENSE_WHERE);
565 }
566 else {
567 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1);
568 }
569
570 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
571
572 if (!getDB().isSupportsInlineDistinct()) {
573 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2);
574 }
575
576 if (orderByComparator != null) {
577 if (getDB().isSupportsInlineDistinct()) {
578 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
579 orderByComparator);
580 }
581 else {
582 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
583 orderByComparator);
584 }
585 }
586 else {
587 if (getDB().isSupportsInlineDistinct()) {
588 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
589 }
590 else {
591 query.append(SCLicenseModelImpl.ORDER_BY_SQL);
592 }
593 }
594
595 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
596 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
597
598 Session session = null;
599
600 try {
601 session = openSession();
602
603 SQLQuery q = session.createSQLQuery(sql);
604
605 if (getDB().isSupportsInlineDistinct()) {
606 q.addEntity(_FILTER_ENTITY_ALIAS, SCLicenseImpl.class);
607 }
608 else {
609 q.addEntity(_FILTER_ENTITY_TABLE, SCLicenseImpl.class);
610 }
611
612 QueryPos qPos = QueryPos.getInstance(q);
613
614 qPos.add(active);
615
616 return (List<SCLicense>)QueryUtil.list(q, getDialect(), start, end);
617 }
618 catch (Exception e) {
619 throw processException(e);
620 }
621 finally {
622 closeSession(session);
623 }
624 }
625
626
636 public SCLicense[] filterFindByActive_PrevAndNext(long licenseId,
637 boolean active, OrderByComparator orderByComparator)
638 throws NoSuchLicenseException, SystemException {
639 if (!InlineSQLHelperUtil.isEnabled()) {
640 return findByActive_PrevAndNext(licenseId, active, orderByComparator);
641 }
642
643 SCLicense scLicense = findByPrimaryKey(licenseId);
644
645 Session session = null;
646
647 try {
648 session = openSession();
649
650 SCLicense[] array = new SCLicenseImpl[3];
651
652 array[0] = filterGetByActive_PrevAndNext(session, scLicense,
653 active, orderByComparator, true);
654
655 array[1] = scLicense;
656
657 array[2] = filterGetByActive_PrevAndNext(session, scLicense,
658 active, orderByComparator, false);
659
660 return array;
661 }
662 catch (Exception e) {
663 throw processException(e);
664 }
665 finally {
666 closeSession(session);
667 }
668 }
669
670 protected SCLicense filterGetByActive_PrevAndNext(Session session,
671 SCLicense scLicense, boolean active,
672 OrderByComparator orderByComparator, boolean previous) {
673 StringBundler query = null;
674
675 if (orderByComparator != null) {
676 query = new StringBundler(6 +
677 (orderByComparator.getOrderByFields().length * 6));
678 }
679 else {
680 query = new StringBundler(3);
681 }
682
683 if (getDB().isSupportsInlineDistinct()) {
684 query.append(_FILTER_SQL_SELECT_SCLICENSE_WHERE);
685 }
686 else {
687 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1);
688 }
689
690 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
691
692 if (!getDB().isSupportsInlineDistinct()) {
693 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2);
694 }
695
696 if (orderByComparator != null) {
697 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
698
699 if (orderByConditionFields.length > 0) {
700 query.append(WHERE_AND);
701 }
702
703 for (int i = 0; i < orderByConditionFields.length; i++) {
704 if (getDB().isSupportsInlineDistinct()) {
705 query.append(_ORDER_BY_ENTITY_ALIAS);
706 }
707 else {
708 query.append(_ORDER_BY_ENTITY_TABLE);
709 }
710
711 query.append(orderByConditionFields[i]);
712
713 if ((i + 1) < orderByConditionFields.length) {
714 if (orderByComparator.isAscending() ^ previous) {
715 query.append(WHERE_GREATER_THAN_HAS_NEXT);
716 }
717 else {
718 query.append(WHERE_LESSER_THAN_HAS_NEXT);
719 }
720 }
721 else {
722 if (orderByComparator.isAscending() ^ previous) {
723 query.append(WHERE_GREATER_THAN);
724 }
725 else {
726 query.append(WHERE_LESSER_THAN);
727 }
728 }
729 }
730
731 query.append(ORDER_BY_CLAUSE);
732
733 String[] orderByFields = orderByComparator.getOrderByFields();
734
735 for (int i = 0; i < orderByFields.length; i++) {
736 if (getDB().isSupportsInlineDistinct()) {
737 query.append(_ORDER_BY_ENTITY_ALIAS);
738 }
739 else {
740 query.append(_ORDER_BY_ENTITY_TABLE);
741 }
742
743 query.append(orderByFields[i]);
744
745 if ((i + 1) < orderByFields.length) {
746 if (orderByComparator.isAscending() ^ previous) {
747 query.append(ORDER_BY_ASC_HAS_NEXT);
748 }
749 else {
750 query.append(ORDER_BY_DESC_HAS_NEXT);
751 }
752 }
753 else {
754 if (orderByComparator.isAscending() ^ previous) {
755 query.append(ORDER_BY_ASC);
756 }
757 else {
758 query.append(ORDER_BY_DESC);
759 }
760 }
761 }
762 }
763 else {
764 if (getDB().isSupportsInlineDistinct()) {
765 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
766 }
767 else {
768 query.append(SCLicenseModelImpl.ORDER_BY_SQL);
769 }
770 }
771
772 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
773 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
774
775 SQLQuery q = session.createSQLQuery(sql);
776
777 q.setFirstResult(0);
778 q.setMaxResults(2);
779
780 if (getDB().isSupportsInlineDistinct()) {
781 q.addEntity(_FILTER_ENTITY_ALIAS, SCLicenseImpl.class);
782 }
783 else {
784 q.addEntity(_FILTER_ENTITY_TABLE, SCLicenseImpl.class);
785 }
786
787 QueryPos qPos = QueryPos.getInstance(q);
788
789 qPos.add(active);
790
791 if (orderByComparator != null) {
792 Object[] values = orderByComparator.getOrderByConditionValues(scLicense);
793
794 for (Object value : values) {
795 qPos.add(value);
796 }
797 }
798
799 List<SCLicense> list = q.list();
800
801 if (list.size() == 2) {
802 return list.get(1);
803 }
804 else {
805 return null;
806 }
807 }
808
809
815 public void removeByActive(boolean active) throws SystemException {
816 for (SCLicense scLicense : findByActive(active, QueryUtil.ALL_POS,
817 QueryUtil.ALL_POS, null)) {
818 remove(scLicense);
819 }
820 }
821
822
829 public int countByActive(boolean active) throws SystemException {
830 FinderPath finderPath = FINDER_PATH_COUNT_BY_ACTIVE;
831
832 Object[] finderArgs = new Object[] { active };
833
834 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
835 this);
836
837 if (count == null) {
838 StringBundler query = new StringBundler(2);
839
840 query.append(_SQL_COUNT_SCLICENSE_WHERE);
841
842 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
843
844 String sql = query.toString();
845
846 Session session = null;
847
848 try {
849 session = openSession();
850
851 Query q = session.createQuery(sql);
852
853 QueryPos qPos = QueryPos.getInstance(q);
854
855 qPos.add(active);
856
857 count = (Long)q.uniqueResult();
858
859 FinderCacheUtil.putResult(finderPath, finderArgs, count);
860 }
861 catch (Exception e) {
862 FinderCacheUtil.removeResult(finderPath, finderArgs);
863
864 throw processException(e);
865 }
866 finally {
867 closeSession(session);
868 }
869 }
870
871 return count.intValue();
872 }
873
874
881 public int filterCountByActive(boolean active) throws SystemException {
882 if (!InlineSQLHelperUtil.isEnabled()) {
883 return countByActive(active);
884 }
885
886 StringBundler query = new StringBundler(2);
887
888 query.append(_FILTER_SQL_COUNT_SCLICENSE_WHERE);
889
890 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
891
892 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
893 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
894
895 Session session = null;
896
897 try {
898 session = openSession();
899
900 SQLQuery q = session.createSQLQuery(sql);
901
902 q.addScalar(COUNT_COLUMN_NAME,
903 com.liferay.portal.kernel.dao.orm.Type.LONG);
904
905 QueryPos qPos = QueryPos.getInstance(q);
906
907 qPos.add(active);
908
909 Long count = (Long)q.uniqueResult();
910
911 return count.intValue();
912 }
913 catch (Exception e) {
914 throw processException(e);
915 }
916 finally {
917 closeSession(session);
918 }
919 }
920
921 private static final String _FINDER_COLUMN_ACTIVE_ACTIVE_2 = "scLicense.active = ?";
922 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_A_R = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
923 SCLicenseModelImpl.FINDER_CACHE_ENABLED, SCLicenseImpl.class,
924 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByA_R",
925 new String[] {
926 Boolean.class.getName(), Boolean.class.getName(),
927
928 Integer.class.getName(), Integer.class.getName(),
929 OrderByComparator.class.getName()
930 });
931 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_A_R = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
932 SCLicenseModelImpl.FINDER_CACHE_ENABLED, SCLicenseImpl.class,
933 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByA_R",
934 new String[] { Boolean.class.getName(), Boolean.class.getName() },
935 SCLicenseModelImpl.ACTIVE_COLUMN_BITMASK |
936 SCLicenseModelImpl.RECOMMENDED_COLUMN_BITMASK |
937 SCLicenseModelImpl.NAME_COLUMN_BITMASK);
938 public static final FinderPath FINDER_PATH_COUNT_BY_A_R = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
939 SCLicenseModelImpl.FINDER_CACHE_ENABLED, Long.class,
940 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByA_R",
941 new String[] { Boolean.class.getName(), Boolean.class.getName() });
942
943
951 public List<SCLicense> findByA_R(boolean active, boolean recommended)
952 throws SystemException {
953 return findByA_R(active, recommended, QueryUtil.ALL_POS,
954 QueryUtil.ALL_POS, null);
955 }
956
957
971 public List<SCLicense> findByA_R(boolean active, boolean recommended,
972 int start, int end) throws SystemException {
973 return findByA_R(active, recommended, start, end, null);
974 }
975
976
991 public List<SCLicense> findByA_R(boolean active, boolean recommended,
992 int start, int end, OrderByComparator orderByComparator)
993 throws SystemException {
994 boolean pagination = true;
995 FinderPath finderPath = null;
996 Object[] finderArgs = null;
997
998 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
999 (orderByComparator == null)) {
1000 pagination = false;
1001 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_A_R;
1002 finderArgs = new Object[] { active, recommended };
1003 }
1004 else {
1005 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_A_R;
1006 finderArgs = new Object[] {
1007 active, recommended,
1008
1009 start, end, orderByComparator
1010 };
1011 }
1012
1013 List<SCLicense> list = (List<SCLicense>)FinderCacheUtil.getResult(finderPath,
1014 finderArgs, this);
1015
1016 if ((list != null) && !list.isEmpty()) {
1017 for (SCLicense scLicense : list) {
1018 if ((active != scLicense.getActive()) ||
1019 (recommended != scLicense.getRecommended())) {
1020 list = null;
1021
1022 break;
1023 }
1024 }
1025 }
1026
1027 if (list == null) {
1028 StringBundler query = null;
1029
1030 if (orderByComparator != null) {
1031 query = new StringBundler(4 +
1032 (orderByComparator.getOrderByFields().length * 3));
1033 }
1034 else {
1035 query = new StringBundler(4);
1036 }
1037
1038 query.append(_SQL_SELECT_SCLICENSE_WHERE);
1039
1040 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1041
1042 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1043
1044 if (orderByComparator != null) {
1045 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1046 orderByComparator);
1047 }
1048 else
1049 if (pagination) {
1050 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1051 }
1052
1053 String sql = query.toString();
1054
1055 Session session = null;
1056
1057 try {
1058 session = openSession();
1059
1060 Query q = session.createQuery(sql);
1061
1062 QueryPos qPos = QueryPos.getInstance(q);
1063
1064 qPos.add(active);
1065
1066 qPos.add(recommended);
1067
1068 if (!pagination) {
1069 list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
1070 start, end, false);
1071
1072 Collections.sort(list);
1073
1074 list = new UnmodifiableList<SCLicense>(list);
1075 }
1076 else {
1077 list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
1078 start, end);
1079 }
1080
1081 cacheResult(list);
1082
1083 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1084 }
1085 catch (Exception e) {
1086 FinderCacheUtil.removeResult(finderPath, finderArgs);
1087
1088 throw processException(e);
1089 }
1090 finally {
1091 closeSession(session);
1092 }
1093 }
1094
1095 return list;
1096 }
1097
1098
1108 public SCLicense findByA_R_First(boolean active, boolean recommended,
1109 OrderByComparator orderByComparator)
1110 throws NoSuchLicenseException, SystemException {
1111 SCLicense scLicense = fetchByA_R_First(active, recommended,
1112 orderByComparator);
1113
1114 if (scLicense != null) {
1115 return scLicense;
1116 }
1117
1118 StringBundler msg = new StringBundler(6);
1119
1120 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1121
1122 msg.append("active=");
1123 msg.append(active);
1124
1125 msg.append(", recommended=");
1126 msg.append(recommended);
1127
1128 msg.append(StringPool.CLOSE_CURLY_BRACE);
1129
1130 throw new NoSuchLicenseException(msg.toString());
1131 }
1132
1133
1142 public SCLicense fetchByA_R_First(boolean active, boolean recommended,
1143 OrderByComparator orderByComparator) throws SystemException {
1144 List<SCLicense> list = findByA_R(active, recommended, 0, 1,
1145 orderByComparator);
1146
1147 if (!list.isEmpty()) {
1148 return list.get(0);
1149 }
1150
1151 return null;
1152 }
1153
1154
1164 public SCLicense findByA_R_Last(boolean active, boolean recommended,
1165 OrderByComparator orderByComparator)
1166 throws NoSuchLicenseException, SystemException {
1167 SCLicense scLicense = fetchByA_R_Last(active, recommended,
1168 orderByComparator);
1169
1170 if (scLicense != null) {
1171 return scLicense;
1172 }
1173
1174 StringBundler msg = new StringBundler(6);
1175
1176 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1177
1178 msg.append("active=");
1179 msg.append(active);
1180
1181 msg.append(", recommended=");
1182 msg.append(recommended);
1183
1184 msg.append(StringPool.CLOSE_CURLY_BRACE);
1185
1186 throw new NoSuchLicenseException(msg.toString());
1187 }
1188
1189
1198 public SCLicense fetchByA_R_Last(boolean active, boolean recommended,
1199 OrderByComparator orderByComparator) throws SystemException {
1200 int count = countByA_R(active, recommended);
1201
1202 List<SCLicense> list = findByA_R(active, recommended, count - 1, count,
1203 orderByComparator);
1204
1205 if (!list.isEmpty()) {
1206 return list.get(0);
1207 }
1208
1209 return null;
1210 }
1211
1212
1223 public SCLicense[] findByA_R_PrevAndNext(long licenseId, boolean active,
1224 boolean recommended, OrderByComparator orderByComparator)
1225 throws NoSuchLicenseException, SystemException {
1226 SCLicense scLicense = findByPrimaryKey(licenseId);
1227
1228 Session session = null;
1229
1230 try {
1231 session = openSession();
1232
1233 SCLicense[] array = new SCLicenseImpl[3];
1234
1235 array[0] = getByA_R_PrevAndNext(session, scLicense, active,
1236 recommended, orderByComparator, true);
1237
1238 array[1] = scLicense;
1239
1240 array[2] = getByA_R_PrevAndNext(session, scLicense, active,
1241 recommended, orderByComparator, false);
1242
1243 return array;
1244 }
1245 catch (Exception e) {
1246 throw processException(e);
1247 }
1248 finally {
1249 closeSession(session);
1250 }
1251 }
1252
1253 protected SCLicense getByA_R_PrevAndNext(Session session,
1254 SCLicense scLicense, boolean active, boolean recommended,
1255 OrderByComparator orderByComparator, boolean previous) {
1256 StringBundler query = null;
1257
1258 if (orderByComparator != null) {
1259 query = new StringBundler(6 +
1260 (orderByComparator.getOrderByFields().length * 6));
1261 }
1262 else {
1263 query = new StringBundler(3);
1264 }
1265
1266 query.append(_SQL_SELECT_SCLICENSE_WHERE);
1267
1268 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1269
1270 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1271
1272 if (orderByComparator != null) {
1273 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1274
1275 if (orderByConditionFields.length > 0) {
1276 query.append(WHERE_AND);
1277 }
1278
1279 for (int i = 0; i < orderByConditionFields.length; i++) {
1280 query.append(_ORDER_BY_ENTITY_ALIAS);
1281 query.append(orderByConditionFields[i]);
1282
1283 if ((i + 1) < orderByConditionFields.length) {
1284 if (orderByComparator.isAscending() ^ previous) {
1285 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1286 }
1287 else {
1288 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1289 }
1290 }
1291 else {
1292 if (orderByComparator.isAscending() ^ previous) {
1293 query.append(WHERE_GREATER_THAN);
1294 }
1295 else {
1296 query.append(WHERE_LESSER_THAN);
1297 }
1298 }
1299 }
1300
1301 query.append(ORDER_BY_CLAUSE);
1302
1303 String[] orderByFields = orderByComparator.getOrderByFields();
1304
1305 for (int i = 0; i < orderByFields.length; i++) {
1306 query.append(_ORDER_BY_ENTITY_ALIAS);
1307 query.append(orderByFields[i]);
1308
1309 if ((i + 1) < orderByFields.length) {
1310 if (orderByComparator.isAscending() ^ previous) {
1311 query.append(ORDER_BY_ASC_HAS_NEXT);
1312 }
1313 else {
1314 query.append(ORDER_BY_DESC_HAS_NEXT);
1315 }
1316 }
1317 else {
1318 if (orderByComparator.isAscending() ^ previous) {
1319 query.append(ORDER_BY_ASC);
1320 }
1321 else {
1322 query.append(ORDER_BY_DESC);
1323 }
1324 }
1325 }
1326 }
1327 else {
1328 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1329 }
1330
1331 String sql = query.toString();
1332
1333 Query q = session.createQuery(sql);
1334
1335 q.setFirstResult(0);
1336 q.setMaxResults(2);
1337
1338 QueryPos qPos = QueryPos.getInstance(q);
1339
1340 qPos.add(active);
1341
1342 qPos.add(recommended);
1343
1344 if (orderByComparator != null) {
1345 Object[] values = orderByComparator.getOrderByConditionValues(scLicense);
1346
1347 for (Object value : values) {
1348 qPos.add(value);
1349 }
1350 }
1351
1352 List<SCLicense> list = q.list();
1353
1354 if (list.size() == 2) {
1355 return list.get(1);
1356 }
1357 else {
1358 return null;
1359 }
1360 }
1361
1362
1370 public List<SCLicense> filterFindByA_R(boolean active, boolean recommended)
1371 throws SystemException {
1372 return filterFindByA_R(active, recommended, QueryUtil.ALL_POS,
1373 QueryUtil.ALL_POS, null);
1374 }
1375
1376
1390 public List<SCLicense> filterFindByA_R(boolean active, boolean recommended,
1391 int start, int end) throws SystemException {
1392 return filterFindByA_R(active, recommended, start, end, null);
1393 }
1394
1395
1410 public List<SCLicense> filterFindByA_R(boolean active, boolean recommended,
1411 int start, int end, OrderByComparator orderByComparator)
1412 throws SystemException {
1413 if (!InlineSQLHelperUtil.isEnabled()) {
1414 return findByA_R(active, recommended, start, end, orderByComparator);
1415 }
1416
1417 StringBundler query = null;
1418
1419 if (orderByComparator != null) {
1420 query = new StringBundler(4 +
1421 (orderByComparator.getOrderByFields().length * 3));
1422 }
1423 else {
1424 query = new StringBundler(4);
1425 }
1426
1427 if (getDB().isSupportsInlineDistinct()) {
1428 query.append(_FILTER_SQL_SELECT_SCLICENSE_WHERE);
1429 }
1430 else {
1431 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1);
1432 }
1433
1434 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1435
1436 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1437
1438 if (!getDB().isSupportsInlineDistinct()) {
1439 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2);
1440 }
1441
1442 if (orderByComparator != null) {
1443 if (getDB().isSupportsInlineDistinct()) {
1444 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1445 orderByComparator);
1446 }
1447 else {
1448 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1449 orderByComparator);
1450 }
1451 }
1452 else {
1453 if (getDB().isSupportsInlineDistinct()) {
1454 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1455 }
1456 else {
1457 query.append(SCLicenseModelImpl.ORDER_BY_SQL);
1458 }
1459 }
1460
1461 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1462 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1463
1464 Session session = null;
1465
1466 try {
1467 session = openSession();
1468
1469 SQLQuery q = session.createSQLQuery(sql);
1470
1471 if (getDB().isSupportsInlineDistinct()) {
1472 q.addEntity(_FILTER_ENTITY_ALIAS, SCLicenseImpl.class);
1473 }
1474 else {
1475 q.addEntity(_FILTER_ENTITY_TABLE, SCLicenseImpl.class);
1476 }
1477
1478 QueryPos qPos = QueryPos.getInstance(q);
1479
1480 qPos.add(active);
1481
1482 qPos.add(recommended);
1483
1484 return (List<SCLicense>)QueryUtil.list(q, getDialect(), start, end);
1485 }
1486 catch (Exception e) {
1487 throw processException(e);
1488 }
1489 finally {
1490 closeSession(session);
1491 }
1492 }
1493
1494
1505 public SCLicense[] filterFindByA_R_PrevAndNext(long licenseId,
1506 boolean active, boolean recommended, OrderByComparator orderByComparator)
1507 throws NoSuchLicenseException, SystemException {
1508 if (!InlineSQLHelperUtil.isEnabled()) {
1509 return findByA_R_PrevAndNext(licenseId, active, recommended,
1510 orderByComparator);
1511 }
1512
1513 SCLicense scLicense = findByPrimaryKey(licenseId);
1514
1515 Session session = null;
1516
1517 try {
1518 session = openSession();
1519
1520 SCLicense[] array = new SCLicenseImpl[3];
1521
1522 array[0] = filterGetByA_R_PrevAndNext(session, scLicense, active,
1523 recommended, orderByComparator, true);
1524
1525 array[1] = scLicense;
1526
1527 array[2] = filterGetByA_R_PrevAndNext(session, scLicense, active,
1528 recommended, orderByComparator, false);
1529
1530 return array;
1531 }
1532 catch (Exception e) {
1533 throw processException(e);
1534 }
1535 finally {
1536 closeSession(session);
1537 }
1538 }
1539
1540 protected SCLicense filterGetByA_R_PrevAndNext(Session session,
1541 SCLicense scLicense, boolean active, boolean recommended,
1542 OrderByComparator orderByComparator, boolean previous) {
1543 StringBundler query = null;
1544
1545 if (orderByComparator != null) {
1546 query = new StringBundler(6 +
1547 (orderByComparator.getOrderByFields().length * 6));
1548 }
1549 else {
1550 query = new StringBundler(3);
1551 }
1552
1553 if (getDB().isSupportsInlineDistinct()) {
1554 query.append(_FILTER_SQL_SELECT_SCLICENSE_WHERE);
1555 }
1556 else {
1557 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1);
1558 }
1559
1560 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1561
1562 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1563
1564 if (!getDB().isSupportsInlineDistinct()) {
1565 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2);
1566 }
1567
1568 if (orderByComparator != null) {
1569 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1570
1571 if (orderByConditionFields.length > 0) {
1572 query.append(WHERE_AND);
1573 }
1574
1575 for (int i = 0; i < orderByConditionFields.length; i++) {
1576 if (getDB().isSupportsInlineDistinct()) {
1577 query.append(_ORDER_BY_ENTITY_ALIAS);
1578 }
1579 else {
1580 query.append(_ORDER_BY_ENTITY_TABLE);
1581 }
1582
1583 query.append(orderByConditionFields[i]);
1584
1585 if ((i + 1) < orderByConditionFields.length) {
1586 if (orderByComparator.isAscending() ^ previous) {
1587 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1588 }
1589 else {
1590 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1591 }
1592 }
1593 else {
1594 if (orderByComparator.isAscending() ^ previous) {
1595 query.append(WHERE_GREATER_THAN);
1596 }
1597 else {
1598 query.append(WHERE_LESSER_THAN);
1599 }
1600 }
1601 }
1602
1603 query.append(ORDER_BY_CLAUSE);
1604
1605 String[] orderByFields = orderByComparator.getOrderByFields();
1606
1607 for (int i = 0; i < orderByFields.length; i++) {
1608 if (getDB().isSupportsInlineDistinct()) {
1609 query.append(_ORDER_BY_ENTITY_ALIAS);
1610 }
1611 else {
1612 query.append(_ORDER_BY_ENTITY_TABLE);
1613 }
1614
1615 query.append(orderByFields[i]);
1616
1617 if ((i + 1) < orderByFields.length) {
1618 if (orderByComparator.isAscending() ^ previous) {
1619 query.append(ORDER_BY_ASC_HAS_NEXT);
1620 }
1621 else {
1622 query.append(ORDER_BY_DESC_HAS_NEXT);
1623 }
1624 }
1625 else {
1626 if (orderByComparator.isAscending() ^ previous) {
1627 query.append(ORDER_BY_ASC);
1628 }
1629 else {
1630 query.append(ORDER_BY_DESC);
1631 }
1632 }
1633 }
1634 }
1635 else {
1636 if (getDB().isSupportsInlineDistinct()) {
1637 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1638 }
1639 else {
1640 query.append(SCLicenseModelImpl.ORDER_BY_SQL);
1641 }
1642 }
1643
1644 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1645 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1646
1647 SQLQuery q = session.createSQLQuery(sql);
1648
1649 q.setFirstResult(0);
1650 q.setMaxResults(2);
1651
1652 if (getDB().isSupportsInlineDistinct()) {
1653 q.addEntity(_FILTER_ENTITY_ALIAS, SCLicenseImpl.class);
1654 }
1655 else {
1656 q.addEntity(_FILTER_ENTITY_TABLE, SCLicenseImpl.class);
1657 }
1658
1659 QueryPos qPos = QueryPos.getInstance(q);
1660
1661 qPos.add(active);
1662
1663 qPos.add(recommended);
1664
1665 if (orderByComparator != null) {
1666 Object[] values = orderByComparator.getOrderByConditionValues(scLicense);
1667
1668 for (Object value : values) {
1669 qPos.add(value);
1670 }
1671 }
1672
1673 List<SCLicense> list = q.list();
1674
1675 if (list.size() == 2) {
1676 return list.get(1);
1677 }
1678 else {
1679 return null;
1680 }
1681 }
1682
1683
1690 public void removeByA_R(boolean active, boolean recommended)
1691 throws SystemException {
1692 for (SCLicense scLicense : findByA_R(active, recommended,
1693 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1694 remove(scLicense);
1695 }
1696 }
1697
1698
1706 public int countByA_R(boolean active, boolean recommended)
1707 throws SystemException {
1708 FinderPath finderPath = FINDER_PATH_COUNT_BY_A_R;
1709
1710 Object[] finderArgs = new Object[] { active, recommended };
1711
1712 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1713 this);
1714
1715 if (count == null) {
1716 StringBundler query = new StringBundler(3);
1717
1718 query.append(_SQL_COUNT_SCLICENSE_WHERE);
1719
1720 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1721
1722 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1723
1724 String sql = query.toString();
1725
1726 Session session = null;
1727
1728 try {
1729 session = openSession();
1730
1731 Query q = session.createQuery(sql);
1732
1733 QueryPos qPos = QueryPos.getInstance(q);
1734
1735 qPos.add(active);
1736
1737 qPos.add(recommended);
1738
1739 count = (Long)q.uniqueResult();
1740
1741 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1742 }
1743 catch (Exception e) {
1744 FinderCacheUtil.removeResult(finderPath, finderArgs);
1745
1746 throw processException(e);
1747 }
1748 finally {
1749 closeSession(session);
1750 }
1751 }
1752
1753 return count.intValue();
1754 }
1755
1756
1764 public int filterCountByA_R(boolean active, boolean recommended)
1765 throws SystemException {
1766 if (!InlineSQLHelperUtil.isEnabled()) {
1767 return countByA_R(active, recommended);
1768 }
1769
1770 StringBundler query = new StringBundler(3);
1771
1772 query.append(_FILTER_SQL_COUNT_SCLICENSE_WHERE);
1773
1774 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1775
1776 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1777
1778 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1779 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1780
1781 Session session = null;
1782
1783 try {
1784 session = openSession();
1785
1786 SQLQuery q = session.createSQLQuery(sql);
1787
1788 q.addScalar(COUNT_COLUMN_NAME,
1789 com.liferay.portal.kernel.dao.orm.Type.LONG);
1790
1791 QueryPos qPos = QueryPos.getInstance(q);
1792
1793 qPos.add(active);
1794
1795 qPos.add(recommended);
1796
1797 Long count = (Long)q.uniqueResult();
1798
1799 return count.intValue();
1800 }
1801 catch (Exception e) {
1802 throw processException(e);
1803 }
1804 finally {
1805 closeSession(session);
1806 }
1807 }
1808
1809 private static final String _FINDER_COLUMN_A_R_ACTIVE_2 = "scLicense.active = ? AND ";
1810 private static final String _FINDER_COLUMN_A_R_RECOMMENDED_2 = "scLicense.recommended = ?";
1811
1812
1817 public void cacheResult(SCLicense scLicense) {
1818 EntityCacheUtil.putResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
1819 SCLicenseImpl.class, scLicense.getPrimaryKey(), scLicense);
1820
1821 scLicense.resetOriginalValues();
1822 }
1823
1824
1829 public void cacheResult(List<SCLicense> scLicenses) {
1830 for (SCLicense scLicense : scLicenses) {
1831 if (EntityCacheUtil.getResult(
1832 SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
1833 SCLicenseImpl.class, scLicense.getPrimaryKey()) == null) {
1834 cacheResult(scLicense);
1835 }
1836 else {
1837 scLicense.resetOriginalValues();
1838 }
1839 }
1840 }
1841
1842
1849 @Override
1850 public void clearCache() {
1851 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
1852 CacheRegistryUtil.clear(SCLicenseImpl.class.getName());
1853 }
1854
1855 EntityCacheUtil.clearCache(SCLicenseImpl.class.getName());
1856
1857 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
1858 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1859 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1860 }
1861
1862
1869 @Override
1870 public void clearCache(SCLicense scLicense) {
1871 EntityCacheUtil.removeResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
1872 SCLicenseImpl.class, scLicense.getPrimaryKey());
1873
1874 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1875 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1876 }
1877
1878 @Override
1879 public void clearCache(List<SCLicense> scLicenses) {
1880 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1881 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1882
1883 for (SCLicense scLicense : scLicenses) {
1884 EntityCacheUtil.removeResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
1885 SCLicenseImpl.class, scLicense.getPrimaryKey());
1886 }
1887 }
1888
1889
1895 public SCLicense create(long licenseId) {
1896 SCLicense scLicense = new SCLicenseImpl();
1897
1898 scLicense.setNew(true);
1899 scLicense.setPrimaryKey(licenseId);
1900
1901 return scLicense;
1902 }
1903
1904
1912 public SCLicense remove(long licenseId)
1913 throws NoSuchLicenseException, SystemException {
1914 return remove(Long.valueOf(licenseId));
1915 }
1916
1917
1925 @Override
1926 public SCLicense remove(Serializable primaryKey)
1927 throws NoSuchLicenseException, SystemException {
1928 Session session = null;
1929
1930 try {
1931 session = openSession();
1932
1933 SCLicense scLicense = (SCLicense)session.get(SCLicenseImpl.class,
1934 primaryKey);
1935
1936 if (scLicense == null) {
1937 if (_log.isWarnEnabled()) {
1938 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
1939 }
1940
1941 throw new NoSuchLicenseException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1942 primaryKey);
1943 }
1944
1945 return remove(scLicense);
1946 }
1947 catch (NoSuchLicenseException nsee) {
1948 throw nsee;
1949 }
1950 catch (Exception e) {
1951 throw processException(e);
1952 }
1953 finally {
1954 closeSession(session);
1955 }
1956 }
1957
1958 @Override
1959 protected SCLicense removeImpl(SCLicense scLicense)
1960 throws SystemException {
1961 scLicense = toUnwrappedModel(scLicense);
1962
1963 try {
1964 clearSCProductEntries.clear(scLicense.getPrimaryKey());
1965 }
1966 catch (Exception e) {
1967 throw processException(e);
1968 }
1969 finally {
1970 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
1971 }
1972
1973 Session session = null;
1974
1975 try {
1976 session = openSession();
1977
1978 if (!session.contains(scLicense)) {
1979 scLicense = (SCLicense)session.get(SCLicenseImpl.class,
1980 scLicense.getPrimaryKeyObj());
1981 }
1982
1983 if (scLicense != null) {
1984 session.delete(scLicense);
1985 }
1986 }
1987 catch (Exception e) {
1988 throw processException(e);
1989 }
1990 finally {
1991 closeSession(session);
1992 }
1993
1994 if (scLicense != null) {
1995 clearCache(scLicense);
1996 }
1997
1998 return scLicense;
1999 }
2000
2001 @Override
2002 public SCLicense updateImpl(
2003 com.liferay.portlet.softwarecatalog.model.SCLicense scLicense)
2004 throws SystemException {
2005 scLicense = toUnwrappedModel(scLicense);
2006
2007 boolean isNew = scLicense.isNew();
2008
2009 SCLicenseModelImpl scLicenseModelImpl = (SCLicenseModelImpl)scLicense;
2010
2011 Session session = null;
2012
2013 try {
2014 session = openSession();
2015
2016 if (scLicense.isNew()) {
2017 session.save(scLicense);
2018
2019 scLicense.setNew(false);
2020 }
2021 else {
2022 session.merge(scLicense);
2023 }
2024 }
2025 catch (Exception e) {
2026 throw processException(e);
2027 }
2028 finally {
2029 closeSession(session);
2030 }
2031
2032 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2033
2034 if (isNew || !SCLicenseModelImpl.COLUMN_BITMASK_ENABLED) {
2035 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2036 }
2037
2038 else {
2039 if ((scLicenseModelImpl.getColumnBitmask() &
2040 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE.getColumnBitmask()) != 0) {
2041 Object[] args = new Object[] {
2042 Boolean.valueOf(scLicenseModelImpl.getOriginalActive())
2043 };
2044
2045 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ACTIVE, args);
2046 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE,
2047 args);
2048
2049 args = new Object[] {
2050 Boolean.valueOf(scLicenseModelImpl.getActive())
2051 };
2052
2053 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ACTIVE, args);
2054 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE,
2055 args);
2056 }
2057
2058 if ((scLicenseModelImpl.getColumnBitmask() &
2059 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_A_R.getColumnBitmask()) != 0) {
2060 Object[] args = new Object[] {
2061 Boolean.valueOf(scLicenseModelImpl.getOriginalActive()),
2062 Boolean.valueOf(scLicenseModelImpl.getOriginalRecommended())
2063 };
2064
2065 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_A_R, args);
2066 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_A_R,
2067 args);
2068
2069 args = new Object[] {
2070 Boolean.valueOf(scLicenseModelImpl.getActive()),
2071 Boolean.valueOf(scLicenseModelImpl.getRecommended())
2072 };
2073
2074 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_A_R, args);
2075 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_A_R,
2076 args);
2077 }
2078 }
2079
2080 EntityCacheUtil.putResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
2081 SCLicenseImpl.class, scLicense.getPrimaryKey(), scLicense);
2082
2083 return scLicense;
2084 }
2085
2086 protected SCLicense toUnwrappedModel(SCLicense scLicense) {
2087 if (scLicense instanceof SCLicenseImpl) {
2088 return scLicense;
2089 }
2090
2091 SCLicenseImpl scLicenseImpl = new SCLicenseImpl();
2092
2093 scLicenseImpl.setNew(scLicense.isNew());
2094 scLicenseImpl.setPrimaryKey(scLicense.getPrimaryKey());
2095
2096 scLicenseImpl.setLicenseId(scLicense.getLicenseId());
2097 scLicenseImpl.setName(scLicense.getName());
2098 scLicenseImpl.setUrl(scLicense.getUrl());
2099 scLicenseImpl.setOpenSource(scLicense.isOpenSource());
2100 scLicenseImpl.setActive(scLicense.isActive());
2101 scLicenseImpl.setRecommended(scLicense.isRecommended());
2102
2103 return scLicenseImpl;
2104 }
2105
2106
2114 @Override
2115 public SCLicense findByPrimaryKey(Serializable primaryKey)
2116 throws NoSuchModelException, SystemException {
2117 return findByPrimaryKey(((Long)primaryKey).longValue());
2118 }
2119
2120
2128 public SCLicense findByPrimaryKey(long licenseId)
2129 throws NoSuchLicenseException, SystemException {
2130 SCLicense scLicense = fetchByPrimaryKey(licenseId);
2131
2132 if (scLicense == null) {
2133 if (_log.isWarnEnabled()) {
2134 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + licenseId);
2135 }
2136
2137 throw new NoSuchLicenseException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2138 licenseId);
2139 }
2140
2141 return scLicense;
2142 }
2143
2144
2151 @Override
2152 public SCLicense fetchByPrimaryKey(Serializable primaryKey)
2153 throws SystemException {
2154 return fetchByPrimaryKey(((Long)primaryKey).longValue());
2155 }
2156
2157
2164 public SCLicense fetchByPrimaryKey(long licenseId)
2165 throws SystemException {
2166 SCLicense scLicense = (SCLicense)EntityCacheUtil.getResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
2167 SCLicenseImpl.class, licenseId);
2168
2169 if (scLicense == _nullSCLicense) {
2170 return null;
2171 }
2172
2173 if (scLicense == null) {
2174 Session session = null;
2175
2176 try {
2177 session = openSession();
2178
2179 scLicense = (SCLicense)session.get(SCLicenseImpl.class,
2180 Long.valueOf(licenseId));
2181
2182 if (scLicense != null) {
2183 cacheResult(scLicense);
2184 }
2185 else {
2186 EntityCacheUtil.putResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
2187 SCLicenseImpl.class, licenseId, _nullSCLicense);
2188 }
2189 }
2190 catch (Exception e) {
2191 EntityCacheUtil.removeResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
2192 SCLicenseImpl.class, licenseId);
2193
2194 throw processException(e);
2195 }
2196 finally {
2197 closeSession(session);
2198 }
2199 }
2200
2201 return scLicense;
2202 }
2203
2204
2210 public List<SCLicense> findAll() throws SystemException {
2211 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2212 }
2213
2214
2226 public List<SCLicense> findAll(int start, int end)
2227 throws SystemException {
2228 return findAll(start, end, null);
2229 }
2230
2231
2244 public List<SCLicense> findAll(int start, int end,
2245 OrderByComparator orderByComparator) throws SystemException {
2246 boolean pagination = true;
2247 FinderPath finderPath = null;
2248 Object[] finderArgs = null;
2249
2250 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2251 (orderByComparator == null)) {
2252 pagination = false;
2253 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2254 finderArgs = FINDER_ARGS_EMPTY;
2255 }
2256 else {
2257 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2258 finderArgs = new Object[] { start, end, orderByComparator };
2259 }
2260
2261 List<SCLicense> list = (List<SCLicense>)FinderCacheUtil.getResult(finderPath,
2262 finderArgs, this);
2263
2264 if (list == null) {
2265 StringBundler query = null;
2266 String sql = null;
2267
2268 if (orderByComparator != null) {
2269 query = new StringBundler(2 +
2270 (orderByComparator.getOrderByFields().length * 3));
2271
2272 query.append(_SQL_SELECT_SCLICENSE);
2273
2274 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2275 orderByComparator);
2276
2277 sql = query.toString();
2278 }
2279 else {
2280 sql = _SQL_SELECT_SCLICENSE;
2281
2282 if (pagination) {
2283 sql = sql.concat(SCLicenseModelImpl.ORDER_BY_JPQL);
2284 }
2285 }
2286
2287 Session session = null;
2288
2289 try {
2290 session = openSession();
2291
2292 Query q = session.createQuery(sql);
2293
2294 if (!pagination) {
2295 list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
2296 start, end, false);
2297
2298 Collections.sort(list);
2299
2300 list = new UnmodifiableList<SCLicense>(list);
2301 }
2302 else {
2303 list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
2304 start, end);
2305 }
2306
2307 cacheResult(list);
2308
2309 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2310 }
2311 catch (Exception e) {
2312 FinderCacheUtil.removeResult(finderPath, finderArgs);
2313
2314 throw processException(e);
2315 }
2316 finally {
2317 closeSession(session);
2318 }
2319 }
2320
2321 return list;
2322 }
2323
2324
2329 public void removeAll() throws SystemException {
2330 for (SCLicense scLicense : findAll()) {
2331 remove(scLicense);
2332 }
2333 }
2334
2335
2341 public int countAll() throws SystemException {
2342 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2343 FINDER_ARGS_EMPTY, this);
2344
2345 if (count == null) {
2346 Session session = null;
2347
2348 try {
2349 session = openSession();
2350
2351 Query q = session.createQuery(_SQL_COUNT_SCLICENSE);
2352
2353 count = (Long)q.uniqueResult();
2354
2355 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2356 FINDER_ARGS_EMPTY, count);
2357 }
2358 catch (Exception e) {
2359 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
2360 FINDER_ARGS_EMPTY);
2361
2362 throw processException(e);
2363 }
2364 finally {
2365 closeSession(session);
2366 }
2367 }
2368
2369 return count.intValue();
2370 }
2371
2372
2379 public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
2380 long pk) throws SystemException {
2381 return getSCProductEntries(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2382 }
2383
2384
2397 public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
2398 long pk, int start, int end) throws SystemException {
2399 return getSCProductEntries(pk, start, end, null);
2400 }
2401
2402 public static final FinderPath FINDER_PATH_GET_SCPRODUCTENTRIES = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
2403 SCLicenseModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
2404 com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryImpl.class,
2405 SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
2406 "getSCProductEntries",
2407 new String[] {
2408 Long.class.getName(), Integer.class.getName(),
2409 Integer.class.getName(), OrderByComparator.class.getName()
2410 });
2411
2412 static {
2413 FINDER_PATH_GET_SCPRODUCTENTRIES.setCacheKeyGeneratorCacheName(null);
2414 }
2415
2416
2430 public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
2431 long pk, int start, int end, OrderByComparator orderByComparator)
2432 throws SystemException {
2433 boolean pagination = true;
2434 Object[] finderArgs = null;
2435
2436 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2437 (orderByComparator == null)) {
2438 pagination = false;
2439 finderArgs = new Object[] { pk };
2440 }
2441 else {
2442 finderArgs = new Object[] { pk, start, end, orderByComparator };
2443 }
2444
2445 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> list = (List<com.liferay.portlet.softwarecatalog.model.SCProductEntry>)FinderCacheUtil.getResult(FINDER_PATH_GET_SCPRODUCTENTRIES,
2446 finderArgs, this);
2447
2448 if (list == null) {
2449 Session session = null;
2450
2451 try {
2452 session = openSession();
2453
2454 String sql = null;
2455
2456 if (orderByComparator != null) {
2457 sql = _SQL_GETSCPRODUCTENTRIES.concat(ORDER_BY_CLAUSE)
2458 .concat(orderByComparator.getOrderBy());
2459 }
2460 else {
2461 sql = _SQL_GETSCPRODUCTENTRIES;
2462
2463 if (pagination) {
2464 sql = sql.concat(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ORDER_BY_SQL);
2465 }
2466 }
2467
2468 SQLQuery q = session.createSQLQuery(sql);
2469
2470 q.addEntity("SCProductEntry",
2471 com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryImpl.class);
2472
2473 QueryPos qPos = QueryPos.getInstance(q);
2474
2475 qPos.add(pk);
2476
2477 if (!pagination) {
2478 list = (List<com.liferay.portlet.softwarecatalog.model.SCProductEntry>)QueryUtil.list(q,
2479 getDialect(), start, end, false);
2480
2481 Collections.sort(list);
2482
2483 list = new UnmodifiableList<com.liferay.portlet.softwarecatalog.model.SCProductEntry>(list);
2484 }
2485 else {
2486 list = (List<com.liferay.portlet.softwarecatalog.model.SCProductEntry>)QueryUtil.list(q,
2487 getDialect(), start, end);
2488 }
2489
2490 scProductEntryPersistence.cacheResult(list);
2491
2492 FinderCacheUtil.putResult(FINDER_PATH_GET_SCPRODUCTENTRIES,
2493 finderArgs, list);
2494 }
2495 catch (Exception e) {
2496 FinderCacheUtil.removeResult(FINDER_PATH_GET_SCPRODUCTENTRIES,
2497 finderArgs);
2498
2499 throw processException(e);
2500 }
2501 finally {
2502 closeSession(session);
2503 }
2504 }
2505
2506 return list;
2507 }
2508
2509 public static final FinderPath FINDER_PATH_GET_SCPRODUCTENTRIES_SIZE = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
2510 SCLicenseModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
2511 Long.class,
2512 SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
2513 "getSCProductEntriesSize", new String[] { Long.class.getName() });
2514
2515 static {
2516 FINDER_PATH_GET_SCPRODUCTENTRIES_SIZE.setCacheKeyGeneratorCacheName(null);
2517 }
2518
2519
2526 public int getSCProductEntriesSize(long pk) throws SystemException {
2527 Object[] finderArgs = new Object[] { pk };
2528
2529 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_SCPRODUCTENTRIES_SIZE,
2530 finderArgs, this);
2531
2532 if (count == null) {
2533 Session session = null;
2534
2535 try {
2536 session = openSession();
2537
2538 SQLQuery q = session.createSQLQuery(_SQL_GETSCPRODUCTENTRIESSIZE);
2539
2540 q.addScalar(COUNT_COLUMN_NAME,
2541 com.liferay.portal.kernel.dao.orm.Type.LONG);
2542
2543 QueryPos qPos = QueryPos.getInstance(q);
2544
2545 qPos.add(pk);
2546
2547 count = (Long)q.uniqueResult();
2548
2549 FinderCacheUtil.putResult(FINDER_PATH_GET_SCPRODUCTENTRIES_SIZE,
2550 finderArgs, count);
2551 }
2552 catch (Exception e) {
2553 FinderCacheUtil.removeResult(FINDER_PATH_GET_SCPRODUCTENTRIES_SIZE,
2554 finderArgs);
2555
2556 throw processException(e);
2557 }
2558 finally {
2559 closeSession(session);
2560 }
2561 }
2562
2563 return count.intValue();
2564 }
2565
2566 public static final FinderPath FINDER_PATH_CONTAINS_SCPRODUCTENTRY = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
2567 SCLicenseModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
2568 Boolean.class,
2569 SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
2570 "containsSCProductEntry",
2571 new String[] { Long.class.getName(), Long.class.getName() });
2572
2573
2581 public boolean containsSCProductEntry(long pk, long scProductEntryPK)
2582 throws SystemException {
2583 Object[] finderArgs = new Object[] { pk, scProductEntryPK };
2584
2585 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_SCPRODUCTENTRY,
2586 finderArgs, this);
2587
2588 if (value == null) {
2589 try {
2590 value = Boolean.valueOf(containsSCProductEntry.contains(pk,
2591 scProductEntryPK));
2592
2593 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_SCPRODUCTENTRY,
2594 finderArgs, value);
2595 }
2596 catch (Exception e) {
2597 FinderCacheUtil.removeResult(FINDER_PATH_CONTAINS_SCPRODUCTENTRY,
2598 finderArgs);
2599
2600 throw processException(e);
2601 }
2602 }
2603
2604 return value.booleanValue();
2605 }
2606
2607
2614 public boolean containsSCProductEntries(long pk) throws SystemException {
2615 if (getSCProductEntriesSize(pk) > 0) {
2616 return true;
2617 }
2618 else {
2619 return false;
2620 }
2621 }
2622
2623
2630 public void addSCProductEntry(long pk, long scProductEntryPK)
2631 throws SystemException {
2632 try {
2633 addSCProductEntry.add(pk, scProductEntryPK);
2634 }
2635 catch (Exception e) {
2636 throw processException(e);
2637 }
2638 finally {
2639 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2640 }
2641 }
2642
2643
2650 public void addSCProductEntry(long pk,
2651 com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry)
2652 throws SystemException {
2653 try {
2654 addSCProductEntry.add(pk, scProductEntry.getPrimaryKey());
2655 }
2656 catch (Exception e) {
2657 throw processException(e);
2658 }
2659 finally {
2660 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2661 }
2662 }
2663
2664
2671 public void addSCProductEntries(long pk, long[] scProductEntryPKs)
2672 throws SystemException {
2673 try {
2674 for (long scProductEntryPK : scProductEntryPKs) {
2675 addSCProductEntry.add(pk, scProductEntryPK);
2676 }
2677 }
2678 catch (Exception e) {
2679 throw processException(e);
2680 }
2681 finally {
2682 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2683 }
2684 }
2685
2686
2693 public void addSCProductEntries(long pk,
2694 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries)
2695 throws SystemException {
2696 try {
2697 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2698 addSCProductEntry.add(pk, scProductEntry.getPrimaryKey());
2699 }
2700 }
2701 catch (Exception e) {
2702 throw processException(e);
2703 }
2704 finally {
2705 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2706 }
2707 }
2708
2709
2715 public void clearSCProductEntries(long pk) throws SystemException {
2716 try {
2717 clearSCProductEntries.clear(pk);
2718 }
2719 catch (Exception e) {
2720 throw processException(e);
2721 }
2722 finally {
2723 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2724 }
2725 }
2726
2727
2734 public void removeSCProductEntry(long pk, long scProductEntryPK)
2735 throws SystemException {
2736 try {
2737 removeSCProductEntry.remove(pk, scProductEntryPK);
2738 }
2739 catch (Exception e) {
2740 throw processException(e);
2741 }
2742 finally {
2743 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2744 }
2745 }
2746
2747
2754 public void removeSCProductEntry(long pk,
2755 com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry)
2756 throws SystemException {
2757 try {
2758 removeSCProductEntry.remove(pk, scProductEntry.getPrimaryKey());
2759 }
2760 catch (Exception e) {
2761 throw processException(e);
2762 }
2763 finally {
2764 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2765 }
2766 }
2767
2768
2775 public void removeSCProductEntries(long pk, long[] scProductEntryPKs)
2776 throws SystemException {
2777 try {
2778 for (long scProductEntryPK : scProductEntryPKs) {
2779 removeSCProductEntry.remove(pk, scProductEntryPK);
2780 }
2781 }
2782 catch (Exception e) {
2783 throw processException(e);
2784 }
2785 finally {
2786 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2787 }
2788 }
2789
2790
2797 public void removeSCProductEntries(long pk,
2798 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries)
2799 throws SystemException {
2800 try {
2801 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2802 removeSCProductEntry.remove(pk, scProductEntry.getPrimaryKey());
2803 }
2804 }
2805 catch (Exception e) {
2806 throw processException(e);
2807 }
2808 finally {
2809 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2810 }
2811 }
2812
2813
2820 public void setSCProductEntries(long pk, long[] scProductEntryPKs)
2821 throws SystemException {
2822 try {
2823 Set<Long> scProductEntryPKSet = SetUtil.fromArray(scProductEntryPKs);
2824
2825 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries =
2826 getSCProductEntries(pk);
2827
2828 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2829 if (!scProductEntryPKSet.remove(scProductEntry.getPrimaryKey())) {
2830 removeSCProductEntry.remove(pk,
2831 scProductEntry.getPrimaryKey());
2832 }
2833 }
2834
2835 for (Long scProductEntryPK : scProductEntryPKSet) {
2836 addSCProductEntry.add(pk, scProductEntryPK);
2837 }
2838 }
2839 catch (Exception e) {
2840 throw processException(e);
2841 }
2842 finally {
2843 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2844 }
2845 }
2846
2847
2854 public void setSCProductEntries(long pk,
2855 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries)
2856 throws SystemException {
2857 try {
2858 long[] scProductEntryPKs = new long[scProductEntries.size()];
2859
2860 for (int i = 0; i < scProductEntries.size(); i++) {
2861 com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry =
2862 scProductEntries.get(i);
2863
2864 scProductEntryPKs[i] = scProductEntry.getPrimaryKey();
2865 }
2866
2867 setSCProductEntries(pk, scProductEntryPKs);
2868 }
2869 catch (Exception e) {
2870 throw processException(e);
2871 }
2872 finally {
2873 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2874 }
2875 }
2876
2877
2880 public void afterPropertiesSet() {
2881 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2882 com.liferay.portal.util.PropsUtil.get(
2883 "value.object.listener.com.liferay.portlet.softwarecatalog.model.SCLicense")));
2884
2885 if (listenerClassNames.length > 0) {
2886 try {
2887 List<ModelListener<SCLicense>> listenersList = new ArrayList<ModelListener<SCLicense>>();
2888
2889 for (String listenerClassName : listenerClassNames) {
2890 listenersList.add((ModelListener<SCLicense>)InstanceFactory.newInstance(
2891 listenerClassName));
2892 }
2893
2894 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2895 }
2896 catch (Exception e) {
2897 _log.error(e);
2898 }
2899 }
2900
2901 containsSCProductEntry = new ContainsSCProductEntry();
2902
2903 addSCProductEntry = new AddSCProductEntry();
2904 clearSCProductEntries = new ClearSCProductEntries();
2905 removeSCProductEntry = new RemoveSCProductEntry();
2906 }
2907
2908 public void destroy() {
2909 EntityCacheUtil.removeCache(SCLicenseImpl.class.getName());
2910 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2911 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2912 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2913 }
2914
2915 @BeanReference(type = SCProductEntryPersistence.class)
2916 protected SCProductEntryPersistence scProductEntryPersistence;
2917 protected ContainsSCProductEntry containsSCProductEntry;
2918 protected AddSCProductEntry addSCProductEntry;
2919 protected ClearSCProductEntries clearSCProductEntries;
2920 protected RemoveSCProductEntry removeSCProductEntry;
2921
2922 protected class ContainsSCProductEntry {
2923 protected ContainsSCProductEntry() {
2924 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2925 _SQL_CONTAINSSCPRODUCTENTRY,
2926 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
2927 RowMapper.COUNT);
2928 }
2929
2930 protected boolean contains(long licenseId, long productEntryId) {
2931 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2932 new Long(licenseId), new Long(productEntryId)
2933 });
2934
2935 if (results.size() > 0) {
2936 Integer count = results.get(0);
2937
2938 if (count.intValue() > 0) {
2939 return true;
2940 }
2941 }
2942
2943 return false;
2944 }
2945
2946 private MappingSqlQuery<Integer> _mappingSqlQuery;
2947 }
2948
2949 protected class AddSCProductEntry {
2950 protected AddSCProductEntry() {
2951 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2952 "INSERT INTO SCLicenses_SCProductEntries (licenseId, productEntryId) VALUES (?, ?)",
2953 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2954 }
2955
2956 protected void add(long licenseId, long productEntryId)
2957 throws SystemException {
2958 if (!containsSCProductEntry.contains(licenseId, productEntryId)) {
2959 ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry>[] scProductEntryListeners =
2960 scProductEntryPersistence.getListeners();
2961
2962 for (ModelListener<SCLicense> listener : listeners) {
2963 listener.onBeforeAddAssociation(licenseId,
2964 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2965 productEntryId);
2966 }
2967
2968 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2969 listener.onBeforeAddAssociation(productEntryId,
2970 SCLicense.class.getName(), licenseId);
2971 }
2972
2973 _sqlUpdate.update(new Object[] {
2974 new Long(licenseId), new Long(productEntryId)
2975 });
2976
2977 for (ModelListener<SCLicense> listener : listeners) {
2978 listener.onAfterAddAssociation(licenseId,
2979 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2980 productEntryId);
2981 }
2982
2983 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2984 listener.onAfterAddAssociation(productEntryId,
2985 SCLicense.class.getName(), licenseId);
2986 }
2987 }
2988 }
2989
2990 private SqlUpdate _sqlUpdate;
2991 }
2992
2993 protected class ClearSCProductEntries {
2994 protected ClearSCProductEntries() {
2995 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2996 "DELETE FROM SCLicenses_SCProductEntries WHERE licenseId = ?",
2997 new int[] { java.sql.Types.BIGINT });
2998 }
2999
3000 protected void clear(long licenseId) throws SystemException {
3001 ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry>[] scProductEntryListeners =
3002 scProductEntryPersistence.getListeners();
3003
3004 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries =
3005 null;
3006
3007 if ((listeners.length > 0) || (scProductEntryListeners.length > 0)) {
3008 scProductEntries = getSCProductEntries(licenseId);
3009
3010 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
3011 for (ModelListener<SCLicense> listener : listeners) {
3012 listener.onBeforeRemoveAssociation(licenseId,
3013 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
3014 scProductEntry.getPrimaryKey());
3015 }
3016
3017 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
3018 listener.onBeforeRemoveAssociation(scProductEntry.getPrimaryKey(),
3019 SCLicense.class.getName(), licenseId);
3020 }
3021 }
3022 }
3023
3024 _sqlUpdate.update(new Object[] { new Long(licenseId) });
3025
3026 if ((listeners.length > 0) || (scProductEntryListeners.length > 0)) {
3027 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
3028 for (ModelListener<SCLicense> listener : listeners) {
3029 listener.onAfterRemoveAssociation(licenseId,
3030 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
3031 scProductEntry.getPrimaryKey());
3032 }
3033
3034 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
3035 listener.onAfterRemoveAssociation(scProductEntry.getPrimaryKey(),
3036 SCLicense.class.getName(), licenseId);
3037 }
3038 }
3039 }
3040 }
3041
3042 private SqlUpdate _sqlUpdate;
3043 }
3044
3045 protected class RemoveSCProductEntry {
3046 protected RemoveSCProductEntry() {
3047 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3048 "DELETE FROM SCLicenses_SCProductEntries WHERE licenseId = ? AND productEntryId = ?",
3049 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3050 }
3051
3052 protected void remove(long licenseId, long productEntryId)
3053 throws SystemException {
3054 if (containsSCProductEntry.contains(licenseId, productEntryId)) {
3055 ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry>[] scProductEntryListeners =
3056 scProductEntryPersistence.getListeners();
3057
3058 for (ModelListener<SCLicense> listener : listeners) {
3059 listener.onBeforeRemoveAssociation(licenseId,
3060 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
3061 productEntryId);
3062 }
3063
3064 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
3065 listener.onBeforeRemoveAssociation(productEntryId,
3066 SCLicense.class.getName(), licenseId);
3067 }
3068
3069 _sqlUpdate.update(new Object[] {
3070 new Long(licenseId), new Long(productEntryId)
3071 });
3072
3073 for (ModelListener<SCLicense> listener : listeners) {
3074 listener.onAfterRemoveAssociation(licenseId,
3075 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
3076 productEntryId);
3077 }
3078
3079 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
3080 listener.onAfterRemoveAssociation(productEntryId,
3081 SCLicense.class.getName(), licenseId);
3082 }
3083 }
3084 }
3085
3086 private SqlUpdate _sqlUpdate;
3087 }
3088
3089 private static final String _SQL_SELECT_SCLICENSE = "SELECT scLicense FROM SCLicense scLicense";
3090 private static final String _SQL_SELECT_SCLICENSE_WHERE = "SELECT scLicense FROM SCLicense scLicense WHERE ";
3091 private static final String _SQL_COUNT_SCLICENSE = "SELECT COUNT(scLicense) FROM SCLicense scLicense";
3092 private static final String _SQL_COUNT_SCLICENSE_WHERE = "SELECT COUNT(scLicense) FROM SCLicense scLicense WHERE ";
3093 private static final String _SQL_GETSCPRODUCTENTRIES = "SELECT {SCProductEntry.*} FROM SCProductEntry INNER JOIN SCLicenses_SCProductEntries ON (SCLicenses_SCProductEntries.productEntryId = SCProductEntry.productEntryId) WHERE (SCLicenses_SCProductEntries.licenseId = ?)";
3094 private static final String _SQL_GETSCPRODUCTENTRIESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE licenseId = ?";
3095 private static final String _SQL_CONTAINSSCPRODUCTENTRY = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE licenseId = ? AND productEntryId = ?";
3096 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "scLicense.licenseId";
3097 private static final String _FILTER_SQL_SELECT_SCLICENSE_WHERE = "SELECT DISTINCT {scLicense.*} FROM SCLicense scLicense WHERE ";
3098 private static final String _FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1 =
3099 "SELECT {SCLicense.*} FROM (SELECT DISTINCT scLicense.licenseId FROM SCLicense scLicense WHERE ";
3100 private static final String _FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2 =
3101 ") TEMP_TABLE INNER JOIN SCLicense ON TEMP_TABLE.licenseId = SCLicense.licenseId";
3102 private static final String _FILTER_SQL_COUNT_SCLICENSE_WHERE = "SELECT COUNT(DISTINCT scLicense.licenseId) AS COUNT_VALUE FROM SCLicense scLicense WHERE ";
3103 private static final String _FILTER_ENTITY_ALIAS = "scLicense";
3104 private static final String _FILTER_ENTITY_TABLE = "SCLicense";
3105 private static final String _ORDER_BY_ENTITY_ALIAS = "scLicense.";
3106 private static final String _ORDER_BY_ENTITY_TABLE = "SCLicense.";
3107 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SCLicense exists with the primary key ";
3108 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SCLicense exists with the key {";
3109 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3110 private static Log _log = LogFactoryUtil.getLog(SCLicensePersistenceImpl.class);
3111 private static SCLicense _nullSCLicense = new SCLicenseImpl() {
3112 @Override
3113 public Object clone() {
3114 return this;
3115 }
3116
3117 @Override
3118 public CacheModel<SCLicense> toCacheModel() {
3119 return _nullSCLicenseCacheModel;
3120 }
3121 };
3122
3123 private static CacheModel<SCLicense> _nullSCLicenseCacheModel = new CacheModel<SCLicense>() {
3124 public SCLicense toEntityModel() {
3125 return _nullSCLicense;
3126 }
3127 };
3128 }