001
014
015 package com.liferay.portlet.softwarecatalog.service.persistence.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.kernel.bean.BeanReference;
020 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderPath;
023 import com.liferay.portal.kernel.dao.orm.Query;
024 import com.liferay.portal.kernel.dao.orm.QueryPos;
025 import com.liferay.portal.kernel.dao.orm.QueryUtil;
026 import com.liferay.portal.kernel.dao.orm.SQLQuery;
027 import com.liferay.portal.kernel.dao.orm.Session;
028 import com.liferay.portal.kernel.log.Log;
029 import com.liferay.portal.kernel.log.LogFactoryUtil;
030 import com.liferay.portal.kernel.util.OrderByComparator;
031 import com.liferay.portal.kernel.util.SetUtil;
032 import com.liferay.portal.kernel.util.StringBundler;
033 import com.liferay.portal.kernel.util.StringPool;
034 import com.liferay.portal.model.CacheModel;
035 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
036 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
037 import com.liferay.portal.service.persistence.impl.TableMapper;
038 import com.liferay.portal.service.persistence.impl.TableMapperFactory;
039
040 import com.liferay.portlet.softwarecatalog.NoSuchLicenseException;
041 import com.liferay.portlet.softwarecatalog.model.SCLicense;
042 import com.liferay.portlet.softwarecatalog.model.impl.SCLicenseImpl;
043 import com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl;
044 import com.liferay.portlet.softwarecatalog.service.persistence.SCLicensePersistence;
045 import com.liferay.portlet.softwarecatalog.service.persistence.SCProductEntryPersistence;
046
047 import java.io.Serializable;
048
049 import java.util.Collections;
050 import java.util.HashMap;
051 import java.util.HashSet;
052 import java.util.Iterator;
053 import java.util.List;
054 import java.util.Map;
055 import java.util.Set;
056
057
069 @ProviderType
070 public class SCLicensePersistenceImpl extends BasePersistenceImpl<SCLicense>
071 implements SCLicensePersistence {
072
077 public static final String FINDER_CLASS_NAME_ENTITY = SCLicenseImpl.class.getName();
078 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
079 ".List1";
080 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
081 ".List2";
082 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
083 SCLicenseModelImpl.FINDER_CACHE_ENABLED, SCLicenseImpl.class,
084 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
085 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
086 SCLicenseModelImpl.FINDER_CACHE_ENABLED, SCLicenseImpl.class,
087 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
088 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
089 SCLicenseModelImpl.FINDER_CACHE_ENABLED, Long.class,
090 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
091 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_ACTIVE = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
092 SCLicenseModelImpl.FINDER_CACHE_ENABLED, SCLicenseImpl.class,
093 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByActive",
094 new String[] {
095 Boolean.class.getName(),
096
097 Integer.class.getName(), Integer.class.getName(),
098 OrderByComparator.class.getName()
099 });
100 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE =
101 new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
102 SCLicenseModelImpl.FINDER_CACHE_ENABLED, SCLicenseImpl.class,
103 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByActive",
104 new String[] { Boolean.class.getName() },
105 SCLicenseModelImpl.ACTIVE_COLUMN_BITMASK |
106 SCLicenseModelImpl.NAME_COLUMN_BITMASK);
107 public static final FinderPath FINDER_PATH_COUNT_BY_ACTIVE = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
108 SCLicenseModelImpl.FINDER_CACHE_ENABLED, Long.class,
109 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByActive",
110 new String[] { Boolean.class.getName() });
111
112
118 @Override
119 public List<SCLicense> findByActive(boolean active) {
120 return findByActive(active, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
121 }
122
123
135 @Override
136 public List<SCLicense> findByActive(boolean active, int start, int end) {
137 return findByActive(active, start, end, null);
138 }
139
140
153 @Override
154 public List<SCLicense> findByActive(boolean active, int start, int end,
155 OrderByComparator<SCLicense> orderByComparator) {
156 boolean pagination = true;
157 FinderPath finderPath = null;
158 Object[] finderArgs = null;
159
160 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
161 (orderByComparator == null)) {
162 pagination = false;
163 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE;
164 finderArgs = new Object[] { active };
165 }
166 else {
167 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_ACTIVE;
168 finderArgs = new Object[] { active, start, end, orderByComparator };
169 }
170
171 List<SCLicense> list = (List<SCLicense>)FinderCacheUtil.getResult(finderPath,
172 finderArgs, this);
173
174 if ((list != null) && !list.isEmpty()) {
175 for (SCLicense scLicense : list) {
176 if ((active != scLicense.getActive())) {
177 list = null;
178
179 break;
180 }
181 }
182 }
183
184 if (list == null) {
185 StringBundler query = null;
186
187 if (orderByComparator != null) {
188 query = new StringBundler(3 +
189 (orderByComparator.getOrderByFields().length * 3));
190 }
191 else {
192 query = new StringBundler(3);
193 }
194
195 query.append(_SQL_SELECT_SCLICENSE_WHERE);
196
197 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
198
199 if (orderByComparator != null) {
200 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
201 orderByComparator);
202 }
203 else
204 if (pagination) {
205 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
206 }
207
208 String sql = query.toString();
209
210 Session session = null;
211
212 try {
213 session = openSession();
214
215 Query q = session.createQuery(sql);
216
217 QueryPos qPos = QueryPos.getInstance(q);
218
219 qPos.add(active);
220
221 if (!pagination) {
222 list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
223 start, end, false);
224
225 Collections.sort(list);
226
227 list = Collections.unmodifiableList(list);
228 }
229 else {
230 list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
231 start, end);
232 }
233
234 cacheResult(list);
235
236 FinderCacheUtil.putResult(finderPath, finderArgs, list);
237 }
238 catch (Exception e) {
239 FinderCacheUtil.removeResult(finderPath, finderArgs);
240
241 throw processException(e);
242 }
243 finally {
244 closeSession(session);
245 }
246 }
247
248 return list;
249 }
250
251
259 @Override
260 public SCLicense findByActive_First(boolean active,
261 OrderByComparator<SCLicense> orderByComparator)
262 throws NoSuchLicenseException {
263 SCLicense scLicense = fetchByActive_First(active, orderByComparator);
264
265 if (scLicense != null) {
266 return scLicense;
267 }
268
269 StringBundler msg = new StringBundler(4);
270
271 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
272
273 msg.append("active=");
274 msg.append(active);
275
276 msg.append(StringPool.CLOSE_CURLY_BRACE);
277
278 throw new NoSuchLicenseException(msg.toString());
279 }
280
281
288 @Override
289 public SCLicense fetchByActive_First(boolean active,
290 OrderByComparator<SCLicense> orderByComparator) {
291 List<SCLicense> list = findByActive(active, 0, 1, orderByComparator);
292
293 if (!list.isEmpty()) {
294 return list.get(0);
295 }
296
297 return null;
298 }
299
300
308 @Override
309 public SCLicense findByActive_Last(boolean active,
310 OrderByComparator<SCLicense> orderByComparator)
311 throws NoSuchLicenseException {
312 SCLicense scLicense = fetchByActive_Last(active, orderByComparator);
313
314 if (scLicense != null) {
315 return scLicense;
316 }
317
318 StringBundler msg = new StringBundler(4);
319
320 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
321
322 msg.append("active=");
323 msg.append(active);
324
325 msg.append(StringPool.CLOSE_CURLY_BRACE);
326
327 throw new NoSuchLicenseException(msg.toString());
328 }
329
330
337 @Override
338 public SCLicense fetchByActive_Last(boolean active,
339 OrderByComparator<SCLicense> orderByComparator) {
340 int count = countByActive(active);
341
342 if (count == 0) {
343 return null;
344 }
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
365 @Override
366 public SCLicense[] findByActive_PrevAndNext(long licenseId, boolean active,
367 OrderByComparator<SCLicense> orderByComparator)
368 throws NoSuchLicenseException {
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<SCLicense> 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
507 @Override
508 public List<SCLicense> filterFindByActive(boolean active) {
509 return filterFindByActive(active, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
510 null);
511 }
512
513
525 @Override
526 public List<SCLicense> filterFindByActive(boolean active, int start, int end) {
527 return filterFindByActive(active, start, end, null);
528 }
529
530
543 @Override
544 public List<SCLicense> filterFindByActive(boolean active, int start,
545 int end, OrderByComparator<SCLicense> orderByComparator) {
546 if (!InlineSQLHelperUtil.isEnabled()) {
547 return findByActive(active, start, end, orderByComparator);
548 }
549
550 StringBundler query = null;
551
552 if (orderByComparator != null) {
553 query = new StringBundler(3 +
554 (orderByComparator.getOrderByFields().length * 3));
555 }
556 else {
557 query = new StringBundler(3);
558 }
559
560 if (getDB().isSupportsInlineDistinct()) {
561 query.append(_FILTER_SQL_SELECT_SCLICENSE_WHERE);
562 }
563 else {
564 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1);
565 }
566
567 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2_SQL);
568
569 if (!getDB().isSupportsInlineDistinct()) {
570 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2);
571 }
572
573 if (orderByComparator != null) {
574 if (getDB().isSupportsInlineDistinct()) {
575 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
576 orderByComparator, true);
577 }
578 else {
579 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
580 orderByComparator, true);
581 }
582 }
583 else {
584 if (getDB().isSupportsInlineDistinct()) {
585 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
586 }
587 else {
588 query.append(SCLicenseModelImpl.ORDER_BY_SQL);
589 }
590 }
591
592 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
593 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
594
595 Session session = null;
596
597 try {
598 session = openSession();
599
600 SQLQuery q = session.createSynchronizedSQLQuery(sql);
601
602 if (getDB().isSupportsInlineDistinct()) {
603 q.addEntity(_FILTER_ENTITY_ALIAS, SCLicenseImpl.class);
604 }
605 else {
606 q.addEntity(_FILTER_ENTITY_TABLE, SCLicenseImpl.class);
607 }
608
609 QueryPos qPos = QueryPos.getInstance(q);
610
611 qPos.add(active);
612
613 return (List<SCLicense>)QueryUtil.list(q, getDialect(), start, end);
614 }
615 catch (Exception e) {
616 throw processException(e);
617 }
618 finally {
619 closeSession(session);
620 }
621 }
622
623
632 @Override
633 public SCLicense[] filterFindByActive_PrevAndNext(long licenseId,
634 boolean active, OrderByComparator<SCLicense> orderByComparator)
635 throws NoSuchLicenseException {
636 if (!InlineSQLHelperUtil.isEnabled()) {
637 return findByActive_PrevAndNext(licenseId, active, orderByComparator);
638 }
639
640 SCLicense scLicense = findByPrimaryKey(licenseId);
641
642 Session session = null;
643
644 try {
645 session = openSession();
646
647 SCLicense[] array = new SCLicenseImpl[3];
648
649 array[0] = filterGetByActive_PrevAndNext(session, scLicense,
650 active, orderByComparator, true);
651
652 array[1] = scLicense;
653
654 array[2] = filterGetByActive_PrevAndNext(session, scLicense,
655 active, orderByComparator, false);
656
657 return array;
658 }
659 catch (Exception e) {
660 throw processException(e);
661 }
662 finally {
663 closeSession(session);
664 }
665 }
666
667 protected SCLicense filterGetByActive_PrevAndNext(Session session,
668 SCLicense scLicense, boolean active,
669 OrderByComparator<SCLicense> orderByComparator, boolean previous) {
670 StringBundler query = null;
671
672 if (orderByComparator != null) {
673 query = new StringBundler(6 +
674 (orderByComparator.getOrderByFields().length * 6));
675 }
676 else {
677 query = new StringBundler(3);
678 }
679
680 if (getDB().isSupportsInlineDistinct()) {
681 query.append(_FILTER_SQL_SELECT_SCLICENSE_WHERE);
682 }
683 else {
684 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1);
685 }
686
687 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2_SQL);
688
689 if (!getDB().isSupportsInlineDistinct()) {
690 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2);
691 }
692
693 if (orderByComparator != null) {
694 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
695
696 if (orderByConditionFields.length > 0) {
697 query.append(WHERE_AND);
698 }
699
700 for (int i = 0; i < orderByConditionFields.length; i++) {
701 if (getDB().isSupportsInlineDistinct()) {
702 query.append(_ORDER_BY_ENTITY_ALIAS);
703 }
704 else {
705 query.append(_ORDER_BY_ENTITY_TABLE);
706 }
707
708 query.append(orderByConditionFields[i]);
709
710 if ((i + 1) < orderByConditionFields.length) {
711 if (orderByComparator.isAscending() ^ previous) {
712 query.append(WHERE_GREATER_THAN_HAS_NEXT);
713 }
714 else {
715 query.append(WHERE_LESSER_THAN_HAS_NEXT);
716 }
717 }
718 else {
719 if (orderByComparator.isAscending() ^ previous) {
720 query.append(WHERE_GREATER_THAN);
721 }
722 else {
723 query.append(WHERE_LESSER_THAN);
724 }
725 }
726 }
727
728 query.append(ORDER_BY_CLAUSE);
729
730 String[] orderByFields = orderByComparator.getOrderByFields();
731
732 for (int i = 0; i < orderByFields.length; i++) {
733 if (getDB().isSupportsInlineDistinct()) {
734 query.append(_ORDER_BY_ENTITY_ALIAS);
735 }
736 else {
737 query.append(_ORDER_BY_ENTITY_TABLE);
738 }
739
740 query.append(orderByFields[i]);
741
742 if ((i + 1) < orderByFields.length) {
743 if (orderByComparator.isAscending() ^ previous) {
744 query.append(ORDER_BY_ASC_HAS_NEXT);
745 }
746 else {
747 query.append(ORDER_BY_DESC_HAS_NEXT);
748 }
749 }
750 else {
751 if (orderByComparator.isAscending() ^ previous) {
752 query.append(ORDER_BY_ASC);
753 }
754 else {
755 query.append(ORDER_BY_DESC);
756 }
757 }
758 }
759 }
760 else {
761 if (getDB().isSupportsInlineDistinct()) {
762 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
763 }
764 else {
765 query.append(SCLicenseModelImpl.ORDER_BY_SQL);
766 }
767 }
768
769 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
770 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
771
772 SQLQuery q = session.createSynchronizedSQLQuery(sql);
773
774 q.setFirstResult(0);
775 q.setMaxResults(2);
776
777 if (getDB().isSupportsInlineDistinct()) {
778 q.addEntity(_FILTER_ENTITY_ALIAS, SCLicenseImpl.class);
779 }
780 else {
781 q.addEntity(_FILTER_ENTITY_TABLE, SCLicenseImpl.class);
782 }
783
784 QueryPos qPos = QueryPos.getInstance(q);
785
786 qPos.add(active);
787
788 if (orderByComparator != null) {
789 Object[] values = orderByComparator.getOrderByConditionValues(scLicense);
790
791 for (Object value : values) {
792 qPos.add(value);
793 }
794 }
795
796 List<SCLicense> list = q.list();
797
798 if (list.size() == 2) {
799 return list.get(1);
800 }
801 else {
802 return null;
803 }
804 }
805
806
811 @Override
812 public void removeByActive(boolean active) {
813 for (SCLicense scLicense : findByActive(active, QueryUtil.ALL_POS,
814 QueryUtil.ALL_POS, null)) {
815 remove(scLicense);
816 }
817 }
818
819
825 @Override
826 public int countByActive(boolean active) {
827 FinderPath finderPath = FINDER_PATH_COUNT_BY_ACTIVE;
828
829 Object[] finderArgs = new Object[] { active };
830
831 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
832 this);
833
834 if (count == null) {
835 StringBundler query = new StringBundler(2);
836
837 query.append(_SQL_COUNT_SCLICENSE_WHERE);
838
839 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
840
841 String sql = query.toString();
842
843 Session session = null;
844
845 try {
846 session = openSession();
847
848 Query q = session.createQuery(sql);
849
850 QueryPos qPos = QueryPos.getInstance(q);
851
852 qPos.add(active);
853
854 count = (Long)q.uniqueResult();
855
856 FinderCacheUtil.putResult(finderPath, finderArgs, count);
857 }
858 catch (Exception e) {
859 FinderCacheUtil.removeResult(finderPath, finderArgs);
860
861 throw processException(e);
862 }
863 finally {
864 closeSession(session);
865 }
866 }
867
868 return count.intValue();
869 }
870
871
877 @Override
878 public int filterCountByActive(boolean active) {
879 if (!InlineSQLHelperUtil.isEnabled()) {
880 return countByActive(active);
881 }
882
883 StringBundler query = new StringBundler(2);
884
885 query.append(_FILTER_SQL_COUNT_SCLICENSE_WHERE);
886
887 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2_SQL);
888
889 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
890 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
891
892 Session session = null;
893
894 try {
895 session = openSession();
896
897 SQLQuery q = session.createSynchronizedSQLQuery(sql);
898
899 q.addScalar(COUNT_COLUMN_NAME,
900 com.liferay.portal.kernel.dao.orm.Type.LONG);
901
902 QueryPos qPos = QueryPos.getInstance(q);
903
904 qPos.add(active);
905
906 Long count = (Long)q.uniqueResult();
907
908 return count.intValue();
909 }
910 catch (Exception e) {
911 throw processException(e);
912 }
913 finally {
914 closeSession(session);
915 }
916 }
917
918 private static final String _FINDER_COLUMN_ACTIVE_ACTIVE_2 = "scLicense.active = ?";
919 private static final String _FINDER_COLUMN_ACTIVE_ACTIVE_2_SQL = "scLicense.active_ = ?";
920 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_A_R = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
921 SCLicenseModelImpl.FINDER_CACHE_ENABLED, SCLicenseImpl.class,
922 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByA_R",
923 new String[] {
924 Boolean.class.getName(), Boolean.class.getName(),
925
926 Integer.class.getName(), Integer.class.getName(),
927 OrderByComparator.class.getName()
928 });
929 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_A_R = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
930 SCLicenseModelImpl.FINDER_CACHE_ENABLED, SCLicenseImpl.class,
931 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByA_R",
932 new String[] { Boolean.class.getName(), Boolean.class.getName() },
933 SCLicenseModelImpl.ACTIVE_COLUMN_BITMASK |
934 SCLicenseModelImpl.RECOMMENDED_COLUMN_BITMASK |
935 SCLicenseModelImpl.NAME_COLUMN_BITMASK);
936 public static final FinderPath FINDER_PATH_COUNT_BY_A_R = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
937 SCLicenseModelImpl.FINDER_CACHE_ENABLED, Long.class,
938 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByA_R",
939 new String[] { Boolean.class.getName(), Boolean.class.getName() });
940
941
948 @Override
949 public List<SCLicense> findByA_R(boolean active, boolean recommended) {
950 return findByA_R(active, recommended, QueryUtil.ALL_POS,
951 QueryUtil.ALL_POS, null);
952 }
953
954
967 @Override
968 public List<SCLicense> findByA_R(boolean active, boolean recommended,
969 int start, int end) {
970 return findByA_R(active, recommended, start, end, null);
971 }
972
973
987 @Override
988 public List<SCLicense> findByA_R(boolean active, boolean recommended,
989 int start, int end, OrderByComparator<SCLicense> orderByComparator) {
990 boolean pagination = true;
991 FinderPath finderPath = null;
992 Object[] finderArgs = null;
993
994 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
995 (orderByComparator == null)) {
996 pagination = false;
997 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_A_R;
998 finderArgs = new Object[] { active, recommended };
999 }
1000 else {
1001 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_A_R;
1002 finderArgs = new Object[] {
1003 active, recommended,
1004
1005 start, end, orderByComparator
1006 };
1007 }
1008
1009 List<SCLicense> list = (List<SCLicense>)FinderCacheUtil.getResult(finderPath,
1010 finderArgs, this);
1011
1012 if ((list != null) && !list.isEmpty()) {
1013 for (SCLicense scLicense : list) {
1014 if ((active != scLicense.getActive()) ||
1015 (recommended != scLicense.getRecommended())) {
1016 list = null;
1017
1018 break;
1019 }
1020 }
1021 }
1022
1023 if (list == null) {
1024 StringBundler query = null;
1025
1026 if (orderByComparator != null) {
1027 query = new StringBundler(4 +
1028 (orderByComparator.getOrderByFields().length * 3));
1029 }
1030 else {
1031 query = new StringBundler(4);
1032 }
1033
1034 query.append(_SQL_SELECT_SCLICENSE_WHERE);
1035
1036 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1037
1038 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1039
1040 if (orderByComparator != null) {
1041 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1042 orderByComparator);
1043 }
1044 else
1045 if (pagination) {
1046 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1047 }
1048
1049 String sql = query.toString();
1050
1051 Session session = null;
1052
1053 try {
1054 session = openSession();
1055
1056 Query q = session.createQuery(sql);
1057
1058 QueryPos qPos = QueryPos.getInstance(q);
1059
1060 qPos.add(active);
1061
1062 qPos.add(recommended);
1063
1064 if (!pagination) {
1065 list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
1066 start, end, false);
1067
1068 Collections.sort(list);
1069
1070 list = Collections.unmodifiableList(list);
1071 }
1072 else {
1073 list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
1074 start, end);
1075 }
1076
1077 cacheResult(list);
1078
1079 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1080 }
1081 catch (Exception e) {
1082 FinderCacheUtil.removeResult(finderPath, finderArgs);
1083
1084 throw processException(e);
1085 }
1086 finally {
1087 closeSession(session);
1088 }
1089 }
1090
1091 return list;
1092 }
1093
1094
1103 @Override
1104 public SCLicense findByA_R_First(boolean active, boolean recommended,
1105 OrderByComparator<SCLicense> orderByComparator)
1106 throws NoSuchLicenseException {
1107 SCLicense scLicense = fetchByA_R_First(active, recommended,
1108 orderByComparator);
1109
1110 if (scLicense != null) {
1111 return scLicense;
1112 }
1113
1114 StringBundler msg = new StringBundler(6);
1115
1116 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1117
1118 msg.append("active=");
1119 msg.append(active);
1120
1121 msg.append(", recommended=");
1122 msg.append(recommended);
1123
1124 msg.append(StringPool.CLOSE_CURLY_BRACE);
1125
1126 throw new NoSuchLicenseException(msg.toString());
1127 }
1128
1129
1137 @Override
1138 public SCLicense fetchByA_R_First(boolean active, boolean recommended,
1139 OrderByComparator<SCLicense> orderByComparator) {
1140 List<SCLicense> list = findByA_R(active, recommended, 0, 1,
1141 orderByComparator);
1142
1143 if (!list.isEmpty()) {
1144 return list.get(0);
1145 }
1146
1147 return null;
1148 }
1149
1150
1159 @Override
1160 public SCLicense findByA_R_Last(boolean active, boolean recommended,
1161 OrderByComparator<SCLicense> orderByComparator)
1162 throws NoSuchLicenseException {
1163 SCLicense scLicense = fetchByA_R_Last(active, recommended,
1164 orderByComparator);
1165
1166 if (scLicense != null) {
1167 return scLicense;
1168 }
1169
1170 StringBundler msg = new StringBundler(6);
1171
1172 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1173
1174 msg.append("active=");
1175 msg.append(active);
1176
1177 msg.append(", recommended=");
1178 msg.append(recommended);
1179
1180 msg.append(StringPool.CLOSE_CURLY_BRACE);
1181
1182 throw new NoSuchLicenseException(msg.toString());
1183 }
1184
1185
1193 @Override
1194 public SCLicense fetchByA_R_Last(boolean active, boolean recommended,
1195 OrderByComparator<SCLicense> orderByComparator) {
1196 int count = countByA_R(active, recommended);
1197
1198 if (count == 0) {
1199 return null;
1200 }
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
1222 @Override
1223 public SCLicense[] findByA_R_PrevAndNext(long licenseId, boolean active,
1224 boolean recommended, OrderByComparator<SCLicense> orderByComparator)
1225 throws NoSuchLicenseException {
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<SCLicense> 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
1369 @Override
1370 public List<SCLicense> filterFindByA_R(boolean active, boolean recommended) {
1371 return filterFindByA_R(active, recommended, QueryUtil.ALL_POS,
1372 QueryUtil.ALL_POS, null);
1373 }
1374
1375
1388 @Override
1389 public List<SCLicense> filterFindByA_R(boolean active, boolean recommended,
1390 int start, int end) {
1391 return filterFindByA_R(active, recommended, start, end, null);
1392 }
1393
1394
1408 @Override
1409 public List<SCLicense> filterFindByA_R(boolean active, boolean recommended,
1410 int start, int end, OrderByComparator<SCLicense> orderByComparator) {
1411 if (!InlineSQLHelperUtil.isEnabled()) {
1412 return findByA_R(active, recommended, start, end, orderByComparator);
1413 }
1414
1415 StringBundler query = null;
1416
1417 if (orderByComparator != null) {
1418 query = new StringBundler(4 +
1419 (orderByComparator.getOrderByFields().length * 3));
1420 }
1421 else {
1422 query = new StringBundler(4);
1423 }
1424
1425 if (getDB().isSupportsInlineDistinct()) {
1426 query.append(_FILTER_SQL_SELECT_SCLICENSE_WHERE);
1427 }
1428 else {
1429 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1);
1430 }
1431
1432 query.append(_FINDER_COLUMN_A_R_ACTIVE_2_SQL);
1433
1434 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1435
1436 if (!getDB().isSupportsInlineDistinct()) {
1437 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2);
1438 }
1439
1440 if (orderByComparator != null) {
1441 if (getDB().isSupportsInlineDistinct()) {
1442 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1443 orderByComparator, true);
1444 }
1445 else {
1446 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1447 orderByComparator, true);
1448 }
1449 }
1450 else {
1451 if (getDB().isSupportsInlineDistinct()) {
1452 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1453 }
1454 else {
1455 query.append(SCLicenseModelImpl.ORDER_BY_SQL);
1456 }
1457 }
1458
1459 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1460 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1461
1462 Session session = null;
1463
1464 try {
1465 session = openSession();
1466
1467 SQLQuery q = session.createSynchronizedSQLQuery(sql);
1468
1469 if (getDB().isSupportsInlineDistinct()) {
1470 q.addEntity(_FILTER_ENTITY_ALIAS, SCLicenseImpl.class);
1471 }
1472 else {
1473 q.addEntity(_FILTER_ENTITY_TABLE, SCLicenseImpl.class);
1474 }
1475
1476 QueryPos qPos = QueryPos.getInstance(q);
1477
1478 qPos.add(active);
1479
1480 qPos.add(recommended);
1481
1482 return (List<SCLicense>)QueryUtil.list(q, getDialect(), start, end);
1483 }
1484 catch (Exception e) {
1485 throw processException(e);
1486 }
1487 finally {
1488 closeSession(session);
1489 }
1490 }
1491
1492
1502 @Override
1503 public SCLicense[] filterFindByA_R_PrevAndNext(long licenseId,
1504 boolean active, boolean recommended,
1505 OrderByComparator<SCLicense> orderByComparator)
1506 throws NoSuchLicenseException {
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<SCLicense> 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_SQL);
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.createSynchronizedSQLQuery(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
1688 @Override
1689 public void removeByA_R(boolean active, boolean recommended) {
1690 for (SCLicense scLicense : findByA_R(active, recommended,
1691 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1692 remove(scLicense);
1693 }
1694 }
1695
1696
1703 @Override
1704 public int countByA_R(boolean active, boolean recommended) {
1705 FinderPath finderPath = FINDER_PATH_COUNT_BY_A_R;
1706
1707 Object[] finderArgs = new Object[] { active, recommended };
1708
1709 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1710 this);
1711
1712 if (count == null) {
1713 StringBundler query = new StringBundler(3);
1714
1715 query.append(_SQL_COUNT_SCLICENSE_WHERE);
1716
1717 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1718
1719 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1720
1721 String sql = query.toString();
1722
1723 Session session = null;
1724
1725 try {
1726 session = openSession();
1727
1728 Query q = session.createQuery(sql);
1729
1730 QueryPos qPos = QueryPos.getInstance(q);
1731
1732 qPos.add(active);
1733
1734 qPos.add(recommended);
1735
1736 count = (Long)q.uniqueResult();
1737
1738 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1739 }
1740 catch (Exception e) {
1741 FinderCacheUtil.removeResult(finderPath, finderArgs);
1742
1743 throw processException(e);
1744 }
1745 finally {
1746 closeSession(session);
1747 }
1748 }
1749
1750 return count.intValue();
1751 }
1752
1753
1760 @Override
1761 public int filterCountByA_R(boolean active, boolean recommended) {
1762 if (!InlineSQLHelperUtil.isEnabled()) {
1763 return countByA_R(active, recommended);
1764 }
1765
1766 StringBundler query = new StringBundler(3);
1767
1768 query.append(_FILTER_SQL_COUNT_SCLICENSE_WHERE);
1769
1770 query.append(_FINDER_COLUMN_A_R_ACTIVE_2_SQL);
1771
1772 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1773
1774 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1775 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1776
1777 Session session = null;
1778
1779 try {
1780 session = openSession();
1781
1782 SQLQuery q = session.createSynchronizedSQLQuery(sql);
1783
1784 q.addScalar(COUNT_COLUMN_NAME,
1785 com.liferay.portal.kernel.dao.orm.Type.LONG);
1786
1787 QueryPos qPos = QueryPos.getInstance(q);
1788
1789 qPos.add(active);
1790
1791 qPos.add(recommended);
1792
1793 Long count = (Long)q.uniqueResult();
1794
1795 return count.intValue();
1796 }
1797 catch (Exception e) {
1798 throw processException(e);
1799 }
1800 finally {
1801 closeSession(session);
1802 }
1803 }
1804
1805 private static final String _FINDER_COLUMN_A_R_ACTIVE_2 = "scLicense.active = ? AND ";
1806 private static final String _FINDER_COLUMN_A_R_ACTIVE_2_SQL = "scLicense.active_ = ? AND ";
1807 private static final String _FINDER_COLUMN_A_R_RECOMMENDED_2 = "scLicense.recommended = ?";
1808
1809 public SCLicensePersistenceImpl() {
1810 setModelClass(SCLicense.class);
1811 }
1812
1813
1818 @Override
1819 public void cacheResult(SCLicense scLicense) {
1820 EntityCacheUtil.putResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
1821 SCLicenseImpl.class, scLicense.getPrimaryKey(), scLicense);
1822
1823 scLicense.resetOriginalValues();
1824 }
1825
1826
1831 @Override
1832 public void cacheResult(List<SCLicense> scLicenses) {
1833 for (SCLicense scLicense : scLicenses) {
1834 if (EntityCacheUtil.getResult(
1835 SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
1836 SCLicenseImpl.class, scLicense.getPrimaryKey()) == null) {
1837 cacheResult(scLicense);
1838 }
1839 else {
1840 scLicense.resetOriginalValues();
1841 }
1842 }
1843 }
1844
1845
1852 @Override
1853 public void clearCache() {
1854 EntityCacheUtil.clearCache(SCLicenseImpl.class);
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 @Override
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
1911 @Override
1912 public SCLicense remove(long licenseId) throws NoSuchLicenseException {
1913 return remove((Serializable)licenseId);
1914 }
1915
1916
1923 @Override
1924 public SCLicense remove(Serializable primaryKey)
1925 throws NoSuchLicenseException {
1926 Session session = null;
1927
1928 try {
1929 session = openSession();
1930
1931 SCLicense scLicense = (SCLicense)session.get(SCLicenseImpl.class,
1932 primaryKey);
1933
1934 if (scLicense == null) {
1935 if (_log.isWarnEnabled()) {
1936 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
1937 }
1938
1939 throw new NoSuchLicenseException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1940 primaryKey);
1941 }
1942
1943 return remove(scLicense);
1944 }
1945 catch (NoSuchLicenseException nsee) {
1946 throw nsee;
1947 }
1948 catch (Exception e) {
1949 throw processException(e);
1950 }
1951 finally {
1952 closeSession(session);
1953 }
1954 }
1955
1956 @Override
1957 protected SCLicense removeImpl(SCLicense scLicense) {
1958 scLicense = toUnwrappedModel(scLicense);
1959
1960 scLicenseToSCProductEntryTableMapper.deleteLeftPrimaryKeyTableMappings(scLicense.getPrimaryKey());
1961
1962 Session session = null;
1963
1964 try {
1965 session = openSession();
1966
1967 if (!session.contains(scLicense)) {
1968 scLicense = (SCLicense)session.get(SCLicenseImpl.class,
1969 scLicense.getPrimaryKeyObj());
1970 }
1971
1972 if (scLicense != null) {
1973 session.delete(scLicense);
1974 }
1975 }
1976 catch (Exception e) {
1977 throw processException(e);
1978 }
1979 finally {
1980 closeSession(session);
1981 }
1982
1983 if (scLicense != null) {
1984 clearCache(scLicense);
1985 }
1986
1987 return scLicense;
1988 }
1989
1990 @Override
1991 public SCLicense updateImpl(SCLicense scLicense) {
1992 scLicense = toUnwrappedModel(scLicense);
1993
1994 boolean isNew = scLicense.isNew();
1995
1996 SCLicenseModelImpl scLicenseModelImpl = (SCLicenseModelImpl)scLicense;
1997
1998 Session session = null;
1999
2000 try {
2001 session = openSession();
2002
2003 if (scLicense.isNew()) {
2004 session.save(scLicense);
2005
2006 scLicense.setNew(false);
2007 }
2008 else {
2009 session.merge(scLicense);
2010 }
2011 }
2012 catch (Exception e) {
2013 throw processException(e);
2014 }
2015 finally {
2016 closeSession(session);
2017 }
2018
2019 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2020
2021 if (isNew || !SCLicenseModelImpl.COLUMN_BITMASK_ENABLED) {
2022 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2023 }
2024
2025 else {
2026 if ((scLicenseModelImpl.getColumnBitmask() &
2027 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE.getColumnBitmask()) != 0) {
2028 Object[] args = new Object[] {
2029 scLicenseModelImpl.getOriginalActive()
2030 };
2031
2032 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ACTIVE, args);
2033 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE,
2034 args);
2035
2036 args = new Object[] { scLicenseModelImpl.getActive() };
2037
2038 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ACTIVE, args);
2039 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE,
2040 args);
2041 }
2042
2043 if ((scLicenseModelImpl.getColumnBitmask() &
2044 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_A_R.getColumnBitmask()) != 0) {
2045 Object[] args = new Object[] {
2046 scLicenseModelImpl.getOriginalActive(),
2047 scLicenseModelImpl.getOriginalRecommended()
2048 };
2049
2050 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_A_R, args);
2051 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_A_R,
2052 args);
2053
2054 args = new Object[] {
2055 scLicenseModelImpl.getActive(),
2056 scLicenseModelImpl.getRecommended()
2057 };
2058
2059 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_A_R, args);
2060 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_A_R,
2061 args);
2062 }
2063 }
2064
2065 EntityCacheUtil.putResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
2066 SCLicenseImpl.class, scLicense.getPrimaryKey(), scLicense, false);
2067
2068 scLicense.resetOriginalValues();
2069
2070 return scLicense;
2071 }
2072
2073 protected SCLicense toUnwrappedModel(SCLicense scLicense) {
2074 if (scLicense instanceof SCLicenseImpl) {
2075 return scLicense;
2076 }
2077
2078 SCLicenseImpl scLicenseImpl = new SCLicenseImpl();
2079
2080 scLicenseImpl.setNew(scLicense.isNew());
2081 scLicenseImpl.setPrimaryKey(scLicense.getPrimaryKey());
2082
2083 scLicenseImpl.setLicenseId(scLicense.getLicenseId());
2084 scLicenseImpl.setName(scLicense.getName());
2085 scLicenseImpl.setUrl(scLicense.getUrl());
2086 scLicenseImpl.setOpenSource(scLicense.isOpenSource());
2087 scLicenseImpl.setActive(scLicense.isActive());
2088 scLicenseImpl.setRecommended(scLicense.isRecommended());
2089
2090 return scLicenseImpl;
2091 }
2092
2093
2100 @Override
2101 public SCLicense findByPrimaryKey(Serializable primaryKey)
2102 throws NoSuchLicenseException {
2103 SCLicense scLicense = fetchByPrimaryKey(primaryKey);
2104
2105 if (scLicense == null) {
2106 if (_log.isWarnEnabled()) {
2107 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2108 }
2109
2110 throw new NoSuchLicenseException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2111 primaryKey);
2112 }
2113
2114 return scLicense;
2115 }
2116
2117
2124 @Override
2125 public SCLicense findByPrimaryKey(long licenseId)
2126 throws NoSuchLicenseException {
2127 return findByPrimaryKey((Serializable)licenseId);
2128 }
2129
2130
2136 @Override
2137 public SCLicense fetchByPrimaryKey(Serializable primaryKey) {
2138 SCLicense scLicense = (SCLicense)EntityCacheUtil.getResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
2139 SCLicenseImpl.class, primaryKey);
2140
2141 if (scLicense == _nullSCLicense) {
2142 return null;
2143 }
2144
2145 if (scLicense == null) {
2146 Session session = null;
2147
2148 try {
2149 session = openSession();
2150
2151 scLicense = (SCLicense)session.get(SCLicenseImpl.class,
2152 primaryKey);
2153
2154 if (scLicense != null) {
2155 cacheResult(scLicense);
2156 }
2157 else {
2158 EntityCacheUtil.putResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
2159 SCLicenseImpl.class, primaryKey, _nullSCLicense);
2160 }
2161 }
2162 catch (Exception e) {
2163 EntityCacheUtil.removeResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
2164 SCLicenseImpl.class, primaryKey);
2165
2166 throw processException(e);
2167 }
2168 finally {
2169 closeSession(session);
2170 }
2171 }
2172
2173 return scLicense;
2174 }
2175
2176
2182 @Override
2183 public SCLicense fetchByPrimaryKey(long licenseId) {
2184 return fetchByPrimaryKey((Serializable)licenseId);
2185 }
2186
2187 @Override
2188 public Map<Serializable, SCLicense> fetchByPrimaryKeys(
2189 Set<Serializable> primaryKeys) {
2190 if (primaryKeys.isEmpty()) {
2191 return Collections.emptyMap();
2192 }
2193
2194 Map<Serializable, SCLicense> map = new HashMap<Serializable, SCLicense>();
2195
2196 if (primaryKeys.size() == 1) {
2197 Iterator<Serializable> iterator = primaryKeys.iterator();
2198
2199 Serializable primaryKey = iterator.next();
2200
2201 SCLicense scLicense = fetchByPrimaryKey(primaryKey);
2202
2203 if (scLicense != null) {
2204 map.put(primaryKey, scLicense);
2205 }
2206
2207 return map;
2208 }
2209
2210 Set<Serializable> uncachedPrimaryKeys = null;
2211
2212 for (Serializable primaryKey : primaryKeys) {
2213 SCLicense scLicense = (SCLicense)EntityCacheUtil.getResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
2214 SCLicenseImpl.class, primaryKey);
2215
2216 if (scLicense == null) {
2217 if (uncachedPrimaryKeys == null) {
2218 uncachedPrimaryKeys = new HashSet<Serializable>();
2219 }
2220
2221 uncachedPrimaryKeys.add(primaryKey);
2222 }
2223 else {
2224 map.put(primaryKey, scLicense);
2225 }
2226 }
2227
2228 if (uncachedPrimaryKeys == null) {
2229 return map;
2230 }
2231
2232 StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
2233 1);
2234
2235 query.append(_SQL_SELECT_SCLICENSE_WHERE_PKS_IN);
2236
2237 for (Serializable primaryKey : uncachedPrimaryKeys) {
2238 query.append(String.valueOf(primaryKey));
2239
2240 query.append(StringPool.COMMA);
2241 }
2242
2243 query.setIndex(query.index() - 1);
2244
2245 query.append(StringPool.CLOSE_PARENTHESIS);
2246
2247 String sql = query.toString();
2248
2249 Session session = null;
2250
2251 try {
2252 session = openSession();
2253
2254 Query q = session.createQuery(sql);
2255
2256 for (SCLicense scLicense : (List<SCLicense>)q.list()) {
2257 map.put(scLicense.getPrimaryKeyObj(), scLicense);
2258
2259 cacheResult(scLicense);
2260
2261 uncachedPrimaryKeys.remove(scLicense.getPrimaryKeyObj());
2262 }
2263
2264 for (Serializable primaryKey : uncachedPrimaryKeys) {
2265 EntityCacheUtil.putResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
2266 SCLicenseImpl.class, primaryKey, _nullSCLicense);
2267 }
2268 }
2269 catch (Exception e) {
2270 throw processException(e);
2271 }
2272 finally {
2273 closeSession(session);
2274 }
2275
2276 return map;
2277 }
2278
2279
2284 @Override
2285 public List<SCLicense> findAll() {
2286 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2287 }
2288
2289
2300 @Override
2301 public List<SCLicense> findAll(int start, int end) {
2302 return findAll(start, end, null);
2303 }
2304
2305
2317 @Override
2318 public List<SCLicense> findAll(int start, int end,
2319 OrderByComparator<SCLicense> orderByComparator) {
2320 boolean pagination = true;
2321 FinderPath finderPath = null;
2322 Object[] finderArgs = null;
2323
2324 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2325 (orderByComparator == null)) {
2326 pagination = false;
2327 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2328 finderArgs = FINDER_ARGS_EMPTY;
2329 }
2330 else {
2331 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2332 finderArgs = new Object[] { start, end, orderByComparator };
2333 }
2334
2335 List<SCLicense> list = (List<SCLicense>)FinderCacheUtil.getResult(finderPath,
2336 finderArgs, this);
2337
2338 if (list == null) {
2339 StringBundler query = null;
2340 String sql = null;
2341
2342 if (orderByComparator != null) {
2343 query = new StringBundler(2 +
2344 (orderByComparator.getOrderByFields().length * 3));
2345
2346 query.append(_SQL_SELECT_SCLICENSE);
2347
2348 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2349 orderByComparator);
2350
2351 sql = query.toString();
2352 }
2353 else {
2354 sql = _SQL_SELECT_SCLICENSE;
2355
2356 if (pagination) {
2357 sql = sql.concat(SCLicenseModelImpl.ORDER_BY_JPQL);
2358 }
2359 }
2360
2361 Session session = null;
2362
2363 try {
2364 session = openSession();
2365
2366 Query q = session.createQuery(sql);
2367
2368 if (!pagination) {
2369 list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
2370 start, end, false);
2371
2372 Collections.sort(list);
2373
2374 list = Collections.unmodifiableList(list);
2375 }
2376 else {
2377 list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
2378 start, end);
2379 }
2380
2381 cacheResult(list);
2382
2383 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2384 }
2385 catch (Exception e) {
2386 FinderCacheUtil.removeResult(finderPath, finderArgs);
2387
2388 throw processException(e);
2389 }
2390 finally {
2391 closeSession(session);
2392 }
2393 }
2394
2395 return list;
2396 }
2397
2398
2402 @Override
2403 public void removeAll() {
2404 for (SCLicense scLicense : findAll()) {
2405 remove(scLicense);
2406 }
2407 }
2408
2409
2414 @Override
2415 public int countAll() {
2416 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2417 FINDER_ARGS_EMPTY, this);
2418
2419 if (count == null) {
2420 Session session = null;
2421
2422 try {
2423 session = openSession();
2424
2425 Query q = session.createQuery(_SQL_COUNT_SCLICENSE);
2426
2427 count = (Long)q.uniqueResult();
2428
2429 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2430 FINDER_ARGS_EMPTY, count);
2431 }
2432 catch (Exception e) {
2433 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
2434 FINDER_ARGS_EMPTY);
2435
2436 throw processException(e);
2437 }
2438 finally {
2439 closeSession(session);
2440 }
2441 }
2442
2443 return count.intValue();
2444 }
2445
2446
2452 @Override
2453 public long[] getSCProductEntryPrimaryKeys(long pk) {
2454 long[] pks = scLicenseToSCProductEntryTableMapper.getRightPrimaryKeys(pk);
2455
2456 return pks.clone();
2457 }
2458
2459
2465 @Override
2466 public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
2467 long pk) {
2468 return getSCProductEntries(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2469 }
2470
2471
2483 @Override
2484 public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
2485 long pk, int start, int end) {
2486 return getSCProductEntries(pk, start, end, null);
2487 }
2488
2489
2502 @Override
2503 public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
2504 long pk, int start, int end,
2505 OrderByComparator<com.liferay.portlet.softwarecatalog.model.SCProductEntry> orderByComparator) {
2506 return scLicenseToSCProductEntryTableMapper.getRightBaseModels(pk,
2507 start, end, orderByComparator);
2508 }
2509
2510
2516 @Override
2517 public int getSCProductEntriesSize(long pk) {
2518 long[] pks = scLicenseToSCProductEntryTableMapper.getRightPrimaryKeys(pk);
2519
2520 return pks.length;
2521 }
2522
2523
2530 @Override
2531 public boolean containsSCProductEntry(long pk, long scProductEntryPK) {
2532 return scLicenseToSCProductEntryTableMapper.containsTableMapping(pk,
2533 scProductEntryPK);
2534 }
2535
2536
2542 @Override
2543 public boolean containsSCProductEntries(long pk) {
2544 if (getSCProductEntriesSize(pk) > 0) {
2545 return true;
2546 }
2547 else {
2548 return false;
2549 }
2550 }
2551
2552
2558 @Override
2559 public void addSCProductEntry(long pk, long scProductEntryPK) {
2560 scLicenseToSCProductEntryTableMapper.addTableMapping(pk,
2561 scProductEntryPK);
2562 }
2563
2564
2570 @Override
2571 public void addSCProductEntry(long pk,
2572 com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry) {
2573 scLicenseToSCProductEntryTableMapper.addTableMapping(pk,
2574 scProductEntry.getPrimaryKey());
2575 }
2576
2577
2583 @Override
2584 public void addSCProductEntries(long pk, long[] scProductEntryPKs) {
2585 for (long scProductEntryPK : scProductEntryPKs) {
2586 scLicenseToSCProductEntryTableMapper.addTableMapping(pk,
2587 scProductEntryPK);
2588 }
2589 }
2590
2591
2597 @Override
2598 public void addSCProductEntries(long pk,
2599 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries) {
2600 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2601 scLicenseToSCProductEntryTableMapper.addTableMapping(pk,
2602 scProductEntry.getPrimaryKey());
2603 }
2604 }
2605
2606
2611 @Override
2612 public void clearSCProductEntries(long pk) {
2613 scLicenseToSCProductEntryTableMapper.deleteLeftPrimaryKeyTableMappings(pk);
2614 }
2615
2616
2622 @Override
2623 public void removeSCProductEntry(long pk, long scProductEntryPK) {
2624 scLicenseToSCProductEntryTableMapper.deleteTableMapping(pk,
2625 scProductEntryPK);
2626 }
2627
2628
2634 @Override
2635 public void removeSCProductEntry(long pk,
2636 com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry) {
2637 scLicenseToSCProductEntryTableMapper.deleteTableMapping(pk,
2638 scProductEntry.getPrimaryKey());
2639 }
2640
2641
2647 @Override
2648 public void removeSCProductEntries(long pk, long[] scProductEntryPKs) {
2649 for (long scProductEntryPK : scProductEntryPKs) {
2650 scLicenseToSCProductEntryTableMapper.deleteTableMapping(pk,
2651 scProductEntryPK);
2652 }
2653 }
2654
2655
2661 @Override
2662 public void removeSCProductEntries(long pk,
2663 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries) {
2664 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2665 scLicenseToSCProductEntryTableMapper.deleteTableMapping(pk,
2666 scProductEntry.getPrimaryKey());
2667 }
2668 }
2669
2670
2676 @Override
2677 public void setSCProductEntries(long pk, long[] scProductEntryPKs) {
2678 Set<Long> newSCProductEntryPKsSet = SetUtil.fromArray(scProductEntryPKs);
2679 Set<Long> oldSCProductEntryPKsSet = SetUtil.fromArray(scLicenseToSCProductEntryTableMapper.getRightPrimaryKeys(
2680 pk));
2681
2682 Set<Long> removeSCProductEntryPKsSet = new HashSet<Long>(oldSCProductEntryPKsSet);
2683
2684 removeSCProductEntryPKsSet.removeAll(newSCProductEntryPKsSet);
2685
2686 for (long removeSCProductEntryPK : removeSCProductEntryPKsSet) {
2687 scLicenseToSCProductEntryTableMapper.deleteTableMapping(pk,
2688 removeSCProductEntryPK);
2689 }
2690
2691 newSCProductEntryPKsSet.removeAll(oldSCProductEntryPKsSet);
2692
2693 for (long newSCProductEntryPK : newSCProductEntryPKsSet) {
2694 scLicenseToSCProductEntryTableMapper.addTableMapping(pk,
2695 newSCProductEntryPK);
2696 }
2697 }
2698
2699
2705 @Override
2706 public void setSCProductEntries(long pk,
2707 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries) {
2708 try {
2709 long[] scProductEntryPKs = new long[scProductEntries.size()];
2710
2711 for (int i = 0; i < scProductEntries.size(); i++) {
2712 com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry =
2713 scProductEntries.get(i);
2714
2715 scProductEntryPKs[i] = scProductEntry.getPrimaryKey();
2716 }
2717
2718 setSCProductEntries(pk, scProductEntryPKs);
2719 }
2720 catch (Exception e) {
2721 throw processException(e);
2722 }
2723 }
2724
2725 @Override
2726 protected Set<String> getBadColumnNames() {
2727 return _badColumnNames;
2728 }
2729
2730
2733 public void afterPropertiesSet() {
2734 scLicenseToSCProductEntryTableMapper = TableMapperFactory.getTableMapper("SCLicenses_SCProductEntries",
2735 "licenseId", "productEntryId", this, scProductEntryPersistence);
2736 }
2737
2738 public void destroy() {
2739 EntityCacheUtil.removeCache(SCLicenseImpl.class.getName());
2740 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2741 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2742 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2743
2744 TableMapperFactory.removeTableMapper("SCLicenses_SCProductEntries");
2745 }
2746
2747 @BeanReference(type = SCProductEntryPersistence.class)
2748 protected SCProductEntryPersistence scProductEntryPersistence;
2749 protected TableMapper<SCLicense, com.liferay.portlet.softwarecatalog.model.SCProductEntry> scLicenseToSCProductEntryTableMapper;
2750 private static final String _SQL_SELECT_SCLICENSE = "SELECT scLicense FROM SCLicense scLicense";
2751 private static final String _SQL_SELECT_SCLICENSE_WHERE_PKS_IN = "SELECT scLicense FROM SCLicense scLicense WHERE licenseId IN (";
2752 private static final String _SQL_SELECT_SCLICENSE_WHERE = "SELECT scLicense FROM SCLicense scLicense WHERE ";
2753 private static final String _SQL_COUNT_SCLICENSE = "SELECT COUNT(scLicense) FROM SCLicense scLicense";
2754 private static final String _SQL_COUNT_SCLICENSE_WHERE = "SELECT COUNT(scLicense) FROM SCLicense scLicense WHERE ";
2755 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "scLicense.licenseId";
2756 private static final String _FILTER_SQL_SELECT_SCLICENSE_WHERE = "SELECT DISTINCT {scLicense.*} FROM SCLicense scLicense WHERE ";
2757 private static final String _FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1 =
2758 "SELECT {SCLicense.*} FROM (SELECT DISTINCT scLicense.licenseId FROM SCLicense scLicense WHERE ";
2759 private static final String _FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2 =
2760 ") TEMP_TABLE INNER JOIN SCLicense ON TEMP_TABLE.licenseId = SCLicense.licenseId";
2761 private static final String _FILTER_SQL_COUNT_SCLICENSE_WHERE = "SELECT COUNT(DISTINCT scLicense.licenseId) AS COUNT_VALUE FROM SCLicense scLicense WHERE ";
2762 private static final String _FILTER_ENTITY_ALIAS = "scLicense";
2763 private static final String _FILTER_ENTITY_TABLE = "SCLicense";
2764 private static final String _ORDER_BY_ENTITY_ALIAS = "scLicense.";
2765 private static final String _ORDER_BY_ENTITY_TABLE = "SCLicense.";
2766 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SCLicense exists with the primary key ";
2767 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SCLicense exists with the key {";
2768 private static final Log _log = LogFactoryUtil.getLog(SCLicensePersistenceImpl.class);
2769 private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
2770 "active"
2771 });
2772 private static final SCLicense _nullSCLicense = new SCLicenseImpl() {
2773 @Override
2774 public Object clone() {
2775 return this;
2776 }
2777
2778 @Override
2779 public CacheModel<SCLicense> toCacheModel() {
2780 return _nullSCLicenseCacheModel;
2781 }
2782 };
2783
2784 private static final CacheModel<SCLicense> _nullSCLicenseCacheModel = new CacheModel<SCLicense>() {
2785 @Override
2786 public SCLicense toEntityModel() {
2787 return _nullSCLicense;
2788 }
2789 };
2790 }