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.EntityCache;
021 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderCache;
023 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
024 import com.liferay.portal.kernel.dao.orm.FinderPath;
025 import com.liferay.portal.kernel.dao.orm.Query;
026 import com.liferay.portal.kernel.dao.orm.QueryPos;
027 import com.liferay.portal.kernel.dao.orm.QueryUtil;
028 import com.liferay.portal.kernel.dao.orm.SQLQuery;
029 import com.liferay.portal.kernel.dao.orm.Session;
030 import com.liferay.portal.kernel.log.Log;
031 import com.liferay.portal.kernel.log.LogFactoryUtil;
032 import com.liferay.portal.kernel.util.OrderByComparator;
033 import com.liferay.portal.kernel.util.SetUtil;
034 import com.liferay.portal.kernel.util.StringBundler;
035 import com.liferay.portal.kernel.util.StringPool;
036 import com.liferay.portal.model.CacheModel;
037 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
038 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
039 import com.liferay.portal.service.persistence.impl.TableMapper;
040 import com.liferay.portal.service.persistence.impl.TableMapperFactory;
041
042 import com.liferay.portlet.softwarecatalog.NoSuchLicenseException;
043 import com.liferay.portlet.softwarecatalog.model.SCLicense;
044 import com.liferay.portlet.softwarecatalog.model.impl.SCLicenseImpl;
045 import com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl;
046 import com.liferay.portlet.softwarecatalog.service.persistence.SCLicensePersistence;
047 import com.liferay.portlet.softwarecatalog.service.persistence.SCProductEntryPersistence;
048
049 import java.io.Serializable;
050
051 import java.util.Collections;
052 import java.util.HashMap;
053 import java.util.HashSet;
054 import java.util.Iterator;
055 import java.util.List;
056 import java.util.Map;
057 import java.util.Set;
058
059
071 @ProviderType
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
120 @Override
121 public List<SCLicense> findByActive(boolean active) {
122 return findByActive(active, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
123 }
124
125
137 @Override
138 public List<SCLicense> findByActive(boolean active, int start, int end) {
139 return findByActive(active, start, end, null);
140 }
141
142
155 @Override
156 public List<SCLicense> findByActive(boolean active, int start, int end,
157 OrderByComparator<SCLicense> orderByComparator) {
158 return findByActive(active, start, end, orderByComparator, true);
159 }
160
161
175 @Override
176 public List<SCLicense> findByActive(boolean active, int start, int end,
177 OrderByComparator<SCLicense> orderByComparator,
178 boolean retrieveFromCache) {
179 boolean pagination = true;
180 FinderPath finderPath = null;
181 Object[] finderArgs = null;
182
183 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
184 (orderByComparator == null)) {
185 pagination = false;
186 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE;
187 finderArgs = new Object[] { active };
188 }
189 else {
190 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_ACTIVE;
191 finderArgs = new Object[] { active, start, end, orderByComparator };
192 }
193
194 List<SCLicense> list = null;
195
196 if (retrieveFromCache) {
197 list = (List<SCLicense>)finderCache.getResult(finderPath,
198 finderArgs, this);
199
200 if ((list != null) && !list.isEmpty()) {
201 for (SCLicense scLicense : list) {
202 if ((active != scLicense.getActive())) {
203 list = null;
204
205 break;
206 }
207 }
208 }
209 }
210
211 if (list == null) {
212 StringBundler query = null;
213
214 if (orderByComparator != null) {
215 query = new StringBundler(3 +
216 (orderByComparator.getOrderByFields().length * 3));
217 }
218 else {
219 query = new StringBundler(3);
220 }
221
222 query.append(_SQL_SELECT_SCLICENSE_WHERE);
223
224 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
225
226 if (orderByComparator != null) {
227 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
228 orderByComparator);
229 }
230 else
231 if (pagination) {
232 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
233 }
234
235 String sql = query.toString();
236
237 Session session = null;
238
239 try {
240 session = openSession();
241
242 Query q = session.createQuery(sql);
243
244 QueryPos qPos = QueryPos.getInstance(q);
245
246 qPos.add(active);
247
248 if (!pagination) {
249 list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
250 start, end, false);
251
252 Collections.sort(list);
253
254 list = Collections.unmodifiableList(list);
255 }
256 else {
257 list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
258 start, end);
259 }
260
261 cacheResult(list);
262
263 finderCache.putResult(finderPath, finderArgs, list);
264 }
265 catch (Exception e) {
266 finderCache.removeResult(finderPath, finderArgs);
267
268 throw processException(e);
269 }
270 finally {
271 closeSession(session);
272 }
273 }
274
275 return list;
276 }
277
278
286 @Override
287 public SCLicense findByActive_First(boolean active,
288 OrderByComparator<SCLicense> orderByComparator)
289 throws NoSuchLicenseException {
290 SCLicense scLicense = fetchByActive_First(active, orderByComparator);
291
292 if (scLicense != null) {
293 return scLicense;
294 }
295
296 StringBundler msg = new StringBundler(4);
297
298 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
299
300 msg.append("active=");
301 msg.append(active);
302
303 msg.append(StringPool.CLOSE_CURLY_BRACE);
304
305 throw new NoSuchLicenseException(msg.toString());
306 }
307
308
315 @Override
316 public SCLicense fetchByActive_First(boolean active,
317 OrderByComparator<SCLicense> orderByComparator) {
318 List<SCLicense> list = findByActive(active, 0, 1, orderByComparator);
319
320 if (!list.isEmpty()) {
321 return list.get(0);
322 }
323
324 return null;
325 }
326
327
335 @Override
336 public SCLicense findByActive_Last(boolean active,
337 OrderByComparator<SCLicense> orderByComparator)
338 throws NoSuchLicenseException {
339 SCLicense scLicense = fetchByActive_Last(active, orderByComparator);
340
341 if (scLicense != null) {
342 return scLicense;
343 }
344
345 StringBundler msg = new StringBundler(4);
346
347 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
348
349 msg.append("active=");
350 msg.append(active);
351
352 msg.append(StringPool.CLOSE_CURLY_BRACE);
353
354 throw new NoSuchLicenseException(msg.toString());
355 }
356
357
364 @Override
365 public SCLicense fetchByActive_Last(boolean active,
366 OrderByComparator<SCLicense> orderByComparator) {
367 int count = countByActive(active);
368
369 if (count == 0) {
370 return null;
371 }
372
373 List<SCLicense> list = findByActive(active, count - 1, count,
374 orderByComparator);
375
376 if (!list.isEmpty()) {
377 return list.get(0);
378 }
379
380 return null;
381 }
382
383
392 @Override
393 public SCLicense[] findByActive_PrevAndNext(long licenseId, boolean active,
394 OrderByComparator<SCLicense> orderByComparator)
395 throws NoSuchLicenseException {
396 SCLicense scLicense = findByPrimaryKey(licenseId);
397
398 Session session = null;
399
400 try {
401 session = openSession();
402
403 SCLicense[] array = new SCLicenseImpl[3];
404
405 array[0] = getByActive_PrevAndNext(session, scLicense, active,
406 orderByComparator, true);
407
408 array[1] = scLicense;
409
410 array[2] = getByActive_PrevAndNext(session, scLicense, active,
411 orderByComparator, false);
412
413 return array;
414 }
415 catch (Exception e) {
416 throw processException(e);
417 }
418 finally {
419 closeSession(session);
420 }
421 }
422
423 protected SCLicense getByActive_PrevAndNext(Session session,
424 SCLicense scLicense, boolean active,
425 OrderByComparator<SCLicense> orderByComparator, boolean previous) {
426 StringBundler query = null;
427
428 if (orderByComparator != null) {
429 query = new StringBundler(6 +
430 (orderByComparator.getOrderByFields().length * 6));
431 }
432 else {
433 query = new StringBundler(3);
434 }
435
436 query.append(_SQL_SELECT_SCLICENSE_WHERE);
437
438 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
439
440 if (orderByComparator != null) {
441 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
442
443 if (orderByConditionFields.length > 0) {
444 query.append(WHERE_AND);
445 }
446
447 for (int i = 0; i < orderByConditionFields.length; i++) {
448 query.append(_ORDER_BY_ENTITY_ALIAS);
449 query.append(orderByConditionFields[i]);
450
451 if ((i + 1) < orderByConditionFields.length) {
452 if (orderByComparator.isAscending() ^ previous) {
453 query.append(WHERE_GREATER_THAN_HAS_NEXT);
454 }
455 else {
456 query.append(WHERE_LESSER_THAN_HAS_NEXT);
457 }
458 }
459 else {
460 if (orderByComparator.isAscending() ^ previous) {
461 query.append(WHERE_GREATER_THAN);
462 }
463 else {
464 query.append(WHERE_LESSER_THAN);
465 }
466 }
467 }
468
469 query.append(ORDER_BY_CLAUSE);
470
471 String[] orderByFields = orderByComparator.getOrderByFields();
472
473 for (int i = 0; i < orderByFields.length; i++) {
474 query.append(_ORDER_BY_ENTITY_ALIAS);
475 query.append(orderByFields[i]);
476
477 if ((i + 1) < orderByFields.length) {
478 if (orderByComparator.isAscending() ^ previous) {
479 query.append(ORDER_BY_ASC_HAS_NEXT);
480 }
481 else {
482 query.append(ORDER_BY_DESC_HAS_NEXT);
483 }
484 }
485 else {
486 if (orderByComparator.isAscending() ^ previous) {
487 query.append(ORDER_BY_ASC);
488 }
489 else {
490 query.append(ORDER_BY_DESC);
491 }
492 }
493 }
494 }
495 else {
496 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
497 }
498
499 String sql = query.toString();
500
501 Query q = session.createQuery(sql);
502
503 q.setFirstResult(0);
504 q.setMaxResults(2);
505
506 QueryPos qPos = QueryPos.getInstance(q);
507
508 qPos.add(active);
509
510 if (orderByComparator != null) {
511 Object[] values = orderByComparator.getOrderByConditionValues(scLicense);
512
513 for (Object value : values) {
514 qPos.add(value);
515 }
516 }
517
518 List<SCLicense> list = q.list();
519
520 if (list.size() == 2) {
521 return list.get(1);
522 }
523 else {
524 return null;
525 }
526 }
527
528
534 @Override
535 public List<SCLicense> filterFindByActive(boolean active) {
536 return filterFindByActive(active, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
537 null);
538 }
539
540
552 @Override
553 public List<SCLicense> filterFindByActive(boolean active, int start, int end) {
554 return filterFindByActive(active, start, end, null);
555 }
556
557
570 @Override
571 public List<SCLicense> filterFindByActive(boolean active, int start,
572 int end, OrderByComparator<SCLicense> orderByComparator) {
573 if (!InlineSQLHelperUtil.isEnabled()) {
574 return findByActive(active, start, end, orderByComparator);
575 }
576
577 StringBundler query = null;
578
579 if (orderByComparator != null) {
580 query = new StringBundler(3 +
581 (orderByComparator.getOrderByFields().length * 3));
582 }
583 else {
584 query = new StringBundler(3);
585 }
586
587 if (getDB().isSupportsInlineDistinct()) {
588 query.append(_FILTER_SQL_SELECT_SCLICENSE_WHERE);
589 }
590 else {
591 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1);
592 }
593
594 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2_SQL);
595
596 if (!getDB().isSupportsInlineDistinct()) {
597 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2);
598 }
599
600 if (orderByComparator != null) {
601 if (getDB().isSupportsInlineDistinct()) {
602 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
603 orderByComparator, true);
604 }
605 else {
606 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
607 orderByComparator, true);
608 }
609 }
610 else {
611 if (getDB().isSupportsInlineDistinct()) {
612 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
613 }
614 else {
615 query.append(SCLicenseModelImpl.ORDER_BY_SQL);
616 }
617 }
618
619 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
620 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
621
622 Session session = null;
623
624 try {
625 session = openSession();
626
627 SQLQuery q = session.createSynchronizedSQLQuery(sql);
628
629 if (getDB().isSupportsInlineDistinct()) {
630 q.addEntity(_FILTER_ENTITY_ALIAS, SCLicenseImpl.class);
631 }
632 else {
633 q.addEntity(_FILTER_ENTITY_TABLE, SCLicenseImpl.class);
634 }
635
636 QueryPos qPos = QueryPos.getInstance(q);
637
638 qPos.add(active);
639
640 return (List<SCLicense>)QueryUtil.list(q, getDialect(), start, end);
641 }
642 catch (Exception e) {
643 throw processException(e);
644 }
645 finally {
646 closeSession(session);
647 }
648 }
649
650
659 @Override
660 public SCLicense[] filterFindByActive_PrevAndNext(long licenseId,
661 boolean active, OrderByComparator<SCLicense> orderByComparator)
662 throws NoSuchLicenseException {
663 if (!InlineSQLHelperUtil.isEnabled()) {
664 return findByActive_PrevAndNext(licenseId, active, orderByComparator);
665 }
666
667 SCLicense scLicense = findByPrimaryKey(licenseId);
668
669 Session session = null;
670
671 try {
672 session = openSession();
673
674 SCLicense[] array = new SCLicenseImpl[3];
675
676 array[0] = filterGetByActive_PrevAndNext(session, scLicense,
677 active, orderByComparator, true);
678
679 array[1] = scLicense;
680
681 array[2] = filterGetByActive_PrevAndNext(session, scLicense,
682 active, orderByComparator, false);
683
684 return array;
685 }
686 catch (Exception e) {
687 throw processException(e);
688 }
689 finally {
690 closeSession(session);
691 }
692 }
693
694 protected SCLicense filterGetByActive_PrevAndNext(Session session,
695 SCLicense scLicense, boolean active,
696 OrderByComparator<SCLicense> orderByComparator, boolean previous) {
697 StringBundler query = null;
698
699 if (orderByComparator != null) {
700 query = new StringBundler(6 +
701 (orderByComparator.getOrderByFields().length * 6));
702 }
703 else {
704 query = new StringBundler(3);
705 }
706
707 if (getDB().isSupportsInlineDistinct()) {
708 query.append(_FILTER_SQL_SELECT_SCLICENSE_WHERE);
709 }
710 else {
711 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1);
712 }
713
714 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2_SQL);
715
716 if (!getDB().isSupportsInlineDistinct()) {
717 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2);
718 }
719
720 if (orderByComparator != null) {
721 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
722
723 if (orderByConditionFields.length > 0) {
724 query.append(WHERE_AND);
725 }
726
727 for (int i = 0; i < orderByConditionFields.length; i++) {
728 if (getDB().isSupportsInlineDistinct()) {
729 query.append(_ORDER_BY_ENTITY_ALIAS);
730 }
731 else {
732 query.append(_ORDER_BY_ENTITY_TABLE);
733 }
734
735 query.append(orderByConditionFields[i]);
736
737 if ((i + 1) < orderByConditionFields.length) {
738 if (orderByComparator.isAscending() ^ previous) {
739 query.append(WHERE_GREATER_THAN_HAS_NEXT);
740 }
741 else {
742 query.append(WHERE_LESSER_THAN_HAS_NEXT);
743 }
744 }
745 else {
746 if (orderByComparator.isAscending() ^ previous) {
747 query.append(WHERE_GREATER_THAN);
748 }
749 else {
750 query.append(WHERE_LESSER_THAN);
751 }
752 }
753 }
754
755 query.append(ORDER_BY_CLAUSE);
756
757 String[] orderByFields = orderByComparator.getOrderByFields();
758
759 for (int i = 0; i < orderByFields.length; i++) {
760 if (getDB().isSupportsInlineDistinct()) {
761 query.append(_ORDER_BY_ENTITY_ALIAS);
762 }
763 else {
764 query.append(_ORDER_BY_ENTITY_TABLE);
765 }
766
767 query.append(orderByFields[i]);
768
769 if ((i + 1) < orderByFields.length) {
770 if (orderByComparator.isAscending() ^ previous) {
771 query.append(ORDER_BY_ASC_HAS_NEXT);
772 }
773 else {
774 query.append(ORDER_BY_DESC_HAS_NEXT);
775 }
776 }
777 else {
778 if (orderByComparator.isAscending() ^ previous) {
779 query.append(ORDER_BY_ASC);
780 }
781 else {
782 query.append(ORDER_BY_DESC);
783 }
784 }
785 }
786 }
787 else {
788 if (getDB().isSupportsInlineDistinct()) {
789 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
790 }
791 else {
792 query.append(SCLicenseModelImpl.ORDER_BY_SQL);
793 }
794 }
795
796 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
797 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
798
799 SQLQuery q = session.createSynchronizedSQLQuery(sql);
800
801 q.setFirstResult(0);
802 q.setMaxResults(2);
803
804 if (getDB().isSupportsInlineDistinct()) {
805 q.addEntity(_FILTER_ENTITY_ALIAS, SCLicenseImpl.class);
806 }
807 else {
808 q.addEntity(_FILTER_ENTITY_TABLE, SCLicenseImpl.class);
809 }
810
811 QueryPos qPos = QueryPos.getInstance(q);
812
813 qPos.add(active);
814
815 if (orderByComparator != null) {
816 Object[] values = orderByComparator.getOrderByConditionValues(scLicense);
817
818 for (Object value : values) {
819 qPos.add(value);
820 }
821 }
822
823 List<SCLicense> list = q.list();
824
825 if (list.size() == 2) {
826 return list.get(1);
827 }
828 else {
829 return null;
830 }
831 }
832
833
838 @Override
839 public void removeByActive(boolean active) {
840 for (SCLicense scLicense : findByActive(active, QueryUtil.ALL_POS,
841 QueryUtil.ALL_POS, null)) {
842 remove(scLicense);
843 }
844 }
845
846
852 @Override
853 public int countByActive(boolean active) {
854 FinderPath finderPath = FINDER_PATH_COUNT_BY_ACTIVE;
855
856 Object[] finderArgs = new Object[] { active };
857
858 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
859
860 if (count == null) {
861 StringBundler query = new StringBundler(2);
862
863 query.append(_SQL_COUNT_SCLICENSE_WHERE);
864
865 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
866
867 String sql = query.toString();
868
869 Session session = null;
870
871 try {
872 session = openSession();
873
874 Query q = session.createQuery(sql);
875
876 QueryPos qPos = QueryPos.getInstance(q);
877
878 qPos.add(active);
879
880 count = (Long)q.uniqueResult();
881
882 finderCache.putResult(finderPath, finderArgs, count);
883 }
884 catch (Exception e) {
885 finderCache.removeResult(finderPath, finderArgs);
886
887 throw processException(e);
888 }
889 finally {
890 closeSession(session);
891 }
892 }
893
894 return count.intValue();
895 }
896
897
903 @Override
904 public int filterCountByActive(boolean active) {
905 if (!InlineSQLHelperUtil.isEnabled()) {
906 return countByActive(active);
907 }
908
909 StringBundler query = new StringBundler(2);
910
911 query.append(_FILTER_SQL_COUNT_SCLICENSE_WHERE);
912
913 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2_SQL);
914
915 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
916 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
917
918 Session session = null;
919
920 try {
921 session = openSession();
922
923 SQLQuery q = session.createSynchronizedSQLQuery(sql);
924
925 q.addScalar(COUNT_COLUMN_NAME,
926 com.liferay.portal.kernel.dao.orm.Type.LONG);
927
928 QueryPos qPos = QueryPos.getInstance(q);
929
930 qPos.add(active);
931
932 Long count = (Long)q.uniqueResult();
933
934 return count.intValue();
935 }
936 catch (Exception e) {
937 throw processException(e);
938 }
939 finally {
940 closeSession(session);
941 }
942 }
943
944 private static final String _FINDER_COLUMN_ACTIVE_ACTIVE_2 = "scLicense.active = ?";
945 private static final String _FINDER_COLUMN_ACTIVE_ACTIVE_2_SQL = "scLicense.active_ = ?";
946 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_A_R = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
947 SCLicenseModelImpl.FINDER_CACHE_ENABLED, SCLicenseImpl.class,
948 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByA_R",
949 new String[] {
950 Boolean.class.getName(), Boolean.class.getName(),
951
952 Integer.class.getName(), Integer.class.getName(),
953 OrderByComparator.class.getName()
954 });
955 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_A_R = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
956 SCLicenseModelImpl.FINDER_CACHE_ENABLED, SCLicenseImpl.class,
957 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByA_R",
958 new String[] { Boolean.class.getName(), Boolean.class.getName() },
959 SCLicenseModelImpl.ACTIVE_COLUMN_BITMASK |
960 SCLicenseModelImpl.RECOMMENDED_COLUMN_BITMASK |
961 SCLicenseModelImpl.NAME_COLUMN_BITMASK);
962 public static final FinderPath FINDER_PATH_COUNT_BY_A_R = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
963 SCLicenseModelImpl.FINDER_CACHE_ENABLED, Long.class,
964 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByA_R",
965 new String[] { Boolean.class.getName(), Boolean.class.getName() });
966
967
974 @Override
975 public List<SCLicense> findByA_R(boolean active, boolean recommended) {
976 return findByA_R(active, recommended, QueryUtil.ALL_POS,
977 QueryUtil.ALL_POS, null);
978 }
979
980
993 @Override
994 public List<SCLicense> findByA_R(boolean active, boolean recommended,
995 int start, int end) {
996 return findByA_R(active, recommended, start, end, null);
997 }
998
999
1013 @Override
1014 public List<SCLicense> findByA_R(boolean active, boolean recommended,
1015 int start, int end, OrderByComparator<SCLicense> orderByComparator) {
1016 return findByA_R(active, recommended, start, end, orderByComparator,
1017 true);
1018 }
1019
1020
1035 @Override
1036 public List<SCLicense> findByA_R(boolean active, boolean recommended,
1037 int start, int end, OrderByComparator<SCLicense> orderByComparator,
1038 boolean retrieveFromCache) {
1039 boolean pagination = true;
1040 FinderPath finderPath = null;
1041 Object[] finderArgs = null;
1042
1043 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1044 (orderByComparator == null)) {
1045 pagination = false;
1046 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_A_R;
1047 finderArgs = new Object[] { active, recommended };
1048 }
1049 else {
1050 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_A_R;
1051 finderArgs = new Object[] {
1052 active, recommended,
1053
1054 start, end, orderByComparator
1055 };
1056 }
1057
1058 List<SCLicense> list = null;
1059
1060 if (retrieveFromCache) {
1061 list = (List<SCLicense>)finderCache.getResult(finderPath,
1062 finderArgs, this);
1063
1064 if ((list != null) && !list.isEmpty()) {
1065 for (SCLicense scLicense : list) {
1066 if ((active != scLicense.getActive()) ||
1067 (recommended != scLicense.getRecommended())) {
1068 list = null;
1069
1070 break;
1071 }
1072 }
1073 }
1074 }
1075
1076 if (list == null) {
1077 StringBundler query = null;
1078
1079 if (orderByComparator != null) {
1080 query = new StringBundler(4 +
1081 (orderByComparator.getOrderByFields().length * 3));
1082 }
1083 else {
1084 query = new StringBundler(4);
1085 }
1086
1087 query.append(_SQL_SELECT_SCLICENSE_WHERE);
1088
1089 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1090
1091 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1092
1093 if (orderByComparator != null) {
1094 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1095 orderByComparator);
1096 }
1097 else
1098 if (pagination) {
1099 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1100 }
1101
1102 String sql = query.toString();
1103
1104 Session session = null;
1105
1106 try {
1107 session = openSession();
1108
1109 Query q = session.createQuery(sql);
1110
1111 QueryPos qPos = QueryPos.getInstance(q);
1112
1113 qPos.add(active);
1114
1115 qPos.add(recommended);
1116
1117 if (!pagination) {
1118 list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
1119 start, end, false);
1120
1121 Collections.sort(list);
1122
1123 list = Collections.unmodifiableList(list);
1124 }
1125 else {
1126 list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
1127 start, end);
1128 }
1129
1130 cacheResult(list);
1131
1132 finderCache.putResult(finderPath, finderArgs, list);
1133 }
1134 catch (Exception e) {
1135 finderCache.removeResult(finderPath, finderArgs);
1136
1137 throw processException(e);
1138 }
1139 finally {
1140 closeSession(session);
1141 }
1142 }
1143
1144 return list;
1145 }
1146
1147
1156 @Override
1157 public SCLicense findByA_R_First(boolean active, boolean recommended,
1158 OrderByComparator<SCLicense> orderByComparator)
1159 throws NoSuchLicenseException {
1160 SCLicense scLicense = fetchByA_R_First(active, recommended,
1161 orderByComparator);
1162
1163 if (scLicense != null) {
1164 return scLicense;
1165 }
1166
1167 StringBundler msg = new StringBundler(6);
1168
1169 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1170
1171 msg.append("active=");
1172 msg.append(active);
1173
1174 msg.append(", recommended=");
1175 msg.append(recommended);
1176
1177 msg.append(StringPool.CLOSE_CURLY_BRACE);
1178
1179 throw new NoSuchLicenseException(msg.toString());
1180 }
1181
1182
1190 @Override
1191 public SCLicense fetchByA_R_First(boolean active, boolean recommended,
1192 OrderByComparator<SCLicense> orderByComparator) {
1193 List<SCLicense> list = findByA_R(active, recommended, 0, 1,
1194 orderByComparator);
1195
1196 if (!list.isEmpty()) {
1197 return list.get(0);
1198 }
1199
1200 return null;
1201 }
1202
1203
1212 @Override
1213 public SCLicense findByA_R_Last(boolean active, boolean recommended,
1214 OrderByComparator<SCLicense> orderByComparator)
1215 throws NoSuchLicenseException {
1216 SCLicense scLicense = fetchByA_R_Last(active, recommended,
1217 orderByComparator);
1218
1219 if (scLicense != null) {
1220 return scLicense;
1221 }
1222
1223 StringBundler msg = new StringBundler(6);
1224
1225 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1226
1227 msg.append("active=");
1228 msg.append(active);
1229
1230 msg.append(", recommended=");
1231 msg.append(recommended);
1232
1233 msg.append(StringPool.CLOSE_CURLY_BRACE);
1234
1235 throw new NoSuchLicenseException(msg.toString());
1236 }
1237
1238
1246 @Override
1247 public SCLicense fetchByA_R_Last(boolean active, boolean recommended,
1248 OrderByComparator<SCLicense> orderByComparator) {
1249 int count = countByA_R(active, recommended);
1250
1251 if (count == 0) {
1252 return null;
1253 }
1254
1255 List<SCLicense> list = findByA_R(active, recommended, count - 1, count,
1256 orderByComparator);
1257
1258 if (!list.isEmpty()) {
1259 return list.get(0);
1260 }
1261
1262 return null;
1263 }
1264
1265
1275 @Override
1276 public SCLicense[] findByA_R_PrevAndNext(long licenseId, boolean active,
1277 boolean recommended, OrderByComparator<SCLicense> orderByComparator)
1278 throws NoSuchLicenseException {
1279 SCLicense scLicense = findByPrimaryKey(licenseId);
1280
1281 Session session = null;
1282
1283 try {
1284 session = openSession();
1285
1286 SCLicense[] array = new SCLicenseImpl[3];
1287
1288 array[0] = getByA_R_PrevAndNext(session, scLicense, active,
1289 recommended, orderByComparator, true);
1290
1291 array[1] = scLicense;
1292
1293 array[2] = getByA_R_PrevAndNext(session, scLicense, active,
1294 recommended, orderByComparator, false);
1295
1296 return array;
1297 }
1298 catch (Exception e) {
1299 throw processException(e);
1300 }
1301 finally {
1302 closeSession(session);
1303 }
1304 }
1305
1306 protected SCLicense getByA_R_PrevAndNext(Session session,
1307 SCLicense scLicense, boolean active, boolean recommended,
1308 OrderByComparator<SCLicense> orderByComparator, boolean previous) {
1309 StringBundler query = null;
1310
1311 if (orderByComparator != null) {
1312 query = new StringBundler(6 +
1313 (orderByComparator.getOrderByFields().length * 6));
1314 }
1315 else {
1316 query = new StringBundler(3);
1317 }
1318
1319 query.append(_SQL_SELECT_SCLICENSE_WHERE);
1320
1321 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1322
1323 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1324
1325 if (orderByComparator != null) {
1326 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1327
1328 if (orderByConditionFields.length > 0) {
1329 query.append(WHERE_AND);
1330 }
1331
1332 for (int i = 0; i < orderByConditionFields.length; i++) {
1333 query.append(_ORDER_BY_ENTITY_ALIAS);
1334 query.append(orderByConditionFields[i]);
1335
1336 if ((i + 1) < orderByConditionFields.length) {
1337 if (orderByComparator.isAscending() ^ previous) {
1338 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1339 }
1340 else {
1341 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1342 }
1343 }
1344 else {
1345 if (orderByComparator.isAscending() ^ previous) {
1346 query.append(WHERE_GREATER_THAN);
1347 }
1348 else {
1349 query.append(WHERE_LESSER_THAN);
1350 }
1351 }
1352 }
1353
1354 query.append(ORDER_BY_CLAUSE);
1355
1356 String[] orderByFields = orderByComparator.getOrderByFields();
1357
1358 for (int i = 0; i < orderByFields.length; i++) {
1359 query.append(_ORDER_BY_ENTITY_ALIAS);
1360 query.append(orderByFields[i]);
1361
1362 if ((i + 1) < orderByFields.length) {
1363 if (orderByComparator.isAscending() ^ previous) {
1364 query.append(ORDER_BY_ASC_HAS_NEXT);
1365 }
1366 else {
1367 query.append(ORDER_BY_DESC_HAS_NEXT);
1368 }
1369 }
1370 else {
1371 if (orderByComparator.isAscending() ^ previous) {
1372 query.append(ORDER_BY_ASC);
1373 }
1374 else {
1375 query.append(ORDER_BY_DESC);
1376 }
1377 }
1378 }
1379 }
1380 else {
1381 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1382 }
1383
1384 String sql = query.toString();
1385
1386 Query q = session.createQuery(sql);
1387
1388 q.setFirstResult(0);
1389 q.setMaxResults(2);
1390
1391 QueryPos qPos = QueryPos.getInstance(q);
1392
1393 qPos.add(active);
1394
1395 qPos.add(recommended);
1396
1397 if (orderByComparator != null) {
1398 Object[] values = orderByComparator.getOrderByConditionValues(scLicense);
1399
1400 for (Object value : values) {
1401 qPos.add(value);
1402 }
1403 }
1404
1405 List<SCLicense> list = q.list();
1406
1407 if (list.size() == 2) {
1408 return list.get(1);
1409 }
1410 else {
1411 return null;
1412 }
1413 }
1414
1415
1422 @Override
1423 public List<SCLicense> filterFindByA_R(boolean active, boolean recommended) {
1424 return filterFindByA_R(active, recommended, QueryUtil.ALL_POS,
1425 QueryUtil.ALL_POS, null);
1426 }
1427
1428
1441 @Override
1442 public List<SCLicense> filterFindByA_R(boolean active, boolean recommended,
1443 int start, int end) {
1444 return filterFindByA_R(active, recommended, start, end, null);
1445 }
1446
1447
1461 @Override
1462 public List<SCLicense> filterFindByA_R(boolean active, boolean recommended,
1463 int start, int end, OrderByComparator<SCLicense> orderByComparator) {
1464 if (!InlineSQLHelperUtil.isEnabled()) {
1465 return findByA_R(active, recommended, start, end, orderByComparator);
1466 }
1467
1468 StringBundler query = null;
1469
1470 if (orderByComparator != null) {
1471 query = new StringBundler(4 +
1472 (orderByComparator.getOrderByFields().length * 3));
1473 }
1474 else {
1475 query = new StringBundler(4);
1476 }
1477
1478 if (getDB().isSupportsInlineDistinct()) {
1479 query.append(_FILTER_SQL_SELECT_SCLICENSE_WHERE);
1480 }
1481 else {
1482 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1);
1483 }
1484
1485 query.append(_FINDER_COLUMN_A_R_ACTIVE_2_SQL);
1486
1487 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1488
1489 if (!getDB().isSupportsInlineDistinct()) {
1490 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2);
1491 }
1492
1493 if (orderByComparator != null) {
1494 if (getDB().isSupportsInlineDistinct()) {
1495 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1496 orderByComparator, true);
1497 }
1498 else {
1499 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1500 orderByComparator, true);
1501 }
1502 }
1503 else {
1504 if (getDB().isSupportsInlineDistinct()) {
1505 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1506 }
1507 else {
1508 query.append(SCLicenseModelImpl.ORDER_BY_SQL);
1509 }
1510 }
1511
1512 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1513 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1514
1515 Session session = null;
1516
1517 try {
1518 session = openSession();
1519
1520 SQLQuery q = session.createSynchronizedSQLQuery(sql);
1521
1522 if (getDB().isSupportsInlineDistinct()) {
1523 q.addEntity(_FILTER_ENTITY_ALIAS, SCLicenseImpl.class);
1524 }
1525 else {
1526 q.addEntity(_FILTER_ENTITY_TABLE, SCLicenseImpl.class);
1527 }
1528
1529 QueryPos qPos = QueryPos.getInstance(q);
1530
1531 qPos.add(active);
1532
1533 qPos.add(recommended);
1534
1535 return (List<SCLicense>)QueryUtil.list(q, getDialect(), start, end);
1536 }
1537 catch (Exception e) {
1538 throw processException(e);
1539 }
1540 finally {
1541 closeSession(session);
1542 }
1543 }
1544
1545
1555 @Override
1556 public SCLicense[] filterFindByA_R_PrevAndNext(long licenseId,
1557 boolean active, boolean recommended,
1558 OrderByComparator<SCLicense> orderByComparator)
1559 throws NoSuchLicenseException {
1560 if (!InlineSQLHelperUtil.isEnabled()) {
1561 return findByA_R_PrevAndNext(licenseId, active, recommended,
1562 orderByComparator);
1563 }
1564
1565 SCLicense scLicense = findByPrimaryKey(licenseId);
1566
1567 Session session = null;
1568
1569 try {
1570 session = openSession();
1571
1572 SCLicense[] array = new SCLicenseImpl[3];
1573
1574 array[0] = filterGetByA_R_PrevAndNext(session, scLicense, active,
1575 recommended, orderByComparator, true);
1576
1577 array[1] = scLicense;
1578
1579 array[2] = filterGetByA_R_PrevAndNext(session, scLicense, active,
1580 recommended, orderByComparator, false);
1581
1582 return array;
1583 }
1584 catch (Exception e) {
1585 throw processException(e);
1586 }
1587 finally {
1588 closeSession(session);
1589 }
1590 }
1591
1592 protected SCLicense filterGetByA_R_PrevAndNext(Session session,
1593 SCLicense scLicense, boolean active, boolean recommended,
1594 OrderByComparator<SCLicense> orderByComparator, boolean previous) {
1595 StringBundler query = null;
1596
1597 if (orderByComparator != null) {
1598 query = new StringBundler(6 +
1599 (orderByComparator.getOrderByFields().length * 6));
1600 }
1601 else {
1602 query = new StringBundler(3);
1603 }
1604
1605 if (getDB().isSupportsInlineDistinct()) {
1606 query.append(_FILTER_SQL_SELECT_SCLICENSE_WHERE);
1607 }
1608 else {
1609 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1);
1610 }
1611
1612 query.append(_FINDER_COLUMN_A_R_ACTIVE_2_SQL);
1613
1614 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1615
1616 if (!getDB().isSupportsInlineDistinct()) {
1617 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2);
1618 }
1619
1620 if (orderByComparator != null) {
1621 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1622
1623 if (orderByConditionFields.length > 0) {
1624 query.append(WHERE_AND);
1625 }
1626
1627 for (int i = 0; i < orderByConditionFields.length; i++) {
1628 if (getDB().isSupportsInlineDistinct()) {
1629 query.append(_ORDER_BY_ENTITY_ALIAS);
1630 }
1631 else {
1632 query.append(_ORDER_BY_ENTITY_TABLE);
1633 }
1634
1635 query.append(orderByConditionFields[i]);
1636
1637 if ((i + 1) < orderByConditionFields.length) {
1638 if (orderByComparator.isAscending() ^ previous) {
1639 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1640 }
1641 else {
1642 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1643 }
1644 }
1645 else {
1646 if (orderByComparator.isAscending() ^ previous) {
1647 query.append(WHERE_GREATER_THAN);
1648 }
1649 else {
1650 query.append(WHERE_LESSER_THAN);
1651 }
1652 }
1653 }
1654
1655 query.append(ORDER_BY_CLAUSE);
1656
1657 String[] orderByFields = orderByComparator.getOrderByFields();
1658
1659 for (int i = 0; i < orderByFields.length; i++) {
1660 if (getDB().isSupportsInlineDistinct()) {
1661 query.append(_ORDER_BY_ENTITY_ALIAS);
1662 }
1663 else {
1664 query.append(_ORDER_BY_ENTITY_TABLE);
1665 }
1666
1667 query.append(orderByFields[i]);
1668
1669 if ((i + 1) < orderByFields.length) {
1670 if (orderByComparator.isAscending() ^ previous) {
1671 query.append(ORDER_BY_ASC_HAS_NEXT);
1672 }
1673 else {
1674 query.append(ORDER_BY_DESC_HAS_NEXT);
1675 }
1676 }
1677 else {
1678 if (orderByComparator.isAscending() ^ previous) {
1679 query.append(ORDER_BY_ASC);
1680 }
1681 else {
1682 query.append(ORDER_BY_DESC);
1683 }
1684 }
1685 }
1686 }
1687 else {
1688 if (getDB().isSupportsInlineDistinct()) {
1689 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1690 }
1691 else {
1692 query.append(SCLicenseModelImpl.ORDER_BY_SQL);
1693 }
1694 }
1695
1696 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1697 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1698
1699 SQLQuery q = session.createSynchronizedSQLQuery(sql);
1700
1701 q.setFirstResult(0);
1702 q.setMaxResults(2);
1703
1704 if (getDB().isSupportsInlineDistinct()) {
1705 q.addEntity(_FILTER_ENTITY_ALIAS, SCLicenseImpl.class);
1706 }
1707 else {
1708 q.addEntity(_FILTER_ENTITY_TABLE, SCLicenseImpl.class);
1709 }
1710
1711 QueryPos qPos = QueryPos.getInstance(q);
1712
1713 qPos.add(active);
1714
1715 qPos.add(recommended);
1716
1717 if (orderByComparator != null) {
1718 Object[] values = orderByComparator.getOrderByConditionValues(scLicense);
1719
1720 for (Object value : values) {
1721 qPos.add(value);
1722 }
1723 }
1724
1725 List<SCLicense> list = q.list();
1726
1727 if (list.size() == 2) {
1728 return list.get(1);
1729 }
1730 else {
1731 return null;
1732 }
1733 }
1734
1735
1741 @Override
1742 public void removeByA_R(boolean active, boolean recommended) {
1743 for (SCLicense scLicense : findByA_R(active, recommended,
1744 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1745 remove(scLicense);
1746 }
1747 }
1748
1749
1756 @Override
1757 public int countByA_R(boolean active, boolean recommended) {
1758 FinderPath finderPath = FINDER_PATH_COUNT_BY_A_R;
1759
1760 Object[] finderArgs = new Object[] { active, recommended };
1761
1762 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1763
1764 if (count == null) {
1765 StringBundler query = new StringBundler(3);
1766
1767 query.append(_SQL_COUNT_SCLICENSE_WHERE);
1768
1769 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1770
1771 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1772
1773 String sql = query.toString();
1774
1775 Session session = null;
1776
1777 try {
1778 session = openSession();
1779
1780 Query q = session.createQuery(sql);
1781
1782 QueryPos qPos = QueryPos.getInstance(q);
1783
1784 qPos.add(active);
1785
1786 qPos.add(recommended);
1787
1788 count = (Long)q.uniqueResult();
1789
1790 finderCache.putResult(finderPath, finderArgs, count);
1791 }
1792 catch (Exception e) {
1793 finderCache.removeResult(finderPath, finderArgs);
1794
1795 throw processException(e);
1796 }
1797 finally {
1798 closeSession(session);
1799 }
1800 }
1801
1802 return count.intValue();
1803 }
1804
1805
1812 @Override
1813 public int filterCountByA_R(boolean active, boolean recommended) {
1814 if (!InlineSQLHelperUtil.isEnabled()) {
1815 return countByA_R(active, recommended);
1816 }
1817
1818 StringBundler query = new StringBundler(3);
1819
1820 query.append(_FILTER_SQL_COUNT_SCLICENSE_WHERE);
1821
1822 query.append(_FINDER_COLUMN_A_R_ACTIVE_2_SQL);
1823
1824 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1825
1826 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1827 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1828
1829 Session session = null;
1830
1831 try {
1832 session = openSession();
1833
1834 SQLQuery q = session.createSynchronizedSQLQuery(sql);
1835
1836 q.addScalar(COUNT_COLUMN_NAME,
1837 com.liferay.portal.kernel.dao.orm.Type.LONG);
1838
1839 QueryPos qPos = QueryPos.getInstance(q);
1840
1841 qPos.add(active);
1842
1843 qPos.add(recommended);
1844
1845 Long count = (Long)q.uniqueResult();
1846
1847 return count.intValue();
1848 }
1849 catch (Exception e) {
1850 throw processException(e);
1851 }
1852 finally {
1853 closeSession(session);
1854 }
1855 }
1856
1857 private static final String _FINDER_COLUMN_A_R_ACTIVE_2 = "scLicense.active = ? AND ";
1858 private static final String _FINDER_COLUMN_A_R_ACTIVE_2_SQL = "scLicense.active_ = ? AND ";
1859 private static final String _FINDER_COLUMN_A_R_RECOMMENDED_2 = "scLicense.recommended = ?";
1860
1861 public SCLicensePersistenceImpl() {
1862 setModelClass(SCLicense.class);
1863 }
1864
1865
1870 @Override
1871 public void cacheResult(SCLicense scLicense) {
1872 entityCache.putResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
1873 SCLicenseImpl.class, scLicense.getPrimaryKey(), scLicense);
1874
1875 scLicense.resetOriginalValues();
1876 }
1877
1878
1883 @Override
1884 public void cacheResult(List<SCLicense> scLicenses) {
1885 for (SCLicense scLicense : scLicenses) {
1886 if (entityCache.getResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
1887 SCLicenseImpl.class, scLicense.getPrimaryKey()) == null) {
1888 cacheResult(scLicense);
1889 }
1890 else {
1891 scLicense.resetOriginalValues();
1892 }
1893 }
1894 }
1895
1896
1903 @Override
1904 public void clearCache() {
1905 entityCache.clearCache(SCLicenseImpl.class);
1906
1907 finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
1908 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1909 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1910 }
1911
1912
1919 @Override
1920 public void clearCache(SCLicense scLicense) {
1921 entityCache.removeResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
1922 SCLicenseImpl.class, scLicense.getPrimaryKey());
1923
1924 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1925 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1926 }
1927
1928 @Override
1929 public void clearCache(List<SCLicense> scLicenses) {
1930 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1931 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1932
1933 for (SCLicense scLicense : scLicenses) {
1934 entityCache.removeResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
1935 SCLicenseImpl.class, scLicense.getPrimaryKey());
1936 }
1937 }
1938
1939
1945 @Override
1946 public SCLicense create(long licenseId) {
1947 SCLicense scLicense = new SCLicenseImpl();
1948
1949 scLicense.setNew(true);
1950 scLicense.setPrimaryKey(licenseId);
1951
1952 return scLicense;
1953 }
1954
1955
1962 @Override
1963 public SCLicense remove(long licenseId) throws NoSuchLicenseException {
1964 return remove((Serializable)licenseId);
1965 }
1966
1967
1974 @Override
1975 public SCLicense remove(Serializable primaryKey)
1976 throws NoSuchLicenseException {
1977 Session session = null;
1978
1979 try {
1980 session = openSession();
1981
1982 SCLicense scLicense = (SCLicense)session.get(SCLicenseImpl.class,
1983 primaryKey);
1984
1985 if (scLicense == null) {
1986 if (_log.isWarnEnabled()) {
1987 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
1988 }
1989
1990 throw new NoSuchLicenseException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1991 primaryKey);
1992 }
1993
1994 return remove(scLicense);
1995 }
1996 catch (NoSuchLicenseException nsee) {
1997 throw nsee;
1998 }
1999 catch (Exception e) {
2000 throw processException(e);
2001 }
2002 finally {
2003 closeSession(session);
2004 }
2005 }
2006
2007 @Override
2008 protected SCLicense removeImpl(SCLicense scLicense) {
2009 scLicense = toUnwrappedModel(scLicense);
2010
2011 scLicenseToSCProductEntryTableMapper.deleteLeftPrimaryKeyTableMappings(0,
2012 scLicense.getPrimaryKey());
2013
2014 Session session = null;
2015
2016 try {
2017 session = openSession();
2018
2019 if (!session.contains(scLicense)) {
2020 scLicense = (SCLicense)session.get(SCLicenseImpl.class,
2021 scLicense.getPrimaryKeyObj());
2022 }
2023
2024 if (scLicense != null) {
2025 session.delete(scLicense);
2026 }
2027 }
2028 catch (Exception e) {
2029 throw processException(e);
2030 }
2031 finally {
2032 closeSession(session);
2033 }
2034
2035 if (scLicense != null) {
2036 clearCache(scLicense);
2037 }
2038
2039 return scLicense;
2040 }
2041
2042 @Override
2043 public SCLicense updateImpl(SCLicense scLicense) {
2044 scLicense = toUnwrappedModel(scLicense);
2045
2046 boolean isNew = scLicense.isNew();
2047
2048 SCLicenseModelImpl scLicenseModelImpl = (SCLicenseModelImpl)scLicense;
2049
2050 Session session = null;
2051
2052 try {
2053 session = openSession();
2054
2055 if (scLicense.isNew()) {
2056 session.save(scLicense);
2057
2058 scLicense.setNew(false);
2059 }
2060 else {
2061 scLicense = (SCLicense)session.merge(scLicense);
2062 }
2063 }
2064 catch (Exception e) {
2065 throw processException(e);
2066 }
2067 finally {
2068 closeSession(session);
2069 }
2070
2071 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2072
2073 if (isNew || !SCLicenseModelImpl.COLUMN_BITMASK_ENABLED) {
2074 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2075 }
2076
2077 else {
2078 if ((scLicenseModelImpl.getColumnBitmask() &
2079 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE.getColumnBitmask()) != 0) {
2080 Object[] args = new Object[] {
2081 scLicenseModelImpl.getOriginalActive()
2082 };
2083
2084 finderCache.removeResult(FINDER_PATH_COUNT_BY_ACTIVE, args);
2085 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE,
2086 args);
2087
2088 args = new Object[] { scLicenseModelImpl.getActive() };
2089
2090 finderCache.removeResult(FINDER_PATH_COUNT_BY_ACTIVE, args);
2091 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE,
2092 args);
2093 }
2094
2095 if ((scLicenseModelImpl.getColumnBitmask() &
2096 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_A_R.getColumnBitmask()) != 0) {
2097 Object[] args = new Object[] {
2098 scLicenseModelImpl.getOriginalActive(),
2099 scLicenseModelImpl.getOriginalRecommended()
2100 };
2101
2102 finderCache.removeResult(FINDER_PATH_COUNT_BY_A_R, args);
2103 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_A_R,
2104 args);
2105
2106 args = new Object[] {
2107 scLicenseModelImpl.getActive(),
2108 scLicenseModelImpl.getRecommended()
2109 };
2110
2111 finderCache.removeResult(FINDER_PATH_COUNT_BY_A_R, args);
2112 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_A_R,
2113 args);
2114 }
2115 }
2116
2117 entityCache.putResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
2118 SCLicenseImpl.class, scLicense.getPrimaryKey(), scLicense, false);
2119
2120 scLicense.resetOriginalValues();
2121
2122 return scLicense;
2123 }
2124
2125 protected SCLicense toUnwrappedModel(SCLicense scLicense) {
2126 if (scLicense instanceof SCLicenseImpl) {
2127 return scLicense;
2128 }
2129
2130 SCLicenseImpl scLicenseImpl = new SCLicenseImpl();
2131
2132 scLicenseImpl.setNew(scLicense.isNew());
2133 scLicenseImpl.setPrimaryKey(scLicense.getPrimaryKey());
2134
2135 scLicenseImpl.setLicenseId(scLicense.getLicenseId());
2136 scLicenseImpl.setName(scLicense.getName());
2137 scLicenseImpl.setUrl(scLicense.getUrl());
2138 scLicenseImpl.setOpenSource(scLicense.isOpenSource());
2139 scLicenseImpl.setActive(scLicense.isActive());
2140 scLicenseImpl.setRecommended(scLicense.isRecommended());
2141
2142 return scLicenseImpl;
2143 }
2144
2145
2152 @Override
2153 public SCLicense findByPrimaryKey(Serializable primaryKey)
2154 throws NoSuchLicenseException {
2155 SCLicense scLicense = fetchByPrimaryKey(primaryKey);
2156
2157 if (scLicense == null) {
2158 if (_log.isWarnEnabled()) {
2159 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2160 }
2161
2162 throw new NoSuchLicenseException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2163 primaryKey);
2164 }
2165
2166 return scLicense;
2167 }
2168
2169
2176 @Override
2177 public SCLicense findByPrimaryKey(long licenseId)
2178 throws NoSuchLicenseException {
2179 return findByPrimaryKey((Serializable)licenseId);
2180 }
2181
2182
2188 @Override
2189 public SCLicense fetchByPrimaryKey(Serializable primaryKey) {
2190 SCLicense scLicense = (SCLicense)entityCache.getResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
2191 SCLicenseImpl.class, primaryKey);
2192
2193 if (scLicense == _nullSCLicense) {
2194 return null;
2195 }
2196
2197 if (scLicense == null) {
2198 Session session = null;
2199
2200 try {
2201 session = openSession();
2202
2203 scLicense = (SCLicense)session.get(SCLicenseImpl.class,
2204 primaryKey);
2205
2206 if (scLicense != null) {
2207 cacheResult(scLicense);
2208 }
2209 else {
2210 entityCache.putResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
2211 SCLicenseImpl.class, primaryKey, _nullSCLicense);
2212 }
2213 }
2214 catch (Exception e) {
2215 entityCache.removeResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
2216 SCLicenseImpl.class, primaryKey);
2217
2218 throw processException(e);
2219 }
2220 finally {
2221 closeSession(session);
2222 }
2223 }
2224
2225 return scLicense;
2226 }
2227
2228
2234 @Override
2235 public SCLicense fetchByPrimaryKey(long licenseId) {
2236 return fetchByPrimaryKey((Serializable)licenseId);
2237 }
2238
2239 @Override
2240 public Map<Serializable, SCLicense> fetchByPrimaryKeys(
2241 Set<Serializable> primaryKeys) {
2242 if (primaryKeys.isEmpty()) {
2243 return Collections.emptyMap();
2244 }
2245
2246 Map<Serializable, SCLicense> map = new HashMap<Serializable, SCLicense>();
2247
2248 if (primaryKeys.size() == 1) {
2249 Iterator<Serializable> iterator = primaryKeys.iterator();
2250
2251 Serializable primaryKey = iterator.next();
2252
2253 SCLicense scLicense = fetchByPrimaryKey(primaryKey);
2254
2255 if (scLicense != null) {
2256 map.put(primaryKey, scLicense);
2257 }
2258
2259 return map;
2260 }
2261
2262 Set<Serializable> uncachedPrimaryKeys = null;
2263
2264 for (Serializable primaryKey : primaryKeys) {
2265 SCLicense scLicense = (SCLicense)entityCache.getResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
2266 SCLicenseImpl.class, primaryKey);
2267
2268 if (scLicense == null) {
2269 if (uncachedPrimaryKeys == null) {
2270 uncachedPrimaryKeys = new HashSet<Serializable>();
2271 }
2272
2273 uncachedPrimaryKeys.add(primaryKey);
2274 }
2275 else {
2276 map.put(primaryKey, scLicense);
2277 }
2278 }
2279
2280 if (uncachedPrimaryKeys == null) {
2281 return map;
2282 }
2283
2284 StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
2285 1);
2286
2287 query.append(_SQL_SELECT_SCLICENSE_WHERE_PKS_IN);
2288
2289 for (Serializable primaryKey : uncachedPrimaryKeys) {
2290 query.append(String.valueOf(primaryKey));
2291
2292 query.append(StringPool.COMMA);
2293 }
2294
2295 query.setIndex(query.index() - 1);
2296
2297 query.append(StringPool.CLOSE_PARENTHESIS);
2298
2299 String sql = query.toString();
2300
2301 Session session = null;
2302
2303 try {
2304 session = openSession();
2305
2306 Query q = session.createQuery(sql);
2307
2308 for (SCLicense scLicense : (List<SCLicense>)q.list()) {
2309 map.put(scLicense.getPrimaryKeyObj(), scLicense);
2310
2311 cacheResult(scLicense);
2312
2313 uncachedPrimaryKeys.remove(scLicense.getPrimaryKeyObj());
2314 }
2315
2316 for (Serializable primaryKey : uncachedPrimaryKeys) {
2317 entityCache.putResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
2318 SCLicenseImpl.class, primaryKey, _nullSCLicense);
2319 }
2320 }
2321 catch (Exception e) {
2322 throw processException(e);
2323 }
2324 finally {
2325 closeSession(session);
2326 }
2327
2328 return map;
2329 }
2330
2331
2336 @Override
2337 public List<SCLicense> findAll() {
2338 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2339 }
2340
2341
2352 @Override
2353 public List<SCLicense> findAll(int start, int end) {
2354 return findAll(start, end, null);
2355 }
2356
2357
2369 @Override
2370 public List<SCLicense> findAll(int start, int end,
2371 OrderByComparator<SCLicense> orderByComparator) {
2372 return findAll(start, end, orderByComparator, true);
2373 }
2374
2375
2388 @Override
2389 public List<SCLicense> findAll(int start, int end,
2390 OrderByComparator<SCLicense> orderByComparator,
2391 boolean retrieveFromCache) {
2392 boolean pagination = true;
2393 FinderPath finderPath = null;
2394 Object[] finderArgs = null;
2395
2396 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2397 (orderByComparator == null)) {
2398 pagination = false;
2399 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2400 finderArgs = FINDER_ARGS_EMPTY;
2401 }
2402 else {
2403 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2404 finderArgs = new Object[] { start, end, orderByComparator };
2405 }
2406
2407 List<SCLicense> list = null;
2408
2409 if (retrieveFromCache) {
2410 list = (List<SCLicense>)finderCache.getResult(finderPath,
2411 finderArgs, this);
2412 }
2413
2414 if (list == null) {
2415 StringBundler query = null;
2416 String sql = null;
2417
2418 if (orderByComparator != null) {
2419 query = new StringBundler(2 +
2420 (orderByComparator.getOrderByFields().length * 3));
2421
2422 query.append(_SQL_SELECT_SCLICENSE);
2423
2424 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2425 orderByComparator);
2426
2427 sql = query.toString();
2428 }
2429 else {
2430 sql = _SQL_SELECT_SCLICENSE;
2431
2432 if (pagination) {
2433 sql = sql.concat(SCLicenseModelImpl.ORDER_BY_JPQL);
2434 }
2435 }
2436
2437 Session session = null;
2438
2439 try {
2440 session = openSession();
2441
2442 Query q = session.createQuery(sql);
2443
2444 if (!pagination) {
2445 list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
2446 start, end, false);
2447
2448 Collections.sort(list);
2449
2450 list = Collections.unmodifiableList(list);
2451 }
2452 else {
2453 list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
2454 start, end);
2455 }
2456
2457 cacheResult(list);
2458
2459 finderCache.putResult(finderPath, finderArgs, list);
2460 }
2461 catch (Exception e) {
2462 finderCache.removeResult(finderPath, finderArgs);
2463
2464 throw processException(e);
2465 }
2466 finally {
2467 closeSession(session);
2468 }
2469 }
2470
2471 return list;
2472 }
2473
2474
2478 @Override
2479 public void removeAll() {
2480 for (SCLicense scLicense : findAll()) {
2481 remove(scLicense);
2482 }
2483 }
2484
2485
2490 @Override
2491 public int countAll() {
2492 Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
2493 FINDER_ARGS_EMPTY, this);
2494
2495 if (count == null) {
2496 Session session = null;
2497
2498 try {
2499 session = openSession();
2500
2501 Query q = session.createQuery(_SQL_COUNT_SCLICENSE);
2502
2503 count = (Long)q.uniqueResult();
2504
2505 finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
2506 count);
2507 }
2508 catch (Exception e) {
2509 finderCache.removeResult(FINDER_PATH_COUNT_ALL,
2510 FINDER_ARGS_EMPTY);
2511
2512 throw processException(e);
2513 }
2514 finally {
2515 closeSession(session);
2516 }
2517 }
2518
2519 return count.intValue();
2520 }
2521
2522
2528 @Override
2529 public long[] getSCProductEntryPrimaryKeys(long pk) {
2530 long[] pks = scLicenseToSCProductEntryTableMapper.getRightPrimaryKeys(0,
2531 pk);
2532
2533 return pks.clone();
2534 }
2535
2536
2542 @Override
2543 public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
2544 long pk) {
2545 return getSCProductEntries(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2546 }
2547
2548
2560 @Override
2561 public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
2562 long pk, int start, int end) {
2563 return getSCProductEntries(pk, start, end, null);
2564 }
2565
2566
2579 @Override
2580 public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
2581 long pk, int start, int end,
2582 OrderByComparator<com.liferay.portlet.softwarecatalog.model.SCProductEntry> orderByComparator) {
2583 return scLicenseToSCProductEntryTableMapper.getRightBaseModels(0, pk,
2584 start, end, orderByComparator);
2585 }
2586
2587
2593 @Override
2594 public int getSCProductEntriesSize(long pk) {
2595 long[] pks = scLicenseToSCProductEntryTableMapper.getRightPrimaryKeys(0,
2596 pk);
2597
2598 return pks.length;
2599 }
2600
2601
2608 @Override
2609 public boolean containsSCProductEntry(long pk, long scProductEntryPK) {
2610 return scLicenseToSCProductEntryTableMapper.containsTableMapping(0, pk,
2611 scProductEntryPK);
2612 }
2613
2614
2620 @Override
2621 public boolean containsSCProductEntries(long pk) {
2622 if (getSCProductEntriesSize(pk) > 0) {
2623 return true;
2624 }
2625 else {
2626 return false;
2627 }
2628 }
2629
2630
2636 @Override
2637 public void addSCProductEntry(long pk, long scProductEntryPK) {
2638 scLicenseToSCProductEntryTableMapper.addTableMapping(0, pk,
2639 scProductEntryPK);
2640 }
2641
2642
2648 @Override
2649 public void addSCProductEntry(long pk,
2650 com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry) {
2651 scLicenseToSCProductEntryTableMapper.addTableMapping(0, pk,
2652 scProductEntry.getPrimaryKey());
2653 }
2654
2655
2661 @Override
2662 public void addSCProductEntries(long pk, long[] scProductEntryPKs) {
2663 for (long scProductEntryPK : scProductEntryPKs) {
2664 scLicenseToSCProductEntryTableMapper.addTableMapping(0, pk,
2665 scProductEntryPK);
2666 }
2667 }
2668
2669
2675 @Override
2676 public void addSCProductEntries(long pk,
2677 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries) {
2678 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2679 scLicenseToSCProductEntryTableMapper.addTableMapping(0, pk,
2680 scProductEntry.getPrimaryKey());
2681 }
2682 }
2683
2684
2689 @Override
2690 public void clearSCProductEntries(long pk) {
2691 scLicenseToSCProductEntryTableMapper.deleteLeftPrimaryKeyTableMappings(0,
2692 pk);
2693 }
2694
2695
2701 @Override
2702 public void removeSCProductEntry(long pk, long scProductEntryPK) {
2703 scLicenseToSCProductEntryTableMapper.deleteTableMapping(0, pk,
2704 scProductEntryPK);
2705 }
2706
2707
2713 @Override
2714 public void removeSCProductEntry(long pk,
2715 com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry) {
2716 scLicenseToSCProductEntryTableMapper.deleteTableMapping(0, pk,
2717 scProductEntry.getPrimaryKey());
2718 }
2719
2720
2726 @Override
2727 public void removeSCProductEntries(long pk, long[] scProductEntryPKs) {
2728 for (long scProductEntryPK : scProductEntryPKs) {
2729 scLicenseToSCProductEntryTableMapper.deleteTableMapping(0, pk,
2730 scProductEntryPK);
2731 }
2732 }
2733
2734
2740 @Override
2741 public void removeSCProductEntries(long pk,
2742 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries) {
2743 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2744 scLicenseToSCProductEntryTableMapper.deleteTableMapping(0, pk,
2745 scProductEntry.getPrimaryKey());
2746 }
2747 }
2748
2749
2755 @Override
2756 public void setSCProductEntries(long pk, long[] scProductEntryPKs) {
2757 Set<Long> newSCProductEntryPKsSet = SetUtil.fromArray(scProductEntryPKs);
2758 Set<Long> oldSCProductEntryPKsSet = SetUtil.fromArray(scLicenseToSCProductEntryTableMapper.getRightPrimaryKeys(
2759 0, pk));
2760
2761 Set<Long> removeSCProductEntryPKsSet = new HashSet<Long>(oldSCProductEntryPKsSet);
2762
2763 removeSCProductEntryPKsSet.removeAll(newSCProductEntryPKsSet);
2764
2765 for (long removeSCProductEntryPK : removeSCProductEntryPKsSet) {
2766 scLicenseToSCProductEntryTableMapper.deleteTableMapping(0, pk,
2767 removeSCProductEntryPK);
2768 }
2769
2770 newSCProductEntryPKsSet.removeAll(oldSCProductEntryPKsSet);
2771
2772 for (long newSCProductEntryPK : newSCProductEntryPKsSet) {
2773 scLicenseToSCProductEntryTableMapper.addTableMapping(0, pk,
2774 newSCProductEntryPK);
2775 }
2776 }
2777
2778
2784 @Override
2785 public void setSCProductEntries(long pk,
2786 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries) {
2787 try {
2788 long[] scProductEntryPKs = new long[scProductEntries.size()];
2789
2790 for (int i = 0; i < scProductEntries.size(); i++) {
2791 com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry =
2792 scProductEntries.get(i);
2793
2794 scProductEntryPKs[i] = scProductEntry.getPrimaryKey();
2795 }
2796
2797 setSCProductEntries(pk, scProductEntryPKs);
2798 }
2799 catch (Exception e) {
2800 throw processException(e);
2801 }
2802 }
2803
2804 @Override
2805 public Set<String> getBadColumnNames() {
2806 return _badColumnNames;
2807 }
2808
2809 @Override
2810 protected Map<String, Integer> getTableColumnsMap() {
2811 return SCLicenseModelImpl.TABLE_COLUMNS_MAP;
2812 }
2813
2814
2817 public void afterPropertiesSet() {
2818 scLicenseToSCProductEntryTableMapper = TableMapperFactory.getTableMapper("SCLicenses_SCProductEntries",
2819 "companyId", "licenseId", "productEntryId", this,
2820 scProductEntryPersistence);
2821 }
2822
2823 public void destroy() {
2824 entityCache.removeCache(SCLicenseImpl.class.getName());
2825 finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
2826 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2827 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2828
2829 TableMapperFactory.removeTableMapper("SCLicenses_SCProductEntries");
2830 }
2831
2832 protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
2833 protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
2834 @BeanReference(type = SCProductEntryPersistence.class)
2835 protected SCProductEntryPersistence scProductEntryPersistence;
2836 protected TableMapper<SCLicense, com.liferay.portlet.softwarecatalog.model.SCProductEntry> scLicenseToSCProductEntryTableMapper;
2837 private static final String _SQL_SELECT_SCLICENSE = "SELECT scLicense FROM SCLicense scLicense";
2838 private static final String _SQL_SELECT_SCLICENSE_WHERE_PKS_IN = "SELECT scLicense FROM SCLicense scLicense WHERE licenseId IN (";
2839 private static final String _SQL_SELECT_SCLICENSE_WHERE = "SELECT scLicense FROM SCLicense scLicense WHERE ";
2840 private static final String _SQL_COUNT_SCLICENSE = "SELECT COUNT(scLicense) FROM SCLicense scLicense";
2841 private static final String _SQL_COUNT_SCLICENSE_WHERE = "SELECT COUNT(scLicense) FROM SCLicense scLicense WHERE ";
2842 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "scLicense.licenseId";
2843 private static final String _FILTER_SQL_SELECT_SCLICENSE_WHERE = "SELECT DISTINCT {scLicense.*} FROM SCLicense scLicense WHERE ";
2844 private static final String _FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1 =
2845 "SELECT {SCLicense.*} FROM (SELECT DISTINCT scLicense.licenseId FROM SCLicense scLicense WHERE ";
2846 private static final String _FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2 =
2847 ") TEMP_TABLE INNER JOIN SCLicense ON TEMP_TABLE.licenseId = SCLicense.licenseId";
2848 private static final String _FILTER_SQL_COUNT_SCLICENSE_WHERE = "SELECT COUNT(DISTINCT scLicense.licenseId) AS COUNT_VALUE FROM SCLicense scLicense WHERE ";
2849 private static final String _FILTER_ENTITY_ALIAS = "scLicense";
2850 private static final String _FILTER_ENTITY_TABLE = "SCLicense";
2851 private static final String _ORDER_BY_ENTITY_ALIAS = "scLicense.";
2852 private static final String _ORDER_BY_ENTITY_TABLE = "SCLicense.";
2853 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SCLicense exists with the primary key ";
2854 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SCLicense exists with the key {";
2855 private static final Log _log = LogFactoryUtil.getLog(SCLicensePersistenceImpl.class);
2856 private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
2857 "active"
2858 });
2859 private static final SCLicense _nullSCLicense = new SCLicenseImpl() {
2860 @Override
2861 public Object clone() {
2862 return this;
2863 }
2864
2865 @Override
2866 public CacheModel<SCLicense> toCacheModel() {
2867 return _nullSCLicenseCacheModel;
2868 }
2869 };
2870
2871 private static final CacheModel<SCLicense> _nullSCLicenseCacheModel = new CacheModel<SCLicense>() {
2872 @Override
2873 public SCLicense toEntityModel() {
2874 return _nullSCLicense;
2875 }
2876 };
2877 }