001
014
015 package com.liferay.portlet.softwarecatalog.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.bean.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
021 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
022 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
023 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
024 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
025 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
026 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
027 import com.liferay.portal.kernel.dao.orm.FinderPath;
028 import com.liferay.portal.kernel.dao.orm.Query;
029 import com.liferay.portal.kernel.dao.orm.QueryPos;
030 import com.liferay.portal.kernel.dao.orm.QueryUtil;
031 import com.liferay.portal.kernel.dao.orm.SQLQuery;
032 import com.liferay.portal.kernel.dao.orm.Session;
033 import com.liferay.portal.kernel.exception.SystemException;
034 import com.liferay.portal.kernel.log.Log;
035 import com.liferay.portal.kernel.log.LogFactoryUtil;
036 import com.liferay.portal.kernel.util.GetterUtil;
037 import com.liferay.portal.kernel.util.InstanceFactory;
038 import com.liferay.portal.kernel.util.OrderByComparator;
039 import com.liferay.portal.kernel.util.SetUtil;
040 import com.liferay.portal.kernel.util.StringBundler;
041 import com.liferay.portal.kernel.util.StringPool;
042 import com.liferay.portal.kernel.util.StringUtil;
043 import com.liferay.portal.model.CacheModel;
044 import com.liferay.portal.model.ModelListener;
045 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
046 import com.liferay.portal.service.persistence.UserPersistence;
047 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
048
049 import com.liferay.portlet.softwarecatalog.NoSuchLicenseException;
050 import com.liferay.portlet.softwarecatalog.model.SCLicense;
051 import com.liferay.portlet.softwarecatalog.model.impl.SCLicenseImpl;
052 import com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl;
053
054 import java.io.Serializable;
055
056 import java.util.ArrayList;
057 import java.util.Collections;
058 import java.util.List;
059 import java.util.Set;
060
061
073 public class SCLicensePersistenceImpl extends BasePersistenceImpl<SCLicense>
074 implements SCLicensePersistence {
075
080 public static final String FINDER_CLASS_NAME_ENTITY = SCLicenseImpl.class.getName();
081 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
082 ".List1";
083 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
084 ".List2";
085 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_ACTIVE = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
086 SCLicenseModelImpl.FINDER_CACHE_ENABLED, SCLicenseImpl.class,
087 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByActive",
088 new String[] {
089 Boolean.class.getName(),
090
091 "java.lang.Integer", "java.lang.Integer",
092 "com.liferay.portal.kernel.util.OrderByComparator"
093 });
094 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE =
095 new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
096 SCLicenseModelImpl.FINDER_CACHE_ENABLED, SCLicenseImpl.class,
097 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByActive",
098 new String[] { Boolean.class.getName() },
099 SCLicenseModelImpl.ACTIVE_COLUMN_BITMASK);
100 public static final FinderPath FINDER_PATH_COUNT_BY_ACTIVE = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
101 SCLicenseModelImpl.FINDER_CACHE_ENABLED, Long.class,
102 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByActive",
103 new String[] { Boolean.class.getName() });
104 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_A_R = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
105 SCLicenseModelImpl.FINDER_CACHE_ENABLED, SCLicenseImpl.class,
106 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByA_R",
107 new String[] {
108 Boolean.class.getName(), Boolean.class.getName(),
109
110 "java.lang.Integer", "java.lang.Integer",
111 "com.liferay.portal.kernel.util.OrderByComparator"
112 });
113 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_A_R = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
114 SCLicenseModelImpl.FINDER_CACHE_ENABLED, SCLicenseImpl.class,
115 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByA_R",
116 new String[] { Boolean.class.getName(), Boolean.class.getName() },
117 SCLicenseModelImpl.ACTIVE_COLUMN_BITMASK |
118 SCLicenseModelImpl.RECOMMENDED_COLUMN_BITMASK);
119 public static final FinderPath FINDER_PATH_COUNT_BY_A_R = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
120 SCLicenseModelImpl.FINDER_CACHE_ENABLED, Long.class,
121 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByA_R",
122 new String[] { Boolean.class.getName(), Boolean.class.getName() });
123 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
124 SCLicenseModelImpl.FINDER_CACHE_ENABLED, SCLicenseImpl.class,
125 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
126 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
127 SCLicenseModelImpl.FINDER_CACHE_ENABLED, SCLicenseImpl.class,
128 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
129 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
130 SCLicenseModelImpl.FINDER_CACHE_ENABLED, Long.class,
131 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
132
133
138 public void cacheResult(SCLicense scLicense) {
139 EntityCacheUtil.putResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
140 SCLicenseImpl.class, scLicense.getPrimaryKey(), scLicense);
141
142 scLicense.resetOriginalValues();
143 }
144
145
150 public void cacheResult(List<SCLicense> scLicenses) {
151 for (SCLicense scLicense : scLicenses) {
152 if (EntityCacheUtil.getResult(
153 SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
154 SCLicenseImpl.class, scLicense.getPrimaryKey()) == null) {
155 cacheResult(scLicense);
156 }
157 else {
158 scLicense.resetOriginalValues();
159 }
160 }
161 }
162
163
170 @Override
171 public void clearCache() {
172 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
173 CacheRegistryUtil.clear(SCLicenseImpl.class.getName());
174 }
175
176 EntityCacheUtil.clearCache(SCLicenseImpl.class.getName());
177
178 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
179 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
180 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
181 }
182
183
190 @Override
191 public void clearCache(SCLicense scLicense) {
192 EntityCacheUtil.removeResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
193 SCLicenseImpl.class, scLicense.getPrimaryKey());
194
195 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
196 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
197 }
198
199 @Override
200 public void clearCache(List<SCLicense> scLicenses) {
201 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
202 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
203
204 for (SCLicense scLicense : scLicenses) {
205 EntityCacheUtil.removeResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
206 SCLicenseImpl.class, scLicense.getPrimaryKey());
207 }
208 }
209
210
216 public SCLicense create(long licenseId) {
217 SCLicense scLicense = new SCLicenseImpl();
218
219 scLicense.setNew(true);
220 scLicense.setPrimaryKey(licenseId);
221
222 return scLicense;
223 }
224
225
233 public SCLicense remove(long licenseId)
234 throws NoSuchLicenseException, SystemException {
235 return remove(Long.valueOf(licenseId));
236 }
237
238
246 @Override
247 public SCLicense remove(Serializable primaryKey)
248 throws NoSuchLicenseException, SystemException {
249 Session session = null;
250
251 try {
252 session = openSession();
253
254 SCLicense scLicense = (SCLicense)session.get(SCLicenseImpl.class,
255 primaryKey);
256
257 if (scLicense == null) {
258 if (_log.isWarnEnabled()) {
259 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
260 }
261
262 throw new NoSuchLicenseException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
263 primaryKey);
264 }
265
266 return remove(scLicense);
267 }
268 catch (NoSuchLicenseException nsee) {
269 throw nsee;
270 }
271 catch (Exception e) {
272 throw processException(e);
273 }
274 finally {
275 closeSession(session);
276 }
277 }
278
279 @Override
280 protected SCLicense removeImpl(SCLicense scLicense)
281 throws SystemException {
282 scLicense = toUnwrappedModel(scLicense);
283
284 try {
285 clearSCProductEntries.clear(scLicense.getPrimaryKey());
286 }
287 catch (Exception e) {
288 throw processException(e);
289 }
290 finally {
291 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
292 }
293
294 Session session = null;
295
296 try {
297 session = openSession();
298
299 if (scLicense.isCachedModel()) {
300 scLicense = (SCLicense)session.get(SCLicenseImpl.class,
301 scLicense.getPrimaryKeyObj());
302 }
303
304 session.delete(scLicense);
305 }
306 catch (Exception e) {
307 throw processException(e);
308 }
309 finally {
310 closeSession(session);
311 }
312
313 clearCache(scLicense);
314
315 return scLicense;
316 }
317
318 @Override
319 public SCLicense updateImpl(
320 com.liferay.portlet.softwarecatalog.model.SCLicense scLicense)
321 throws SystemException {
322 scLicense = toUnwrappedModel(scLicense);
323
324 boolean isNew = scLicense.isNew();
325
326 SCLicenseModelImpl scLicenseModelImpl = (SCLicenseModelImpl)scLicense;
327
328 Session session = null;
329
330 try {
331 session = openSession();
332
333 if (scLicense.isNew()) {
334 session.save(scLicense);
335
336 scLicense.setNew(false);
337 }
338 else {
339 session.merge(scLicense);
340 }
341 }
342 catch (Exception e) {
343 throw processException(e);
344 }
345 finally {
346 closeSession(session);
347 }
348
349 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
350
351 if (isNew || !SCLicenseModelImpl.COLUMN_BITMASK_ENABLED) {
352 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
353 }
354
355 else {
356 if ((scLicenseModelImpl.getColumnBitmask() &
357 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE.getColumnBitmask()) != 0) {
358 Object[] args = new Object[] {
359 Boolean.valueOf(scLicenseModelImpl.getOriginalActive())
360 };
361
362 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ACTIVE, args);
363 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE,
364 args);
365
366 args = new Object[] {
367 Boolean.valueOf(scLicenseModelImpl.getActive())
368 };
369
370 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ACTIVE, args);
371 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE,
372 args);
373 }
374
375 if ((scLicenseModelImpl.getColumnBitmask() &
376 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_A_R.getColumnBitmask()) != 0) {
377 Object[] args = new Object[] {
378 Boolean.valueOf(scLicenseModelImpl.getOriginalActive()),
379 Boolean.valueOf(scLicenseModelImpl.getOriginalRecommended())
380 };
381
382 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_A_R, args);
383 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_A_R,
384 args);
385
386 args = new Object[] {
387 Boolean.valueOf(scLicenseModelImpl.getActive()),
388 Boolean.valueOf(scLicenseModelImpl.getRecommended())
389 };
390
391 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_A_R, args);
392 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_A_R,
393 args);
394 }
395 }
396
397 EntityCacheUtil.putResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
398 SCLicenseImpl.class, scLicense.getPrimaryKey(), scLicense);
399
400 return scLicense;
401 }
402
403 protected SCLicense toUnwrappedModel(SCLicense scLicense) {
404 if (scLicense instanceof SCLicenseImpl) {
405 return scLicense;
406 }
407
408 SCLicenseImpl scLicenseImpl = new SCLicenseImpl();
409
410 scLicenseImpl.setNew(scLicense.isNew());
411 scLicenseImpl.setPrimaryKey(scLicense.getPrimaryKey());
412
413 scLicenseImpl.setLicenseId(scLicense.getLicenseId());
414 scLicenseImpl.setName(scLicense.getName());
415 scLicenseImpl.setUrl(scLicense.getUrl());
416 scLicenseImpl.setOpenSource(scLicense.isOpenSource());
417 scLicenseImpl.setActive(scLicense.isActive());
418 scLicenseImpl.setRecommended(scLicense.isRecommended());
419
420 return scLicenseImpl;
421 }
422
423
431 @Override
432 public SCLicense findByPrimaryKey(Serializable primaryKey)
433 throws NoSuchModelException, SystemException {
434 return findByPrimaryKey(((Long)primaryKey).longValue());
435 }
436
437
445 public SCLicense findByPrimaryKey(long licenseId)
446 throws NoSuchLicenseException, SystemException {
447 SCLicense scLicense = fetchByPrimaryKey(licenseId);
448
449 if (scLicense == null) {
450 if (_log.isWarnEnabled()) {
451 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + licenseId);
452 }
453
454 throw new NoSuchLicenseException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
455 licenseId);
456 }
457
458 return scLicense;
459 }
460
461
468 @Override
469 public SCLicense fetchByPrimaryKey(Serializable primaryKey)
470 throws SystemException {
471 return fetchByPrimaryKey(((Long)primaryKey).longValue());
472 }
473
474
481 public SCLicense fetchByPrimaryKey(long licenseId)
482 throws SystemException {
483 SCLicense scLicense = (SCLicense)EntityCacheUtil.getResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
484 SCLicenseImpl.class, licenseId);
485
486 if (scLicense == _nullSCLicense) {
487 return null;
488 }
489
490 if (scLicense == null) {
491 Session session = null;
492
493 boolean hasException = false;
494
495 try {
496 session = openSession();
497
498 scLicense = (SCLicense)session.get(SCLicenseImpl.class,
499 Long.valueOf(licenseId));
500 }
501 catch (Exception e) {
502 hasException = true;
503
504 throw processException(e);
505 }
506 finally {
507 if (scLicense != null) {
508 cacheResult(scLicense);
509 }
510 else if (!hasException) {
511 EntityCacheUtil.putResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
512 SCLicenseImpl.class, licenseId, _nullSCLicense);
513 }
514
515 closeSession(session);
516 }
517 }
518
519 return scLicense;
520 }
521
522
529 public List<SCLicense> findByActive(boolean active)
530 throws SystemException {
531 return findByActive(active, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
532 }
533
534
547 public List<SCLicense> findByActive(boolean active, int start, int end)
548 throws SystemException {
549 return findByActive(active, start, end, null);
550 }
551
552
566 public List<SCLicense> findByActive(boolean active, int start, int end,
567 OrderByComparator orderByComparator) throws SystemException {
568 FinderPath finderPath = null;
569 Object[] finderArgs = null;
570
571 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
572 (orderByComparator == null)) {
573 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE;
574 finderArgs = new Object[] { active };
575 }
576 else {
577 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_ACTIVE;
578 finderArgs = new Object[] { active, start, end, orderByComparator };
579 }
580
581 List<SCLicense> list = (List<SCLicense>)FinderCacheUtil.getResult(finderPath,
582 finderArgs, this);
583
584 if ((list != null) && !list.isEmpty()) {
585 for (SCLicense scLicense : list) {
586 if ((active != scLicense.getActive())) {
587 list = null;
588
589 break;
590 }
591 }
592 }
593
594 if (list == null) {
595 StringBundler query = null;
596
597 if (orderByComparator != null) {
598 query = new StringBundler(3 +
599 (orderByComparator.getOrderByFields().length * 3));
600 }
601 else {
602 query = new StringBundler(3);
603 }
604
605 query.append(_SQL_SELECT_SCLICENSE_WHERE);
606
607 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
608
609 if (orderByComparator != null) {
610 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
611 orderByComparator);
612 }
613
614 else {
615 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
616 }
617
618 String sql = query.toString();
619
620 Session session = null;
621
622 try {
623 session = openSession();
624
625 Query q = session.createQuery(sql);
626
627 QueryPos qPos = QueryPos.getInstance(q);
628
629 qPos.add(active);
630
631 list = (List<SCLicense>)QueryUtil.list(q, getDialect(), start,
632 end);
633 }
634 catch (Exception e) {
635 throw processException(e);
636 }
637 finally {
638 if (list == null) {
639 FinderCacheUtil.removeResult(finderPath, finderArgs);
640 }
641 else {
642 cacheResult(list);
643
644 FinderCacheUtil.putResult(finderPath, finderArgs, list);
645 }
646
647 closeSession(session);
648 }
649 }
650
651 return list;
652 }
653
654
663 public SCLicense findByActive_First(boolean active,
664 OrderByComparator orderByComparator)
665 throws NoSuchLicenseException, SystemException {
666 SCLicense scLicense = fetchByActive_First(active, orderByComparator);
667
668 if (scLicense != null) {
669 return scLicense;
670 }
671
672 StringBundler msg = new StringBundler(4);
673
674 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
675
676 msg.append("active=");
677 msg.append(active);
678
679 msg.append(StringPool.CLOSE_CURLY_BRACE);
680
681 throw new NoSuchLicenseException(msg.toString());
682 }
683
684
692 public SCLicense fetchByActive_First(boolean active,
693 OrderByComparator orderByComparator) throws SystemException {
694 List<SCLicense> list = findByActive(active, 0, 1, orderByComparator);
695
696 if (!list.isEmpty()) {
697 return list.get(0);
698 }
699
700 return null;
701 }
702
703
712 public SCLicense findByActive_Last(boolean active,
713 OrderByComparator orderByComparator)
714 throws NoSuchLicenseException, SystemException {
715 SCLicense scLicense = fetchByActive_Last(active, orderByComparator);
716
717 if (scLicense != null) {
718 return scLicense;
719 }
720
721 StringBundler msg = new StringBundler(4);
722
723 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
724
725 msg.append("active=");
726 msg.append(active);
727
728 msg.append(StringPool.CLOSE_CURLY_BRACE);
729
730 throw new NoSuchLicenseException(msg.toString());
731 }
732
733
741 public SCLicense fetchByActive_Last(boolean active,
742 OrderByComparator orderByComparator) throws SystemException {
743 int count = countByActive(active);
744
745 List<SCLicense> list = findByActive(active, count - 1, count,
746 orderByComparator);
747
748 if (!list.isEmpty()) {
749 return list.get(0);
750 }
751
752 return null;
753 }
754
755
765 public SCLicense[] findByActive_PrevAndNext(long licenseId, boolean active,
766 OrderByComparator orderByComparator)
767 throws NoSuchLicenseException, SystemException {
768 SCLicense scLicense = findByPrimaryKey(licenseId);
769
770 Session session = null;
771
772 try {
773 session = openSession();
774
775 SCLicense[] array = new SCLicenseImpl[3];
776
777 array[0] = getByActive_PrevAndNext(session, scLicense, active,
778 orderByComparator, true);
779
780 array[1] = scLicense;
781
782 array[2] = getByActive_PrevAndNext(session, scLicense, active,
783 orderByComparator, false);
784
785 return array;
786 }
787 catch (Exception e) {
788 throw processException(e);
789 }
790 finally {
791 closeSession(session);
792 }
793 }
794
795 protected SCLicense getByActive_PrevAndNext(Session session,
796 SCLicense scLicense, boolean active,
797 OrderByComparator orderByComparator, boolean previous) {
798 StringBundler query = null;
799
800 if (orderByComparator != null) {
801 query = new StringBundler(6 +
802 (orderByComparator.getOrderByFields().length * 6));
803 }
804 else {
805 query = new StringBundler(3);
806 }
807
808 query.append(_SQL_SELECT_SCLICENSE_WHERE);
809
810 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
811
812 if (orderByComparator != null) {
813 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
814
815 if (orderByConditionFields.length > 0) {
816 query.append(WHERE_AND);
817 }
818
819 for (int i = 0; i < orderByConditionFields.length; i++) {
820 query.append(_ORDER_BY_ENTITY_ALIAS);
821 query.append(orderByConditionFields[i]);
822
823 if ((i + 1) < orderByConditionFields.length) {
824 if (orderByComparator.isAscending() ^ previous) {
825 query.append(WHERE_GREATER_THAN_HAS_NEXT);
826 }
827 else {
828 query.append(WHERE_LESSER_THAN_HAS_NEXT);
829 }
830 }
831 else {
832 if (orderByComparator.isAscending() ^ previous) {
833 query.append(WHERE_GREATER_THAN);
834 }
835 else {
836 query.append(WHERE_LESSER_THAN);
837 }
838 }
839 }
840
841 query.append(ORDER_BY_CLAUSE);
842
843 String[] orderByFields = orderByComparator.getOrderByFields();
844
845 for (int i = 0; i < orderByFields.length; i++) {
846 query.append(_ORDER_BY_ENTITY_ALIAS);
847 query.append(orderByFields[i]);
848
849 if ((i + 1) < orderByFields.length) {
850 if (orderByComparator.isAscending() ^ previous) {
851 query.append(ORDER_BY_ASC_HAS_NEXT);
852 }
853 else {
854 query.append(ORDER_BY_DESC_HAS_NEXT);
855 }
856 }
857 else {
858 if (orderByComparator.isAscending() ^ previous) {
859 query.append(ORDER_BY_ASC);
860 }
861 else {
862 query.append(ORDER_BY_DESC);
863 }
864 }
865 }
866 }
867
868 else {
869 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
870 }
871
872 String sql = query.toString();
873
874 Query q = session.createQuery(sql);
875
876 q.setFirstResult(0);
877 q.setMaxResults(2);
878
879 QueryPos qPos = QueryPos.getInstance(q);
880
881 qPos.add(active);
882
883 if (orderByComparator != null) {
884 Object[] values = orderByComparator.getOrderByConditionValues(scLicense);
885
886 for (Object value : values) {
887 qPos.add(value);
888 }
889 }
890
891 List<SCLicense> list = q.list();
892
893 if (list.size() == 2) {
894 return list.get(1);
895 }
896 else {
897 return null;
898 }
899 }
900
901
908 public List<SCLicense> filterFindByActive(boolean active)
909 throws SystemException {
910 return filterFindByActive(active, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
911 null);
912 }
913
914
927 public List<SCLicense> filterFindByActive(boolean active, int start, int end)
928 throws SystemException {
929 return filterFindByActive(active, start, end, null);
930 }
931
932
946 public List<SCLicense> filterFindByActive(boolean active, int start,
947 int end, OrderByComparator orderByComparator) throws SystemException {
948 if (!InlineSQLHelperUtil.isEnabled()) {
949 return findByActive(active, start, end, orderByComparator);
950 }
951
952 StringBundler query = null;
953
954 if (orderByComparator != null) {
955 query = new StringBundler(3 +
956 (orderByComparator.getOrderByFields().length * 3));
957 }
958 else {
959 query = new StringBundler(3);
960 }
961
962 if (getDB().isSupportsInlineDistinct()) {
963 query.append(_FILTER_SQL_SELECT_SCLICENSE_WHERE);
964 }
965 else {
966 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1);
967 }
968
969 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
970
971 if (!getDB().isSupportsInlineDistinct()) {
972 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2);
973 }
974
975 if (orderByComparator != null) {
976 if (getDB().isSupportsInlineDistinct()) {
977 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
978 orderByComparator);
979 }
980 else {
981 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
982 orderByComparator);
983 }
984 }
985
986 else {
987 if (getDB().isSupportsInlineDistinct()) {
988 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
989 }
990 else {
991 query.append(SCLicenseModelImpl.ORDER_BY_SQL);
992 }
993 }
994
995 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
996 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
997
998 Session session = null;
999
1000 try {
1001 session = openSession();
1002
1003 SQLQuery q = session.createSQLQuery(sql);
1004
1005 if (getDB().isSupportsInlineDistinct()) {
1006 q.addEntity(_FILTER_ENTITY_ALIAS, SCLicenseImpl.class);
1007 }
1008 else {
1009 q.addEntity(_FILTER_ENTITY_TABLE, SCLicenseImpl.class);
1010 }
1011
1012 QueryPos qPos = QueryPos.getInstance(q);
1013
1014 qPos.add(active);
1015
1016 return (List<SCLicense>)QueryUtil.list(q, getDialect(), start, end);
1017 }
1018 catch (Exception e) {
1019 throw processException(e);
1020 }
1021 finally {
1022 closeSession(session);
1023 }
1024 }
1025
1026
1036 public SCLicense[] filterFindByActive_PrevAndNext(long licenseId,
1037 boolean active, OrderByComparator orderByComparator)
1038 throws NoSuchLicenseException, SystemException {
1039 if (!InlineSQLHelperUtil.isEnabled()) {
1040 return findByActive_PrevAndNext(licenseId, active, orderByComparator);
1041 }
1042
1043 SCLicense scLicense = findByPrimaryKey(licenseId);
1044
1045 Session session = null;
1046
1047 try {
1048 session = openSession();
1049
1050 SCLicense[] array = new SCLicenseImpl[3];
1051
1052 array[0] = filterGetByActive_PrevAndNext(session, scLicense,
1053 active, orderByComparator, true);
1054
1055 array[1] = scLicense;
1056
1057 array[2] = filterGetByActive_PrevAndNext(session, scLicense,
1058 active, orderByComparator, false);
1059
1060 return array;
1061 }
1062 catch (Exception e) {
1063 throw processException(e);
1064 }
1065 finally {
1066 closeSession(session);
1067 }
1068 }
1069
1070 protected SCLicense filterGetByActive_PrevAndNext(Session session,
1071 SCLicense scLicense, boolean active,
1072 OrderByComparator orderByComparator, boolean previous) {
1073 StringBundler query = null;
1074
1075 if (orderByComparator != null) {
1076 query = new StringBundler(6 +
1077 (orderByComparator.getOrderByFields().length * 6));
1078 }
1079 else {
1080 query = new StringBundler(3);
1081 }
1082
1083 if (getDB().isSupportsInlineDistinct()) {
1084 query.append(_FILTER_SQL_SELECT_SCLICENSE_WHERE);
1085 }
1086 else {
1087 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1);
1088 }
1089
1090 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
1091
1092 if (!getDB().isSupportsInlineDistinct()) {
1093 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2);
1094 }
1095
1096 if (orderByComparator != null) {
1097 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1098
1099 if (orderByConditionFields.length > 0) {
1100 query.append(WHERE_AND);
1101 }
1102
1103 for (int i = 0; i < orderByConditionFields.length; i++) {
1104 if (getDB().isSupportsInlineDistinct()) {
1105 query.append(_ORDER_BY_ENTITY_ALIAS);
1106 }
1107 else {
1108 query.append(_ORDER_BY_ENTITY_TABLE);
1109 }
1110
1111 query.append(orderByConditionFields[i]);
1112
1113 if ((i + 1) < orderByConditionFields.length) {
1114 if (orderByComparator.isAscending() ^ previous) {
1115 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1116 }
1117 else {
1118 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1119 }
1120 }
1121 else {
1122 if (orderByComparator.isAscending() ^ previous) {
1123 query.append(WHERE_GREATER_THAN);
1124 }
1125 else {
1126 query.append(WHERE_LESSER_THAN);
1127 }
1128 }
1129 }
1130
1131 query.append(ORDER_BY_CLAUSE);
1132
1133 String[] orderByFields = orderByComparator.getOrderByFields();
1134
1135 for (int i = 0; i < orderByFields.length; i++) {
1136 if (getDB().isSupportsInlineDistinct()) {
1137 query.append(_ORDER_BY_ENTITY_ALIAS);
1138 }
1139 else {
1140 query.append(_ORDER_BY_ENTITY_TABLE);
1141 }
1142
1143 query.append(orderByFields[i]);
1144
1145 if ((i + 1) < orderByFields.length) {
1146 if (orderByComparator.isAscending() ^ previous) {
1147 query.append(ORDER_BY_ASC_HAS_NEXT);
1148 }
1149 else {
1150 query.append(ORDER_BY_DESC_HAS_NEXT);
1151 }
1152 }
1153 else {
1154 if (orderByComparator.isAscending() ^ previous) {
1155 query.append(ORDER_BY_ASC);
1156 }
1157 else {
1158 query.append(ORDER_BY_DESC);
1159 }
1160 }
1161 }
1162 }
1163
1164 else {
1165 if (getDB().isSupportsInlineDistinct()) {
1166 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1167 }
1168 else {
1169 query.append(SCLicenseModelImpl.ORDER_BY_SQL);
1170 }
1171 }
1172
1173 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1174 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1175
1176 SQLQuery q = session.createSQLQuery(sql);
1177
1178 q.setFirstResult(0);
1179 q.setMaxResults(2);
1180
1181 if (getDB().isSupportsInlineDistinct()) {
1182 q.addEntity(_FILTER_ENTITY_ALIAS, SCLicenseImpl.class);
1183 }
1184 else {
1185 q.addEntity(_FILTER_ENTITY_TABLE, SCLicenseImpl.class);
1186 }
1187
1188 QueryPos qPos = QueryPos.getInstance(q);
1189
1190 qPos.add(active);
1191
1192 if (orderByComparator != null) {
1193 Object[] values = orderByComparator.getOrderByConditionValues(scLicense);
1194
1195 for (Object value : values) {
1196 qPos.add(value);
1197 }
1198 }
1199
1200 List<SCLicense> list = q.list();
1201
1202 if (list.size() == 2) {
1203 return list.get(1);
1204 }
1205 else {
1206 return null;
1207 }
1208 }
1209
1210
1218 public List<SCLicense> findByA_R(boolean active, boolean recommended)
1219 throws SystemException {
1220 return findByA_R(active, recommended, QueryUtil.ALL_POS,
1221 QueryUtil.ALL_POS, null);
1222 }
1223
1224
1238 public List<SCLicense> findByA_R(boolean active, boolean recommended,
1239 int start, int end) throws SystemException {
1240 return findByA_R(active, recommended, start, end, null);
1241 }
1242
1243
1258 public List<SCLicense> findByA_R(boolean active, boolean recommended,
1259 int start, int end, OrderByComparator orderByComparator)
1260 throws SystemException {
1261 FinderPath finderPath = null;
1262 Object[] finderArgs = null;
1263
1264 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1265 (orderByComparator == null)) {
1266 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_A_R;
1267 finderArgs = new Object[] { active, recommended };
1268 }
1269 else {
1270 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_A_R;
1271 finderArgs = new Object[] {
1272 active, recommended,
1273
1274 start, end, orderByComparator
1275 };
1276 }
1277
1278 List<SCLicense> list = (List<SCLicense>)FinderCacheUtil.getResult(finderPath,
1279 finderArgs, this);
1280
1281 if ((list != null) && !list.isEmpty()) {
1282 for (SCLicense scLicense : list) {
1283 if ((active != scLicense.getActive()) ||
1284 (recommended != scLicense.getRecommended())) {
1285 list = null;
1286
1287 break;
1288 }
1289 }
1290 }
1291
1292 if (list == null) {
1293 StringBundler query = null;
1294
1295 if (orderByComparator != null) {
1296 query = new StringBundler(4 +
1297 (orderByComparator.getOrderByFields().length * 3));
1298 }
1299 else {
1300 query = new StringBundler(4);
1301 }
1302
1303 query.append(_SQL_SELECT_SCLICENSE_WHERE);
1304
1305 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1306
1307 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1308
1309 if (orderByComparator != null) {
1310 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1311 orderByComparator);
1312 }
1313
1314 else {
1315 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1316 }
1317
1318 String sql = query.toString();
1319
1320 Session session = null;
1321
1322 try {
1323 session = openSession();
1324
1325 Query q = session.createQuery(sql);
1326
1327 QueryPos qPos = QueryPos.getInstance(q);
1328
1329 qPos.add(active);
1330
1331 qPos.add(recommended);
1332
1333 list = (List<SCLicense>)QueryUtil.list(q, getDialect(), start,
1334 end);
1335 }
1336 catch (Exception e) {
1337 throw processException(e);
1338 }
1339 finally {
1340 if (list == null) {
1341 FinderCacheUtil.removeResult(finderPath, finderArgs);
1342 }
1343 else {
1344 cacheResult(list);
1345
1346 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1347 }
1348
1349 closeSession(session);
1350 }
1351 }
1352
1353 return list;
1354 }
1355
1356
1366 public SCLicense findByA_R_First(boolean active, boolean recommended,
1367 OrderByComparator orderByComparator)
1368 throws NoSuchLicenseException, SystemException {
1369 SCLicense scLicense = fetchByA_R_First(active, recommended,
1370 orderByComparator);
1371
1372 if (scLicense != null) {
1373 return scLicense;
1374 }
1375
1376 StringBundler msg = new StringBundler(6);
1377
1378 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1379
1380 msg.append("active=");
1381 msg.append(active);
1382
1383 msg.append(", recommended=");
1384 msg.append(recommended);
1385
1386 msg.append(StringPool.CLOSE_CURLY_BRACE);
1387
1388 throw new NoSuchLicenseException(msg.toString());
1389 }
1390
1391
1400 public SCLicense fetchByA_R_First(boolean active, boolean recommended,
1401 OrderByComparator orderByComparator) throws SystemException {
1402 List<SCLicense> list = findByA_R(active, recommended, 0, 1,
1403 orderByComparator);
1404
1405 if (!list.isEmpty()) {
1406 return list.get(0);
1407 }
1408
1409 return null;
1410 }
1411
1412
1422 public SCLicense findByA_R_Last(boolean active, boolean recommended,
1423 OrderByComparator orderByComparator)
1424 throws NoSuchLicenseException, SystemException {
1425 SCLicense scLicense = fetchByA_R_Last(active, recommended,
1426 orderByComparator);
1427
1428 if (scLicense != null) {
1429 return scLicense;
1430 }
1431
1432 StringBundler msg = new StringBundler(6);
1433
1434 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1435
1436 msg.append("active=");
1437 msg.append(active);
1438
1439 msg.append(", recommended=");
1440 msg.append(recommended);
1441
1442 msg.append(StringPool.CLOSE_CURLY_BRACE);
1443
1444 throw new NoSuchLicenseException(msg.toString());
1445 }
1446
1447
1456 public SCLicense fetchByA_R_Last(boolean active, boolean recommended,
1457 OrderByComparator orderByComparator) throws SystemException {
1458 int count = countByA_R(active, recommended);
1459
1460 List<SCLicense> list = findByA_R(active, recommended, count - 1, count,
1461 orderByComparator);
1462
1463 if (!list.isEmpty()) {
1464 return list.get(0);
1465 }
1466
1467 return null;
1468 }
1469
1470
1481 public SCLicense[] findByA_R_PrevAndNext(long licenseId, boolean active,
1482 boolean recommended, OrderByComparator orderByComparator)
1483 throws NoSuchLicenseException, SystemException {
1484 SCLicense scLicense = findByPrimaryKey(licenseId);
1485
1486 Session session = null;
1487
1488 try {
1489 session = openSession();
1490
1491 SCLicense[] array = new SCLicenseImpl[3];
1492
1493 array[0] = getByA_R_PrevAndNext(session, scLicense, active,
1494 recommended, orderByComparator, true);
1495
1496 array[1] = scLicense;
1497
1498 array[2] = getByA_R_PrevAndNext(session, scLicense, active,
1499 recommended, orderByComparator, false);
1500
1501 return array;
1502 }
1503 catch (Exception e) {
1504 throw processException(e);
1505 }
1506 finally {
1507 closeSession(session);
1508 }
1509 }
1510
1511 protected SCLicense getByA_R_PrevAndNext(Session session,
1512 SCLicense scLicense, boolean active, boolean recommended,
1513 OrderByComparator orderByComparator, boolean previous) {
1514 StringBundler query = null;
1515
1516 if (orderByComparator != null) {
1517 query = new StringBundler(6 +
1518 (orderByComparator.getOrderByFields().length * 6));
1519 }
1520 else {
1521 query = new StringBundler(3);
1522 }
1523
1524 query.append(_SQL_SELECT_SCLICENSE_WHERE);
1525
1526 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1527
1528 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1529
1530 if (orderByComparator != null) {
1531 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1532
1533 if (orderByConditionFields.length > 0) {
1534 query.append(WHERE_AND);
1535 }
1536
1537 for (int i = 0; i < orderByConditionFields.length; i++) {
1538 query.append(_ORDER_BY_ENTITY_ALIAS);
1539 query.append(orderByConditionFields[i]);
1540
1541 if ((i + 1) < orderByConditionFields.length) {
1542 if (orderByComparator.isAscending() ^ previous) {
1543 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1544 }
1545 else {
1546 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1547 }
1548 }
1549 else {
1550 if (orderByComparator.isAscending() ^ previous) {
1551 query.append(WHERE_GREATER_THAN);
1552 }
1553 else {
1554 query.append(WHERE_LESSER_THAN);
1555 }
1556 }
1557 }
1558
1559 query.append(ORDER_BY_CLAUSE);
1560
1561 String[] orderByFields = orderByComparator.getOrderByFields();
1562
1563 for (int i = 0; i < orderByFields.length; i++) {
1564 query.append(_ORDER_BY_ENTITY_ALIAS);
1565 query.append(orderByFields[i]);
1566
1567 if ((i + 1) < orderByFields.length) {
1568 if (orderByComparator.isAscending() ^ previous) {
1569 query.append(ORDER_BY_ASC_HAS_NEXT);
1570 }
1571 else {
1572 query.append(ORDER_BY_DESC_HAS_NEXT);
1573 }
1574 }
1575 else {
1576 if (orderByComparator.isAscending() ^ previous) {
1577 query.append(ORDER_BY_ASC);
1578 }
1579 else {
1580 query.append(ORDER_BY_DESC);
1581 }
1582 }
1583 }
1584 }
1585
1586 else {
1587 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1588 }
1589
1590 String sql = query.toString();
1591
1592 Query q = session.createQuery(sql);
1593
1594 q.setFirstResult(0);
1595 q.setMaxResults(2);
1596
1597 QueryPos qPos = QueryPos.getInstance(q);
1598
1599 qPos.add(active);
1600
1601 qPos.add(recommended);
1602
1603 if (orderByComparator != null) {
1604 Object[] values = orderByComparator.getOrderByConditionValues(scLicense);
1605
1606 for (Object value : values) {
1607 qPos.add(value);
1608 }
1609 }
1610
1611 List<SCLicense> list = q.list();
1612
1613 if (list.size() == 2) {
1614 return list.get(1);
1615 }
1616 else {
1617 return null;
1618 }
1619 }
1620
1621
1629 public List<SCLicense> filterFindByA_R(boolean active, boolean recommended)
1630 throws SystemException {
1631 return filterFindByA_R(active, recommended, QueryUtil.ALL_POS,
1632 QueryUtil.ALL_POS, null);
1633 }
1634
1635
1649 public List<SCLicense> filterFindByA_R(boolean active, boolean recommended,
1650 int start, int end) throws SystemException {
1651 return filterFindByA_R(active, recommended, start, end, null);
1652 }
1653
1654
1669 public List<SCLicense> filterFindByA_R(boolean active, boolean recommended,
1670 int start, int end, OrderByComparator orderByComparator)
1671 throws SystemException {
1672 if (!InlineSQLHelperUtil.isEnabled()) {
1673 return findByA_R(active, recommended, start, end, orderByComparator);
1674 }
1675
1676 StringBundler query = null;
1677
1678 if (orderByComparator != null) {
1679 query = new StringBundler(4 +
1680 (orderByComparator.getOrderByFields().length * 3));
1681 }
1682 else {
1683 query = new StringBundler(4);
1684 }
1685
1686 if (getDB().isSupportsInlineDistinct()) {
1687 query.append(_FILTER_SQL_SELECT_SCLICENSE_WHERE);
1688 }
1689 else {
1690 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1);
1691 }
1692
1693 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1694
1695 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1696
1697 if (!getDB().isSupportsInlineDistinct()) {
1698 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2);
1699 }
1700
1701 if (orderByComparator != null) {
1702 if (getDB().isSupportsInlineDistinct()) {
1703 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1704 orderByComparator);
1705 }
1706 else {
1707 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1708 orderByComparator);
1709 }
1710 }
1711
1712 else {
1713 if (getDB().isSupportsInlineDistinct()) {
1714 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1715 }
1716 else {
1717 query.append(SCLicenseModelImpl.ORDER_BY_SQL);
1718 }
1719 }
1720
1721 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1722 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1723
1724 Session session = null;
1725
1726 try {
1727 session = openSession();
1728
1729 SQLQuery q = session.createSQLQuery(sql);
1730
1731 if (getDB().isSupportsInlineDistinct()) {
1732 q.addEntity(_FILTER_ENTITY_ALIAS, SCLicenseImpl.class);
1733 }
1734 else {
1735 q.addEntity(_FILTER_ENTITY_TABLE, SCLicenseImpl.class);
1736 }
1737
1738 QueryPos qPos = QueryPos.getInstance(q);
1739
1740 qPos.add(active);
1741
1742 qPos.add(recommended);
1743
1744 return (List<SCLicense>)QueryUtil.list(q, getDialect(), start, end);
1745 }
1746 catch (Exception e) {
1747 throw processException(e);
1748 }
1749 finally {
1750 closeSession(session);
1751 }
1752 }
1753
1754
1765 public SCLicense[] filterFindByA_R_PrevAndNext(long licenseId,
1766 boolean active, boolean recommended, OrderByComparator orderByComparator)
1767 throws NoSuchLicenseException, SystemException {
1768 if (!InlineSQLHelperUtil.isEnabled()) {
1769 return findByA_R_PrevAndNext(licenseId, active, recommended,
1770 orderByComparator);
1771 }
1772
1773 SCLicense scLicense = findByPrimaryKey(licenseId);
1774
1775 Session session = null;
1776
1777 try {
1778 session = openSession();
1779
1780 SCLicense[] array = new SCLicenseImpl[3];
1781
1782 array[0] = filterGetByA_R_PrevAndNext(session, scLicense, active,
1783 recommended, orderByComparator, true);
1784
1785 array[1] = scLicense;
1786
1787 array[2] = filterGetByA_R_PrevAndNext(session, scLicense, active,
1788 recommended, orderByComparator, false);
1789
1790 return array;
1791 }
1792 catch (Exception e) {
1793 throw processException(e);
1794 }
1795 finally {
1796 closeSession(session);
1797 }
1798 }
1799
1800 protected SCLicense filterGetByA_R_PrevAndNext(Session session,
1801 SCLicense scLicense, boolean active, boolean recommended,
1802 OrderByComparator orderByComparator, boolean previous) {
1803 StringBundler query = null;
1804
1805 if (orderByComparator != null) {
1806 query = new StringBundler(6 +
1807 (orderByComparator.getOrderByFields().length * 6));
1808 }
1809 else {
1810 query = new StringBundler(3);
1811 }
1812
1813 if (getDB().isSupportsInlineDistinct()) {
1814 query.append(_FILTER_SQL_SELECT_SCLICENSE_WHERE);
1815 }
1816 else {
1817 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1);
1818 }
1819
1820 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1821
1822 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1823
1824 if (!getDB().isSupportsInlineDistinct()) {
1825 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2);
1826 }
1827
1828 if (orderByComparator != null) {
1829 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1830
1831 if (orderByConditionFields.length > 0) {
1832 query.append(WHERE_AND);
1833 }
1834
1835 for (int i = 0; i < orderByConditionFields.length; i++) {
1836 if (getDB().isSupportsInlineDistinct()) {
1837 query.append(_ORDER_BY_ENTITY_ALIAS);
1838 }
1839 else {
1840 query.append(_ORDER_BY_ENTITY_TABLE);
1841 }
1842
1843 query.append(orderByConditionFields[i]);
1844
1845 if ((i + 1) < orderByConditionFields.length) {
1846 if (orderByComparator.isAscending() ^ previous) {
1847 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1848 }
1849 else {
1850 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1851 }
1852 }
1853 else {
1854 if (orderByComparator.isAscending() ^ previous) {
1855 query.append(WHERE_GREATER_THAN);
1856 }
1857 else {
1858 query.append(WHERE_LESSER_THAN);
1859 }
1860 }
1861 }
1862
1863 query.append(ORDER_BY_CLAUSE);
1864
1865 String[] orderByFields = orderByComparator.getOrderByFields();
1866
1867 for (int i = 0; i < orderByFields.length; i++) {
1868 if (getDB().isSupportsInlineDistinct()) {
1869 query.append(_ORDER_BY_ENTITY_ALIAS);
1870 }
1871 else {
1872 query.append(_ORDER_BY_ENTITY_TABLE);
1873 }
1874
1875 query.append(orderByFields[i]);
1876
1877 if ((i + 1) < orderByFields.length) {
1878 if (orderByComparator.isAscending() ^ previous) {
1879 query.append(ORDER_BY_ASC_HAS_NEXT);
1880 }
1881 else {
1882 query.append(ORDER_BY_DESC_HAS_NEXT);
1883 }
1884 }
1885 else {
1886 if (orderByComparator.isAscending() ^ previous) {
1887 query.append(ORDER_BY_ASC);
1888 }
1889 else {
1890 query.append(ORDER_BY_DESC);
1891 }
1892 }
1893 }
1894 }
1895
1896 else {
1897 if (getDB().isSupportsInlineDistinct()) {
1898 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1899 }
1900 else {
1901 query.append(SCLicenseModelImpl.ORDER_BY_SQL);
1902 }
1903 }
1904
1905 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1906 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1907
1908 SQLQuery q = session.createSQLQuery(sql);
1909
1910 q.setFirstResult(0);
1911 q.setMaxResults(2);
1912
1913 if (getDB().isSupportsInlineDistinct()) {
1914 q.addEntity(_FILTER_ENTITY_ALIAS, SCLicenseImpl.class);
1915 }
1916 else {
1917 q.addEntity(_FILTER_ENTITY_TABLE, SCLicenseImpl.class);
1918 }
1919
1920 QueryPos qPos = QueryPos.getInstance(q);
1921
1922 qPos.add(active);
1923
1924 qPos.add(recommended);
1925
1926 if (orderByComparator != null) {
1927 Object[] values = orderByComparator.getOrderByConditionValues(scLicense);
1928
1929 for (Object value : values) {
1930 qPos.add(value);
1931 }
1932 }
1933
1934 List<SCLicense> list = q.list();
1935
1936 if (list.size() == 2) {
1937 return list.get(1);
1938 }
1939 else {
1940 return null;
1941 }
1942 }
1943
1944
1950 public List<SCLicense> findAll() throws SystemException {
1951 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1952 }
1953
1954
1966 public List<SCLicense> findAll(int start, int end)
1967 throws SystemException {
1968 return findAll(start, end, null);
1969 }
1970
1971
1984 public List<SCLicense> findAll(int start, int end,
1985 OrderByComparator orderByComparator) throws SystemException {
1986 FinderPath finderPath = null;
1987 Object[] finderArgs = new Object[] { start, end, orderByComparator };
1988
1989 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1990 (orderByComparator == null)) {
1991 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1992 finderArgs = FINDER_ARGS_EMPTY;
1993 }
1994 else {
1995 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1996 finderArgs = new Object[] { start, end, orderByComparator };
1997 }
1998
1999 List<SCLicense> list = (List<SCLicense>)FinderCacheUtil.getResult(finderPath,
2000 finderArgs, this);
2001
2002 if (list == null) {
2003 StringBundler query = null;
2004 String sql = null;
2005
2006 if (orderByComparator != null) {
2007 query = new StringBundler(2 +
2008 (orderByComparator.getOrderByFields().length * 3));
2009
2010 query.append(_SQL_SELECT_SCLICENSE);
2011
2012 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2013 orderByComparator);
2014
2015 sql = query.toString();
2016 }
2017 else {
2018 sql = _SQL_SELECT_SCLICENSE.concat(SCLicenseModelImpl.ORDER_BY_JPQL);
2019 }
2020
2021 Session session = null;
2022
2023 try {
2024 session = openSession();
2025
2026 Query q = session.createQuery(sql);
2027
2028 if (orderByComparator == null) {
2029 list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
2030 start, end, false);
2031
2032 Collections.sort(list);
2033 }
2034 else {
2035 list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
2036 start, end);
2037 }
2038 }
2039 catch (Exception e) {
2040 throw processException(e);
2041 }
2042 finally {
2043 if (list == null) {
2044 FinderCacheUtil.removeResult(finderPath, finderArgs);
2045 }
2046 else {
2047 cacheResult(list);
2048
2049 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2050 }
2051
2052 closeSession(session);
2053 }
2054 }
2055
2056 return list;
2057 }
2058
2059
2065 public void removeByActive(boolean active) throws SystemException {
2066 for (SCLicense scLicense : findByActive(active)) {
2067 remove(scLicense);
2068 }
2069 }
2070
2071
2078 public void removeByA_R(boolean active, boolean recommended)
2079 throws SystemException {
2080 for (SCLicense scLicense : findByA_R(active, recommended)) {
2081 remove(scLicense);
2082 }
2083 }
2084
2085
2090 public void removeAll() throws SystemException {
2091 for (SCLicense scLicense : findAll()) {
2092 remove(scLicense);
2093 }
2094 }
2095
2096
2103 public int countByActive(boolean active) throws SystemException {
2104 Object[] finderArgs = new Object[] { active };
2105
2106 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ACTIVE,
2107 finderArgs, this);
2108
2109 if (count == null) {
2110 StringBundler query = new StringBundler(2);
2111
2112 query.append(_SQL_COUNT_SCLICENSE_WHERE);
2113
2114 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
2115
2116 String sql = query.toString();
2117
2118 Session session = null;
2119
2120 try {
2121 session = openSession();
2122
2123 Query q = session.createQuery(sql);
2124
2125 QueryPos qPos = QueryPos.getInstance(q);
2126
2127 qPos.add(active);
2128
2129 count = (Long)q.uniqueResult();
2130 }
2131 catch (Exception e) {
2132 throw processException(e);
2133 }
2134 finally {
2135 if (count == null) {
2136 count = Long.valueOf(0);
2137 }
2138
2139 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ACTIVE,
2140 finderArgs, count);
2141
2142 closeSession(session);
2143 }
2144 }
2145
2146 return count.intValue();
2147 }
2148
2149
2156 public int filterCountByActive(boolean active) throws SystemException {
2157 if (!InlineSQLHelperUtil.isEnabled()) {
2158 return countByActive(active);
2159 }
2160
2161 StringBundler query = new StringBundler(2);
2162
2163 query.append(_FILTER_SQL_COUNT_SCLICENSE_WHERE);
2164
2165 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
2166
2167 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2168 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2169
2170 Session session = null;
2171
2172 try {
2173 session = openSession();
2174
2175 SQLQuery q = session.createSQLQuery(sql);
2176
2177 q.addScalar(COUNT_COLUMN_NAME,
2178 com.liferay.portal.kernel.dao.orm.Type.LONG);
2179
2180 QueryPos qPos = QueryPos.getInstance(q);
2181
2182 qPos.add(active);
2183
2184 Long count = (Long)q.uniqueResult();
2185
2186 return count.intValue();
2187 }
2188 catch (Exception e) {
2189 throw processException(e);
2190 }
2191 finally {
2192 closeSession(session);
2193 }
2194 }
2195
2196
2204 public int countByA_R(boolean active, boolean recommended)
2205 throws SystemException {
2206 Object[] finderArgs = new Object[] { active, recommended };
2207
2208 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_A_R,
2209 finderArgs, this);
2210
2211 if (count == null) {
2212 StringBundler query = new StringBundler(3);
2213
2214 query.append(_SQL_COUNT_SCLICENSE_WHERE);
2215
2216 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
2217
2218 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
2219
2220 String sql = query.toString();
2221
2222 Session session = null;
2223
2224 try {
2225 session = openSession();
2226
2227 Query q = session.createQuery(sql);
2228
2229 QueryPos qPos = QueryPos.getInstance(q);
2230
2231 qPos.add(active);
2232
2233 qPos.add(recommended);
2234
2235 count = (Long)q.uniqueResult();
2236 }
2237 catch (Exception e) {
2238 throw processException(e);
2239 }
2240 finally {
2241 if (count == null) {
2242 count = Long.valueOf(0);
2243 }
2244
2245 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_A_R, finderArgs,
2246 count);
2247
2248 closeSession(session);
2249 }
2250 }
2251
2252 return count.intValue();
2253 }
2254
2255
2263 public int filterCountByA_R(boolean active, boolean recommended)
2264 throws SystemException {
2265 if (!InlineSQLHelperUtil.isEnabled()) {
2266 return countByA_R(active, recommended);
2267 }
2268
2269 StringBundler query = new StringBundler(3);
2270
2271 query.append(_FILTER_SQL_COUNT_SCLICENSE_WHERE);
2272
2273 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
2274
2275 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
2276
2277 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2278 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2279
2280 Session session = null;
2281
2282 try {
2283 session = openSession();
2284
2285 SQLQuery q = session.createSQLQuery(sql);
2286
2287 q.addScalar(COUNT_COLUMN_NAME,
2288 com.liferay.portal.kernel.dao.orm.Type.LONG);
2289
2290 QueryPos qPos = QueryPos.getInstance(q);
2291
2292 qPos.add(active);
2293
2294 qPos.add(recommended);
2295
2296 Long count = (Long)q.uniqueResult();
2297
2298 return count.intValue();
2299 }
2300 catch (Exception e) {
2301 throw processException(e);
2302 }
2303 finally {
2304 closeSession(session);
2305 }
2306 }
2307
2308
2314 public int countAll() throws SystemException {
2315 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2316 FINDER_ARGS_EMPTY, this);
2317
2318 if (count == null) {
2319 Session session = null;
2320
2321 try {
2322 session = openSession();
2323
2324 Query q = session.createQuery(_SQL_COUNT_SCLICENSE);
2325
2326 count = (Long)q.uniqueResult();
2327 }
2328 catch (Exception e) {
2329 throw processException(e);
2330 }
2331 finally {
2332 if (count == null) {
2333 count = Long.valueOf(0);
2334 }
2335
2336 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2337 FINDER_ARGS_EMPTY, count);
2338
2339 closeSession(session);
2340 }
2341 }
2342
2343 return count.intValue();
2344 }
2345
2346
2353 public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
2354 long pk) throws SystemException {
2355 return getSCProductEntries(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2356 }
2357
2358
2371 public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
2372 long pk, int start, int end) throws SystemException {
2373 return getSCProductEntries(pk, start, end, null);
2374 }
2375
2376 public static final FinderPath FINDER_PATH_GET_SCPRODUCTENTRIES = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
2377 SCLicenseModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
2378 com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryImpl.class,
2379 SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
2380 "getSCProductEntries",
2381 new String[] {
2382 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
2383 "com.liferay.portal.kernel.util.OrderByComparator"
2384 });
2385
2386 static {
2387 FINDER_PATH_GET_SCPRODUCTENTRIES.setCacheKeyGeneratorCacheName(null);
2388 }
2389
2390
2404 public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
2405 long pk, int start, int end, OrderByComparator orderByComparator)
2406 throws SystemException {
2407 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
2408
2409 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> list = (List<com.liferay.portlet.softwarecatalog.model.SCProductEntry>)FinderCacheUtil.getResult(FINDER_PATH_GET_SCPRODUCTENTRIES,
2410 finderArgs, this);
2411
2412 if (list == null) {
2413 Session session = null;
2414
2415 try {
2416 session = openSession();
2417
2418 String sql = null;
2419
2420 if (orderByComparator != null) {
2421 sql = _SQL_GETSCPRODUCTENTRIES.concat(ORDER_BY_CLAUSE)
2422 .concat(orderByComparator.getOrderBy());
2423 }
2424 else {
2425 sql = _SQL_GETSCPRODUCTENTRIES.concat(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ORDER_BY_SQL);
2426 }
2427
2428 SQLQuery q = session.createSQLQuery(sql);
2429
2430 q.addEntity("SCProductEntry",
2431 com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryImpl.class);
2432
2433 QueryPos qPos = QueryPos.getInstance(q);
2434
2435 qPos.add(pk);
2436
2437 list = (List<com.liferay.portlet.softwarecatalog.model.SCProductEntry>)QueryUtil.list(q,
2438 getDialect(), start, end);
2439 }
2440 catch (Exception e) {
2441 throw processException(e);
2442 }
2443 finally {
2444 if (list == null) {
2445 FinderCacheUtil.removeResult(FINDER_PATH_GET_SCPRODUCTENTRIES,
2446 finderArgs);
2447 }
2448 else {
2449 scProductEntryPersistence.cacheResult(list);
2450
2451 FinderCacheUtil.putResult(FINDER_PATH_GET_SCPRODUCTENTRIES,
2452 finderArgs, list);
2453 }
2454
2455 closeSession(session);
2456 }
2457 }
2458
2459 return list;
2460 }
2461
2462 public static final FinderPath FINDER_PATH_GET_SCPRODUCTENTRIES_SIZE = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
2463 SCLicenseModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
2464 Long.class,
2465 SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
2466 "getSCProductEntriesSize", new String[] { Long.class.getName() });
2467
2468 static {
2469 FINDER_PATH_GET_SCPRODUCTENTRIES_SIZE.setCacheKeyGeneratorCacheName(null);
2470 }
2471
2472
2479 public int getSCProductEntriesSize(long pk) throws SystemException {
2480 Object[] finderArgs = new Object[] { pk };
2481
2482 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_SCPRODUCTENTRIES_SIZE,
2483 finderArgs, this);
2484
2485 if (count == null) {
2486 Session session = null;
2487
2488 try {
2489 session = openSession();
2490
2491 SQLQuery q = session.createSQLQuery(_SQL_GETSCPRODUCTENTRIESSIZE);
2492
2493 q.addScalar(COUNT_COLUMN_NAME,
2494 com.liferay.portal.kernel.dao.orm.Type.LONG);
2495
2496 QueryPos qPos = QueryPos.getInstance(q);
2497
2498 qPos.add(pk);
2499
2500 count = (Long)q.uniqueResult();
2501 }
2502 catch (Exception e) {
2503 throw processException(e);
2504 }
2505 finally {
2506 if (count == null) {
2507 count = Long.valueOf(0);
2508 }
2509
2510 FinderCacheUtil.putResult(FINDER_PATH_GET_SCPRODUCTENTRIES_SIZE,
2511 finderArgs, count);
2512
2513 closeSession(session);
2514 }
2515 }
2516
2517 return count.intValue();
2518 }
2519
2520 public static final FinderPath FINDER_PATH_CONTAINS_SCPRODUCTENTRY = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
2521 SCLicenseModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
2522 Boolean.class,
2523 SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
2524 "containsSCProductEntry",
2525 new String[] { Long.class.getName(), Long.class.getName() });
2526
2527
2535 public boolean containsSCProductEntry(long pk, long scProductEntryPK)
2536 throws SystemException {
2537 Object[] finderArgs = new Object[] { pk, scProductEntryPK };
2538
2539 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_SCPRODUCTENTRY,
2540 finderArgs, this);
2541
2542 if (value == null) {
2543 try {
2544 value = Boolean.valueOf(containsSCProductEntry.contains(pk,
2545 scProductEntryPK));
2546 }
2547 catch (Exception e) {
2548 throw processException(e);
2549 }
2550 finally {
2551 if (value == null) {
2552 value = Boolean.FALSE;
2553 }
2554
2555 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_SCPRODUCTENTRY,
2556 finderArgs, value);
2557 }
2558 }
2559
2560 return value.booleanValue();
2561 }
2562
2563
2570 public boolean containsSCProductEntries(long pk) throws SystemException {
2571 if (getSCProductEntriesSize(pk) > 0) {
2572 return true;
2573 }
2574 else {
2575 return false;
2576 }
2577 }
2578
2579
2586 public void addSCProductEntry(long pk, long scProductEntryPK)
2587 throws SystemException {
2588 try {
2589 addSCProductEntry.add(pk, scProductEntryPK);
2590 }
2591 catch (Exception e) {
2592 throw processException(e);
2593 }
2594 finally {
2595 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2596 }
2597 }
2598
2599
2606 public void addSCProductEntry(long pk,
2607 com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry)
2608 throws SystemException {
2609 try {
2610 addSCProductEntry.add(pk, scProductEntry.getPrimaryKey());
2611 }
2612 catch (Exception e) {
2613 throw processException(e);
2614 }
2615 finally {
2616 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2617 }
2618 }
2619
2620
2627 public void addSCProductEntries(long pk, long[] scProductEntryPKs)
2628 throws SystemException {
2629 try {
2630 for (long scProductEntryPK : scProductEntryPKs) {
2631 addSCProductEntry.add(pk, scProductEntryPK);
2632 }
2633 }
2634 catch (Exception e) {
2635 throw processException(e);
2636 }
2637 finally {
2638 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2639 }
2640 }
2641
2642
2649 public void addSCProductEntries(long pk,
2650 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries)
2651 throws SystemException {
2652 try {
2653 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2654 addSCProductEntry.add(pk, scProductEntry.getPrimaryKey());
2655 }
2656 }
2657 catch (Exception e) {
2658 throw processException(e);
2659 }
2660 finally {
2661 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2662 }
2663 }
2664
2665
2671 public void clearSCProductEntries(long pk) throws SystemException {
2672 try {
2673 clearSCProductEntries.clear(pk);
2674 }
2675 catch (Exception e) {
2676 throw processException(e);
2677 }
2678 finally {
2679 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2680 }
2681 }
2682
2683
2690 public void removeSCProductEntry(long pk, long scProductEntryPK)
2691 throws SystemException {
2692 try {
2693 removeSCProductEntry.remove(pk, scProductEntryPK);
2694 }
2695 catch (Exception e) {
2696 throw processException(e);
2697 }
2698 finally {
2699 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2700 }
2701 }
2702
2703
2710 public void removeSCProductEntry(long pk,
2711 com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry)
2712 throws SystemException {
2713 try {
2714 removeSCProductEntry.remove(pk, scProductEntry.getPrimaryKey());
2715 }
2716 catch (Exception e) {
2717 throw processException(e);
2718 }
2719 finally {
2720 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2721 }
2722 }
2723
2724
2731 public void removeSCProductEntries(long pk, long[] scProductEntryPKs)
2732 throws SystemException {
2733 try {
2734 for (long scProductEntryPK : scProductEntryPKs) {
2735 removeSCProductEntry.remove(pk, scProductEntryPK);
2736 }
2737 }
2738 catch (Exception e) {
2739 throw processException(e);
2740 }
2741 finally {
2742 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2743 }
2744 }
2745
2746
2753 public void removeSCProductEntries(long pk,
2754 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries)
2755 throws SystemException {
2756 try {
2757 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2758 removeSCProductEntry.remove(pk, scProductEntry.getPrimaryKey());
2759 }
2760 }
2761 catch (Exception e) {
2762 throw processException(e);
2763 }
2764 finally {
2765 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2766 }
2767 }
2768
2769
2776 public void setSCProductEntries(long pk, long[] scProductEntryPKs)
2777 throws SystemException {
2778 try {
2779 Set<Long> scProductEntryPKSet = SetUtil.fromArray(scProductEntryPKs);
2780
2781 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries =
2782 getSCProductEntries(pk);
2783
2784 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2785 if (!scProductEntryPKSet.remove(scProductEntry.getPrimaryKey())) {
2786 removeSCProductEntry.remove(pk,
2787 scProductEntry.getPrimaryKey());
2788 }
2789 }
2790
2791 for (Long scProductEntryPK : scProductEntryPKSet) {
2792 addSCProductEntry.add(pk, scProductEntryPK);
2793 }
2794 }
2795 catch (Exception e) {
2796 throw processException(e);
2797 }
2798 finally {
2799 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2800 }
2801 }
2802
2803
2810 public void setSCProductEntries(long pk,
2811 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries)
2812 throws SystemException {
2813 try {
2814 long[] scProductEntryPKs = new long[scProductEntries.size()];
2815
2816 for (int i = 0; i < scProductEntries.size(); i++) {
2817 com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry =
2818 scProductEntries.get(i);
2819
2820 scProductEntryPKs[i] = scProductEntry.getPrimaryKey();
2821 }
2822
2823 setSCProductEntries(pk, scProductEntryPKs);
2824 }
2825 catch (Exception e) {
2826 throw processException(e);
2827 }
2828 finally {
2829 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2830 }
2831 }
2832
2833
2836 public void afterPropertiesSet() {
2837 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2838 com.liferay.portal.util.PropsUtil.get(
2839 "value.object.listener.com.liferay.portlet.softwarecatalog.model.SCLicense")));
2840
2841 if (listenerClassNames.length > 0) {
2842 try {
2843 List<ModelListener<SCLicense>> listenersList = new ArrayList<ModelListener<SCLicense>>();
2844
2845 for (String listenerClassName : listenerClassNames) {
2846 listenersList.add((ModelListener<SCLicense>)InstanceFactory.newInstance(
2847 listenerClassName));
2848 }
2849
2850 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2851 }
2852 catch (Exception e) {
2853 _log.error(e);
2854 }
2855 }
2856
2857 containsSCProductEntry = new ContainsSCProductEntry();
2858
2859 addSCProductEntry = new AddSCProductEntry();
2860 clearSCProductEntries = new ClearSCProductEntries();
2861 removeSCProductEntry = new RemoveSCProductEntry();
2862 }
2863
2864 public void destroy() {
2865 EntityCacheUtil.removeCache(SCLicenseImpl.class.getName());
2866 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2867 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2868 }
2869
2870 @BeanReference(type = SCFrameworkVersionPersistence.class)
2871 protected SCFrameworkVersionPersistence scFrameworkVersionPersistence;
2872 @BeanReference(type = SCLicensePersistence.class)
2873 protected SCLicensePersistence scLicensePersistence;
2874 @BeanReference(type = SCProductEntryPersistence.class)
2875 protected SCProductEntryPersistence scProductEntryPersistence;
2876 @BeanReference(type = SCProductScreenshotPersistence.class)
2877 protected SCProductScreenshotPersistence scProductScreenshotPersistence;
2878 @BeanReference(type = SCProductVersionPersistence.class)
2879 protected SCProductVersionPersistence scProductVersionPersistence;
2880 @BeanReference(type = UserPersistence.class)
2881 protected UserPersistence userPersistence;
2882 protected ContainsSCProductEntry containsSCProductEntry;
2883 protected AddSCProductEntry addSCProductEntry;
2884 protected ClearSCProductEntries clearSCProductEntries;
2885 protected RemoveSCProductEntry removeSCProductEntry;
2886
2887 protected class ContainsSCProductEntry {
2888 protected ContainsSCProductEntry() {
2889 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2890 _SQL_CONTAINSSCPRODUCTENTRY,
2891 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
2892 RowMapper.COUNT);
2893 }
2894
2895 protected boolean contains(long licenseId, long productEntryId) {
2896 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2897 new Long(licenseId), new Long(productEntryId)
2898 });
2899
2900 if (results.size() > 0) {
2901 Integer count = results.get(0);
2902
2903 if (count.intValue() > 0) {
2904 return true;
2905 }
2906 }
2907
2908 return false;
2909 }
2910
2911 private MappingSqlQuery<Integer> _mappingSqlQuery;
2912 }
2913
2914 protected class AddSCProductEntry {
2915 protected AddSCProductEntry() {
2916 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2917 "INSERT INTO SCLicenses_SCProductEntries (licenseId, productEntryId) VALUES (?, ?)",
2918 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2919 }
2920
2921 protected void add(long licenseId, long productEntryId)
2922 throws SystemException {
2923 if (!containsSCProductEntry.contains(licenseId, productEntryId)) {
2924 ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry>[] scProductEntryListeners =
2925 scProductEntryPersistence.getListeners();
2926
2927 for (ModelListener<SCLicense> listener : listeners) {
2928 listener.onBeforeAddAssociation(licenseId,
2929 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2930 productEntryId);
2931 }
2932
2933 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2934 listener.onBeforeAddAssociation(productEntryId,
2935 SCLicense.class.getName(), licenseId);
2936 }
2937
2938 _sqlUpdate.update(new Object[] {
2939 new Long(licenseId), new Long(productEntryId)
2940 });
2941
2942 for (ModelListener<SCLicense> listener : listeners) {
2943 listener.onAfterAddAssociation(licenseId,
2944 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2945 productEntryId);
2946 }
2947
2948 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2949 listener.onAfterAddAssociation(productEntryId,
2950 SCLicense.class.getName(), licenseId);
2951 }
2952 }
2953 }
2954
2955 private SqlUpdate _sqlUpdate;
2956 }
2957
2958 protected class ClearSCProductEntries {
2959 protected ClearSCProductEntries() {
2960 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2961 "DELETE FROM SCLicenses_SCProductEntries WHERE licenseId = ?",
2962 new int[] { java.sql.Types.BIGINT });
2963 }
2964
2965 protected void clear(long licenseId) throws SystemException {
2966 ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry>[] scProductEntryListeners =
2967 scProductEntryPersistence.getListeners();
2968
2969 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries =
2970 null;
2971
2972 if ((listeners.length > 0) || (scProductEntryListeners.length > 0)) {
2973 scProductEntries = getSCProductEntries(licenseId);
2974
2975 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2976 for (ModelListener<SCLicense> listener : listeners) {
2977 listener.onBeforeRemoveAssociation(licenseId,
2978 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2979 scProductEntry.getPrimaryKey());
2980 }
2981
2982 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2983 listener.onBeforeRemoveAssociation(scProductEntry.getPrimaryKey(),
2984 SCLicense.class.getName(), licenseId);
2985 }
2986 }
2987 }
2988
2989 _sqlUpdate.update(new Object[] { new Long(licenseId) });
2990
2991 if ((listeners.length > 0) || (scProductEntryListeners.length > 0)) {
2992 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2993 for (ModelListener<SCLicense> listener : listeners) {
2994 listener.onAfterRemoveAssociation(licenseId,
2995 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2996 scProductEntry.getPrimaryKey());
2997 }
2998
2999 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
3000 listener.onAfterRemoveAssociation(scProductEntry.getPrimaryKey(),
3001 SCLicense.class.getName(), licenseId);
3002 }
3003 }
3004 }
3005 }
3006
3007 private SqlUpdate _sqlUpdate;
3008 }
3009
3010 protected class RemoveSCProductEntry {
3011 protected RemoveSCProductEntry() {
3012 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3013 "DELETE FROM SCLicenses_SCProductEntries WHERE licenseId = ? AND productEntryId = ?",
3014 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3015 }
3016
3017 protected void remove(long licenseId, long productEntryId)
3018 throws SystemException {
3019 if (containsSCProductEntry.contains(licenseId, productEntryId)) {
3020 ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry>[] scProductEntryListeners =
3021 scProductEntryPersistence.getListeners();
3022
3023 for (ModelListener<SCLicense> listener : listeners) {
3024 listener.onBeforeRemoveAssociation(licenseId,
3025 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
3026 productEntryId);
3027 }
3028
3029 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
3030 listener.onBeforeRemoveAssociation(productEntryId,
3031 SCLicense.class.getName(), licenseId);
3032 }
3033
3034 _sqlUpdate.update(new Object[] {
3035 new Long(licenseId), new Long(productEntryId)
3036 });
3037
3038 for (ModelListener<SCLicense> listener : listeners) {
3039 listener.onAfterRemoveAssociation(licenseId,
3040 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
3041 productEntryId);
3042 }
3043
3044 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
3045 listener.onAfterRemoveAssociation(productEntryId,
3046 SCLicense.class.getName(), licenseId);
3047 }
3048 }
3049 }
3050
3051 private SqlUpdate _sqlUpdate;
3052 }
3053
3054 private static final String _SQL_SELECT_SCLICENSE = "SELECT scLicense FROM SCLicense scLicense";
3055 private static final String _SQL_SELECT_SCLICENSE_WHERE = "SELECT scLicense FROM SCLicense scLicense WHERE ";
3056 private static final String _SQL_COUNT_SCLICENSE = "SELECT COUNT(scLicense) FROM SCLicense scLicense";
3057 private static final String _SQL_COUNT_SCLICENSE_WHERE = "SELECT COUNT(scLicense) FROM SCLicense scLicense WHERE ";
3058 private static final String _SQL_GETSCPRODUCTENTRIES = "SELECT {SCProductEntry.*} FROM SCProductEntry INNER JOIN SCLicenses_SCProductEntries ON (SCLicenses_SCProductEntries.productEntryId = SCProductEntry.productEntryId) WHERE (SCLicenses_SCProductEntries.licenseId = ?)";
3059 private static final String _SQL_GETSCPRODUCTENTRIESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE licenseId = ?";
3060 private static final String _SQL_CONTAINSSCPRODUCTENTRY = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE licenseId = ? AND productEntryId = ?";
3061 private static final String _FINDER_COLUMN_ACTIVE_ACTIVE_2 = "scLicense.active = ?";
3062 private static final String _FINDER_COLUMN_A_R_ACTIVE_2 = "scLicense.active = ? AND ";
3063 private static final String _FINDER_COLUMN_A_R_RECOMMENDED_2 = "scLicense.recommended = ?";
3064 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "scLicense.licenseId";
3065 private static final String _FILTER_SQL_SELECT_SCLICENSE_WHERE = "SELECT DISTINCT {scLicense.*} FROM SCLicense scLicense WHERE ";
3066 private static final String _FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1 =
3067 "SELECT {SCLicense.*} FROM (SELECT DISTINCT scLicense.licenseId FROM SCLicense scLicense WHERE ";
3068 private static final String _FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2 =
3069 ") TEMP_TABLE INNER JOIN SCLicense ON TEMP_TABLE.licenseId = SCLicense.licenseId";
3070 private static final String _FILTER_SQL_COUNT_SCLICENSE_WHERE = "SELECT COUNT(DISTINCT scLicense.licenseId) AS COUNT_VALUE FROM SCLicense scLicense WHERE ";
3071 private static final String _FILTER_ENTITY_ALIAS = "scLicense";
3072 private static final String _FILTER_ENTITY_TABLE = "SCLicense";
3073 private static final String _ORDER_BY_ENTITY_ALIAS = "scLicense.";
3074 private static final String _ORDER_BY_ENTITY_TABLE = "SCLicense.";
3075 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SCLicense exists with the primary key ";
3076 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SCLicense exists with the key {";
3077 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3078 private static Log _log = LogFactoryUtil.getLog(SCLicensePersistenceImpl.class);
3079 private static SCLicense _nullSCLicense = new SCLicenseImpl() {
3080 @Override
3081 public Object clone() {
3082 return this;
3083 }
3084
3085 @Override
3086 public CacheModel<SCLicense> toCacheModel() {
3087 return _nullSCLicenseCacheModel;
3088 }
3089 };
3090
3091 private static CacheModel<SCLicense> _nullSCLicenseCacheModel = new CacheModel<SCLicense>() {
3092 public SCLicense toEntityModel() {
3093 return _nullSCLicense;
3094 }
3095 };
3096 }