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.setCompanyId(scLicense.getCompanyId());
2137 scLicenseImpl.setName(scLicense.getName());
2138 scLicenseImpl.setUrl(scLicense.getUrl());
2139 scLicenseImpl.setOpenSource(scLicense.isOpenSource());
2140 scLicenseImpl.setActive(scLicense.isActive());
2141 scLicenseImpl.setRecommended(scLicense.isRecommended());
2142
2143 return scLicenseImpl;
2144 }
2145
2146
2153 @Override
2154 public SCLicense findByPrimaryKey(Serializable primaryKey)
2155 throws NoSuchLicenseException {
2156 SCLicense scLicense = fetchByPrimaryKey(primaryKey);
2157
2158 if (scLicense == null) {
2159 if (_log.isWarnEnabled()) {
2160 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2161 }
2162
2163 throw new NoSuchLicenseException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2164 primaryKey);
2165 }
2166
2167 return scLicense;
2168 }
2169
2170
2177 @Override
2178 public SCLicense findByPrimaryKey(long licenseId)
2179 throws NoSuchLicenseException {
2180 return findByPrimaryKey((Serializable)licenseId);
2181 }
2182
2183
2189 @Override
2190 public SCLicense fetchByPrimaryKey(Serializable primaryKey) {
2191 SCLicense scLicense = (SCLicense)entityCache.getResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
2192 SCLicenseImpl.class, primaryKey);
2193
2194 if (scLicense == _nullSCLicense) {
2195 return null;
2196 }
2197
2198 if (scLicense == null) {
2199 Session session = null;
2200
2201 try {
2202 session = openSession();
2203
2204 scLicense = (SCLicense)session.get(SCLicenseImpl.class,
2205 primaryKey);
2206
2207 if (scLicense != null) {
2208 cacheResult(scLicense);
2209 }
2210 else {
2211 entityCache.putResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
2212 SCLicenseImpl.class, primaryKey, _nullSCLicense);
2213 }
2214 }
2215 catch (Exception e) {
2216 entityCache.removeResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
2217 SCLicenseImpl.class, primaryKey);
2218
2219 throw processException(e);
2220 }
2221 finally {
2222 closeSession(session);
2223 }
2224 }
2225
2226 return scLicense;
2227 }
2228
2229
2235 @Override
2236 public SCLicense fetchByPrimaryKey(long licenseId) {
2237 return fetchByPrimaryKey((Serializable)licenseId);
2238 }
2239
2240 @Override
2241 public Map<Serializable, SCLicense> fetchByPrimaryKeys(
2242 Set<Serializable> primaryKeys) {
2243 if (primaryKeys.isEmpty()) {
2244 return Collections.emptyMap();
2245 }
2246
2247 Map<Serializable, SCLicense> map = new HashMap<Serializable, SCLicense>();
2248
2249 if (primaryKeys.size() == 1) {
2250 Iterator<Serializable> iterator = primaryKeys.iterator();
2251
2252 Serializable primaryKey = iterator.next();
2253
2254 SCLicense scLicense = fetchByPrimaryKey(primaryKey);
2255
2256 if (scLicense != null) {
2257 map.put(primaryKey, scLicense);
2258 }
2259
2260 return map;
2261 }
2262
2263 Set<Serializable> uncachedPrimaryKeys = null;
2264
2265 for (Serializable primaryKey : primaryKeys) {
2266 SCLicense scLicense = (SCLicense)entityCache.getResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
2267 SCLicenseImpl.class, primaryKey);
2268
2269 if (scLicense == null) {
2270 if (uncachedPrimaryKeys == null) {
2271 uncachedPrimaryKeys = new HashSet<Serializable>();
2272 }
2273
2274 uncachedPrimaryKeys.add(primaryKey);
2275 }
2276 else {
2277 map.put(primaryKey, scLicense);
2278 }
2279 }
2280
2281 if (uncachedPrimaryKeys == null) {
2282 return map;
2283 }
2284
2285 StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
2286 1);
2287
2288 query.append(_SQL_SELECT_SCLICENSE_WHERE_PKS_IN);
2289
2290 for (Serializable primaryKey : uncachedPrimaryKeys) {
2291 query.append(String.valueOf(primaryKey));
2292
2293 query.append(StringPool.COMMA);
2294 }
2295
2296 query.setIndex(query.index() - 1);
2297
2298 query.append(StringPool.CLOSE_PARENTHESIS);
2299
2300 String sql = query.toString();
2301
2302 Session session = null;
2303
2304 try {
2305 session = openSession();
2306
2307 Query q = session.createQuery(sql);
2308
2309 for (SCLicense scLicense : (List<SCLicense>)q.list()) {
2310 map.put(scLicense.getPrimaryKeyObj(), scLicense);
2311
2312 cacheResult(scLicense);
2313
2314 uncachedPrimaryKeys.remove(scLicense.getPrimaryKeyObj());
2315 }
2316
2317 for (Serializable primaryKey : uncachedPrimaryKeys) {
2318 entityCache.putResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
2319 SCLicenseImpl.class, primaryKey, _nullSCLicense);
2320 }
2321 }
2322 catch (Exception e) {
2323 throw processException(e);
2324 }
2325 finally {
2326 closeSession(session);
2327 }
2328
2329 return map;
2330 }
2331
2332
2337 @Override
2338 public List<SCLicense> findAll() {
2339 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2340 }
2341
2342
2353 @Override
2354 public List<SCLicense> findAll(int start, int end) {
2355 return findAll(start, end, null);
2356 }
2357
2358
2370 @Override
2371 public List<SCLicense> findAll(int start, int end,
2372 OrderByComparator<SCLicense> orderByComparator) {
2373 return findAll(start, end, orderByComparator, true);
2374 }
2375
2376
2389 @Override
2390 public List<SCLicense> findAll(int start, int end,
2391 OrderByComparator<SCLicense> orderByComparator,
2392 boolean retrieveFromCache) {
2393 boolean pagination = true;
2394 FinderPath finderPath = null;
2395 Object[] finderArgs = null;
2396
2397 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2398 (orderByComparator == null)) {
2399 pagination = false;
2400 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2401 finderArgs = FINDER_ARGS_EMPTY;
2402 }
2403 else {
2404 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2405 finderArgs = new Object[] { start, end, orderByComparator };
2406 }
2407
2408 List<SCLicense> list = null;
2409
2410 if (retrieveFromCache) {
2411 list = (List<SCLicense>)finderCache.getResult(finderPath,
2412 finderArgs, this);
2413 }
2414
2415 if (list == null) {
2416 StringBundler query = null;
2417 String sql = null;
2418
2419 if (orderByComparator != null) {
2420 query = new StringBundler(2 +
2421 (orderByComparator.getOrderByFields().length * 3));
2422
2423 query.append(_SQL_SELECT_SCLICENSE);
2424
2425 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2426 orderByComparator);
2427
2428 sql = query.toString();
2429 }
2430 else {
2431 sql = _SQL_SELECT_SCLICENSE;
2432
2433 if (pagination) {
2434 sql = sql.concat(SCLicenseModelImpl.ORDER_BY_JPQL);
2435 }
2436 }
2437
2438 Session session = null;
2439
2440 try {
2441 session = openSession();
2442
2443 Query q = session.createQuery(sql);
2444
2445 if (!pagination) {
2446 list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
2447 start, end, false);
2448
2449 Collections.sort(list);
2450
2451 list = Collections.unmodifiableList(list);
2452 }
2453 else {
2454 list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
2455 start, end);
2456 }
2457
2458 cacheResult(list);
2459
2460 finderCache.putResult(finderPath, finderArgs, list);
2461 }
2462 catch (Exception e) {
2463 finderCache.removeResult(finderPath, finderArgs);
2464
2465 throw processException(e);
2466 }
2467 finally {
2468 closeSession(session);
2469 }
2470 }
2471
2472 return list;
2473 }
2474
2475
2479 @Override
2480 public void removeAll() {
2481 for (SCLicense scLicense : findAll()) {
2482 remove(scLicense);
2483 }
2484 }
2485
2486
2491 @Override
2492 public int countAll() {
2493 Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
2494 FINDER_ARGS_EMPTY, this);
2495
2496 if (count == null) {
2497 Session session = null;
2498
2499 try {
2500 session = openSession();
2501
2502 Query q = session.createQuery(_SQL_COUNT_SCLICENSE);
2503
2504 count = (Long)q.uniqueResult();
2505
2506 finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
2507 count);
2508 }
2509 catch (Exception e) {
2510 finderCache.removeResult(FINDER_PATH_COUNT_ALL,
2511 FINDER_ARGS_EMPTY);
2512
2513 throw processException(e);
2514 }
2515 finally {
2516 closeSession(session);
2517 }
2518 }
2519
2520 return count.intValue();
2521 }
2522
2523
2529 @Override
2530 public long[] getSCProductEntryPrimaryKeys(long pk) {
2531 long[] pks = scLicenseToSCProductEntryTableMapper.getRightPrimaryKeys(0,
2532 pk);
2533
2534 return pks.clone();
2535 }
2536
2537
2543 @Override
2544 public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
2545 long pk) {
2546 return getSCProductEntries(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2547 }
2548
2549
2561 @Override
2562 public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
2563 long pk, int start, int end) {
2564 return getSCProductEntries(pk, start, end, null);
2565 }
2566
2567
2580 @Override
2581 public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
2582 long pk, int start, int end,
2583 OrderByComparator<com.liferay.portlet.softwarecatalog.model.SCProductEntry> orderByComparator) {
2584 return scLicenseToSCProductEntryTableMapper.getRightBaseModels(0, pk,
2585 start, end, orderByComparator);
2586 }
2587
2588
2594 @Override
2595 public int getSCProductEntriesSize(long pk) {
2596 long[] pks = scLicenseToSCProductEntryTableMapper.getRightPrimaryKeys(0,
2597 pk);
2598
2599 return pks.length;
2600 }
2601
2602
2609 @Override
2610 public boolean containsSCProductEntry(long pk, long scProductEntryPK) {
2611 return scLicenseToSCProductEntryTableMapper.containsTableMapping(0, pk,
2612 scProductEntryPK);
2613 }
2614
2615
2621 @Override
2622 public boolean containsSCProductEntries(long pk) {
2623 if (getSCProductEntriesSize(pk) > 0) {
2624 return true;
2625 }
2626 else {
2627 return false;
2628 }
2629 }
2630
2631
2637 @Override
2638 public void addSCProductEntry(long pk, long scProductEntryPK) {
2639 scLicenseToSCProductEntryTableMapper.addTableMapping(0, pk,
2640 scProductEntryPK);
2641 }
2642
2643
2649 @Override
2650 public void addSCProductEntry(long pk,
2651 com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry) {
2652 scLicenseToSCProductEntryTableMapper.addTableMapping(0, pk,
2653 scProductEntry.getPrimaryKey());
2654 }
2655
2656
2662 @Override
2663 public void addSCProductEntries(long pk, long[] scProductEntryPKs) {
2664 for (long scProductEntryPK : scProductEntryPKs) {
2665 scLicenseToSCProductEntryTableMapper.addTableMapping(0, pk,
2666 scProductEntryPK);
2667 }
2668 }
2669
2670
2676 @Override
2677 public void addSCProductEntries(long pk,
2678 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries) {
2679 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2680 scLicenseToSCProductEntryTableMapper.addTableMapping(0, pk,
2681 scProductEntry.getPrimaryKey());
2682 }
2683 }
2684
2685
2690 @Override
2691 public void clearSCProductEntries(long pk) {
2692 scLicenseToSCProductEntryTableMapper.deleteLeftPrimaryKeyTableMappings(0,
2693 pk);
2694 }
2695
2696
2702 @Override
2703 public void removeSCProductEntry(long pk, long scProductEntryPK) {
2704 scLicenseToSCProductEntryTableMapper.deleteTableMapping(0, pk,
2705 scProductEntryPK);
2706 }
2707
2708
2714 @Override
2715 public void removeSCProductEntry(long pk,
2716 com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry) {
2717 scLicenseToSCProductEntryTableMapper.deleteTableMapping(0, pk,
2718 scProductEntry.getPrimaryKey());
2719 }
2720
2721
2727 @Override
2728 public void removeSCProductEntries(long pk, long[] scProductEntryPKs) {
2729 for (long scProductEntryPK : scProductEntryPKs) {
2730 scLicenseToSCProductEntryTableMapper.deleteTableMapping(0, pk,
2731 scProductEntryPK);
2732 }
2733 }
2734
2735
2741 @Override
2742 public void removeSCProductEntries(long pk,
2743 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries) {
2744 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2745 scLicenseToSCProductEntryTableMapper.deleteTableMapping(0, pk,
2746 scProductEntry.getPrimaryKey());
2747 }
2748 }
2749
2750
2756 @Override
2757 public void setSCProductEntries(long pk, long[] scProductEntryPKs) {
2758 Set<Long> newSCProductEntryPKsSet = SetUtil.fromArray(scProductEntryPKs);
2759 Set<Long> oldSCProductEntryPKsSet = SetUtil.fromArray(scLicenseToSCProductEntryTableMapper.getRightPrimaryKeys(
2760 0, pk));
2761
2762 Set<Long> removeSCProductEntryPKsSet = new HashSet<Long>(oldSCProductEntryPKsSet);
2763
2764 removeSCProductEntryPKsSet.removeAll(newSCProductEntryPKsSet);
2765
2766 for (long removeSCProductEntryPK : removeSCProductEntryPKsSet) {
2767 scLicenseToSCProductEntryTableMapper.deleteTableMapping(0, pk,
2768 removeSCProductEntryPK);
2769 }
2770
2771 newSCProductEntryPKsSet.removeAll(oldSCProductEntryPKsSet);
2772
2773 for (long newSCProductEntryPK : newSCProductEntryPKsSet) {
2774 scLicenseToSCProductEntryTableMapper.addTableMapping(0, pk,
2775 newSCProductEntryPK);
2776 }
2777 }
2778
2779
2785 @Override
2786 public void setSCProductEntries(long pk,
2787 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries) {
2788 try {
2789 long[] scProductEntryPKs = new long[scProductEntries.size()];
2790
2791 for (int i = 0; i < scProductEntries.size(); i++) {
2792 com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry =
2793 scProductEntries.get(i);
2794
2795 scProductEntryPKs[i] = scProductEntry.getPrimaryKey();
2796 }
2797
2798 setSCProductEntries(pk, scProductEntryPKs);
2799 }
2800 catch (Exception e) {
2801 throw processException(e);
2802 }
2803 }
2804
2805 @Override
2806 public Set<String> getBadColumnNames() {
2807 return _badColumnNames;
2808 }
2809
2810 @Override
2811 protected Map<String, Integer> getTableColumnsMap() {
2812 return SCLicenseModelImpl.TABLE_COLUMNS_MAP;
2813 }
2814
2815
2818 public void afterPropertiesSet() {
2819 scLicenseToSCProductEntryTableMapper = TableMapperFactory.getTableMapper("SCLicenses_SCProductEntries",
2820 "companyId", "licenseId", "productEntryId", this,
2821 scProductEntryPersistence);
2822 }
2823
2824 public void destroy() {
2825 entityCache.removeCache(SCLicenseImpl.class.getName());
2826 finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
2827 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2828 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2829
2830 TableMapperFactory.removeTableMapper("SCLicenses_SCProductEntries");
2831 }
2832
2833 protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
2834 protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
2835 @BeanReference(type = SCProductEntryPersistence.class)
2836 protected SCProductEntryPersistence scProductEntryPersistence;
2837 protected TableMapper<SCLicense, com.liferay.portlet.softwarecatalog.model.SCProductEntry> scLicenseToSCProductEntryTableMapper;
2838 private static final String _SQL_SELECT_SCLICENSE = "SELECT scLicense FROM SCLicense scLicense";
2839 private static final String _SQL_SELECT_SCLICENSE_WHERE_PKS_IN = "SELECT scLicense FROM SCLicense scLicense WHERE licenseId IN (";
2840 private static final String _SQL_SELECT_SCLICENSE_WHERE = "SELECT scLicense FROM SCLicense scLicense WHERE ";
2841 private static final String _SQL_COUNT_SCLICENSE = "SELECT COUNT(scLicense) FROM SCLicense scLicense";
2842 private static final String _SQL_COUNT_SCLICENSE_WHERE = "SELECT COUNT(scLicense) FROM SCLicense scLicense WHERE ";
2843 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "scLicense.licenseId";
2844 private static final String _FILTER_SQL_SELECT_SCLICENSE_WHERE = "SELECT DISTINCT {scLicense.*} FROM SCLicense scLicense WHERE ";
2845 private static final String _FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1 =
2846 "SELECT {SCLicense.*} FROM (SELECT DISTINCT scLicense.licenseId FROM SCLicense scLicense WHERE ";
2847 private static final String _FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2 =
2848 ") TEMP_TABLE INNER JOIN SCLicense ON TEMP_TABLE.licenseId = SCLicense.licenseId";
2849 private static final String _FILTER_SQL_COUNT_SCLICENSE_WHERE = "SELECT COUNT(DISTINCT scLicense.licenseId) AS COUNT_VALUE FROM SCLicense scLicense WHERE ";
2850 private static final String _FILTER_ENTITY_ALIAS = "scLicense";
2851 private static final String _FILTER_ENTITY_TABLE = "SCLicense";
2852 private static final String _ORDER_BY_ENTITY_ALIAS = "scLicense.";
2853 private static final String _ORDER_BY_ENTITY_TABLE = "SCLicense.";
2854 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SCLicense exists with the primary key ";
2855 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SCLicense exists with the key {";
2856 private static final Log _log = LogFactoryUtil.getLog(SCLicensePersistenceImpl.class);
2857 private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
2858 "active"
2859 });
2860 private static final SCLicense _nullSCLicense = new SCLicenseImpl() {
2861 @Override
2862 public Object clone() {
2863 return this;
2864 }
2865
2866 @Override
2867 public CacheModel<SCLicense> toCacheModel() {
2868 return _nullSCLicenseCacheModel;
2869 }
2870 };
2871
2872 private static final CacheModel<SCLicense> _nullSCLicenseCacheModel = new CacheModel<SCLicense>() {
2873 @Override
2874 public SCLicense toEntityModel() {
2875 return _nullSCLicense;
2876 }
2877 };
2878 }