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