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.BatchSessionUtil;
047 import com.liferay.portal.service.persistence.ResourcePersistence;
048 import com.liferay.portal.service.persistence.UserPersistence;
049 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
050
051 import com.liferay.portlet.softwarecatalog.NoSuchLicenseException;
052 import com.liferay.portlet.softwarecatalog.model.SCLicense;
053 import com.liferay.portlet.softwarecatalog.model.impl.SCLicenseImpl;
054 import com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl;
055
056 import java.io.Serializable;
057
058 import java.util.ArrayList;
059 import java.util.Collections;
060 import java.util.List;
061 import java.util.Set;
062
063
075 public class SCLicensePersistenceImpl extends BasePersistenceImpl<SCLicense>
076 implements SCLicensePersistence {
077
082 public static final String FINDER_CLASS_NAME_ENTITY = SCLicenseImpl.class.getName();
083 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
084 ".List1";
085 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
086 ".List2";
087 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_ACTIVE = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
088 SCLicenseModelImpl.FINDER_CACHE_ENABLED, SCLicenseImpl.class,
089 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByActive",
090 new String[] {
091 Boolean.class.getName(),
092
093 "java.lang.Integer", "java.lang.Integer",
094 "com.liferay.portal.kernel.util.OrderByComparator"
095 });
096 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE =
097 new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
098 SCLicenseModelImpl.FINDER_CACHE_ENABLED, SCLicenseImpl.class,
099 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByActive",
100 new String[] { Boolean.class.getName() },
101 SCLicenseModelImpl.ACTIVE_COLUMN_BITMASK);
102 public static final FinderPath FINDER_PATH_COUNT_BY_ACTIVE = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
103 SCLicenseModelImpl.FINDER_CACHE_ENABLED, Long.class,
104 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByActive",
105 new String[] { Boolean.class.getName() });
106 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_A_R = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
107 SCLicenseModelImpl.FINDER_CACHE_ENABLED, SCLicenseImpl.class,
108 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByA_R",
109 new String[] {
110 Boolean.class.getName(), Boolean.class.getName(),
111
112 "java.lang.Integer", "java.lang.Integer",
113 "com.liferay.portal.kernel.util.OrderByComparator"
114 });
115 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_A_R = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
116 SCLicenseModelImpl.FINDER_CACHE_ENABLED, SCLicenseImpl.class,
117 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByA_R",
118 new String[] { Boolean.class.getName(), Boolean.class.getName() },
119 SCLicenseModelImpl.ACTIVE_COLUMN_BITMASK |
120 SCLicenseModelImpl.RECOMMENDED_COLUMN_BITMASK);
121 public static final FinderPath FINDER_PATH_COUNT_BY_A_R = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
122 SCLicenseModelImpl.FINDER_CACHE_ENABLED, Long.class,
123 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByA_R",
124 new String[] { Boolean.class.getName(), Boolean.class.getName() });
125 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
126 SCLicenseModelImpl.FINDER_CACHE_ENABLED, SCLicenseImpl.class,
127 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
128 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
129 SCLicenseModelImpl.FINDER_CACHE_ENABLED, SCLicenseImpl.class,
130 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
131 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
132 SCLicenseModelImpl.FINDER_CACHE_ENABLED, Long.class,
133 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
134
135
140 public void cacheResult(SCLicense scLicense) {
141 EntityCacheUtil.putResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
142 SCLicenseImpl.class, scLicense.getPrimaryKey(), scLicense);
143
144 scLicense.resetOriginalValues();
145 }
146
147
152 public void cacheResult(List<SCLicense> scLicenses) {
153 for (SCLicense scLicense : scLicenses) {
154 if (EntityCacheUtil.getResult(
155 SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
156 SCLicenseImpl.class, scLicense.getPrimaryKey()) == null) {
157 cacheResult(scLicense);
158 }
159 else {
160 scLicense.resetOriginalValues();
161 }
162 }
163 }
164
165
172 @Override
173 public void clearCache() {
174 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
175 CacheRegistryUtil.clear(SCLicenseImpl.class.getName());
176 }
177
178 EntityCacheUtil.clearCache(SCLicenseImpl.class.getName());
179
180 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
181 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
182 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
183 }
184
185
192 @Override
193 public void clearCache(SCLicense scLicense) {
194 EntityCacheUtil.removeResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
195 SCLicenseImpl.class, scLicense.getPrimaryKey());
196
197 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
198 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
199 }
200
201
207 public SCLicense create(long licenseId) {
208 SCLicense scLicense = new SCLicenseImpl();
209
210 scLicense.setNew(true);
211 scLicense.setPrimaryKey(licenseId);
212
213 return scLicense;
214 }
215
216
224 @Override
225 public SCLicense remove(Serializable primaryKey)
226 throws NoSuchModelException, SystemException {
227 return remove(((Long)primaryKey).longValue());
228 }
229
230
238 public SCLicense remove(long licenseId)
239 throws NoSuchLicenseException, SystemException {
240 Session session = null;
241
242 try {
243 session = openSession();
244
245 SCLicense scLicense = (SCLicense)session.get(SCLicenseImpl.class,
246 Long.valueOf(licenseId));
247
248 if (scLicense == null) {
249 if (_log.isWarnEnabled()) {
250 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + licenseId);
251 }
252
253 throw new NoSuchLicenseException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
254 licenseId);
255 }
256
257 return scLicensePersistence.remove(scLicense);
258 }
259 catch (NoSuchLicenseException nsee) {
260 throw nsee;
261 }
262 catch (Exception e) {
263 throw processException(e);
264 }
265 finally {
266 closeSession(session);
267 }
268 }
269
270
277 @Override
278 public SCLicense remove(SCLicense scLicense) throws SystemException {
279 return super.remove(scLicense);
280 }
281
282 @Override
283 protected SCLicense removeImpl(SCLicense scLicense)
284 throws SystemException {
285 scLicense = toUnwrappedModel(scLicense);
286
287 try {
288 clearSCProductEntries.clear(scLicense.getPrimaryKey());
289 }
290 catch (Exception e) {
291 throw processException(e);
292 }
293 finally {
294 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
295 }
296
297 Session session = null;
298
299 try {
300 session = openSession();
301
302 BatchSessionUtil.delete(session, scLicense);
303 }
304 catch (Exception e) {
305 throw processException(e);
306 }
307 finally {
308 closeSession(session);
309 }
310
311 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
312 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
313
314 EntityCacheUtil.removeResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
315 SCLicenseImpl.class, scLicense.getPrimaryKey());
316
317 return scLicense;
318 }
319
320 @Override
321 public SCLicense updateImpl(
322 com.liferay.portlet.softwarecatalog.model.SCLicense scLicense,
323 boolean merge) throws SystemException {
324 scLicense = toUnwrappedModel(scLicense);
325
326 boolean isNew = scLicense.isNew();
327
328 SCLicenseModelImpl scLicenseModelImpl = (SCLicenseModelImpl)scLicense;
329
330 Session session = null;
331
332 try {
333 session = openSession();
334
335 BatchSessionUtil.update(session, scLicense, merge);
336
337 scLicense.setNew(false);
338 }
339 catch (Exception e) {
340 throw processException(e);
341 }
342 finally {
343 closeSession(session);
344 }
345
346 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
347
348 if (isNew || !SCLicenseModelImpl.COLUMN_BITMASK_ENABLED) {
349 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
350 }
351
352 else {
353 if ((scLicenseModelImpl.getColumnBitmask() &
354 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE.getColumnBitmask()) != 0) {
355 Object[] args = new Object[] {
356 Boolean.valueOf(scLicenseModelImpl.getOriginalActive())
357 };
358
359 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ACTIVE, args);
360 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE,
361 args);
362
363 args = new Object[] {
364 Boolean.valueOf(scLicenseModelImpl.getActive())
365 };
366
367 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ACTIVE, args);
368 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE,
369 args);
370 }
371
372 if ((scLicenseModelImpl.getColumnBitmask() &
373 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_A_R.getColumnBitmask()) != 0) {
374 Object[] args = new Object[] {
375 Boolean.valueOf(scLicenseModelImpl.getOriginalActive()),
376 Boolean.valueOf(scLicenseModelImpl.getOriginalRecommended())
377 };
378
379 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_A_R, args);
380 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_A_R,
381 args);
382
383 args = new Object[] {
384 Boolean.valueOf(scLicenseModelImpl.getActive()),
385 Boolean.valueOf(scLicenseModelImpl.getRecommended())
386 };
387
388 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_A_R, args);
389 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_A_R,
390 args);
391 }
392 }
393
394 EntityCacheUtil.putResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
395 SCLicenseImpl.class, scLicense.getPrimaryKey(), scLicense);
396
397 return scLicense;
398 }
399
400 protected SCLicense toUnwrappedModel(SCLicense scLicense) {
401 if (scLicense instanceof SCLicenseImpl) {
402 return scLicense;
403 }
404
405 SCLicenseImpl scLicenseImpl = new SCLicenseImpl();
406
407 scLicenseImpl.setNew(scLicense.isNew());
408 scLicenseImpl.setPrimaryKey(scLicense.getPrimaryKey());
409
410 scLicenseImpl.setLicenseId(scLicense.getLicenseId());
411 scLicenseImpl.setName(scLicense.getName());
412 scLicenseImpl.setUrl(scLicense.getUrl());
413 scLicenseImpl.setOpenSource(scLicense.isOpenSource());
414 scLicenseImpl.setActive(scLicense.isActive());
415 scLicenseImpl.setRecommended(scLicense.isRecommended());
416
417 return scLicenseImpl;
418 }
419
420
428 @Override
429 public SCLicense findByPrimaryKey(Serializable primaryKey)
430 throws NoSuchModelException, SystemException {
431 return findByPrimaryKey(((Long)primaryKey).longValue());
432 }
433
434
442 public SCLicense findByPrimaryKey(long licenseId)
443 throws NoSuchLicenseException, SystemException {
444 SCLicense scLicense = fetchByPrimaryKey(licenseId);
445
446 if (scLicense == null) {
447 if (_log.isWarnEnabled()) {
448 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + licenseId);
449 }
450
451 throw new NoSuchLicenseException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
452 licenseId);
453 }
454
455 return scLicense;
456 }
457
458
465 @Override
466 public SCLicense fetchByPrimaryKey(Serializable primaryKey)
467 throws SystemException {
468 return fetchByPrimaryKey(((Long)primaryKey).longValue());
469 }
470
471
478 public SCLicense fetchByPrimaryKey(long licenseId)
479 throws SystemException {
480 SCLicense scLicense = (SCLicense)EntityCacheUtil.getResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
481 SCLicenseImpl.class, licenseId);
482
483 if (scLicense == _nullSCLicense) {
484 return null;
485 }
486
487 if (scLicense == null) {
488 Session session = null;
489
490 boolean hasException = false;
491
492 try {
493 session = openSession();
494
495 scLicense = (SCLicense)session.get(SCLicenseImpl.class,
496 Long.valueOf(licenseId));
497 }
498 catch (Exception e) {
499 hasException = true;
500
501 throw processException(e);
502 }
503 finally {
504 if (scLicense != null) {
505 cacheResult(scLicense);
506 }
507 else if (!hasException) {
508 EntityCacheUtil.putResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
509 SCLicenseImpl.class, licenseId, _nullSCLicense);
510 }
511
512 closeSession(session);
513 }
514 }
515
516 return scLicense;
517 }
518
519
526 public List<SCLicense> findByActive(boolean active)
527 throws SystemException {
528 return findByActive(active, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
529 }
530
531
544 public List<SCLicense> findByActive(boolean active, int start, int end)
545 throws SystemException {
546 return findByActive(active, start, end, null);
547 }
548
549
563 public List<SCLicense> findByActive(boolean active, int start, int end,
564 OrderByComparator orderByComparator) throws SystemException {
565 FinderPath finderPath = null;
566 Object[] finderArgs = null;
567
568 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
569 (orderByComparator == null)) {
570 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE;
571 finderArgs = new Object[] { active };
572 }
573 else {
574 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_ACTIVE;
575 finderArgs = new Object[] { active, start, end, orderByComparator };
576 }
577
578 List<SCLicense> list = (List<SCLicense>)FinderCacheUtil.getResult(finderPath,
579 finderArgs, this);
580
581 if (list == null) {
582 StringBundler query = null;
583
584 if (orderByComparator != null) {
585 query = new StringBundler(3 +
586 (orderByComparator.getOrderByFields().length * 3));
587 }
588 else {
589 query = new StringBundler(3);
590 }
591
592 query.append(_SQL_SELECT_SCLICENSE_WHERE);
593
594 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
595
596 if (orderByComparator != null) {
597 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
598 orderByComparator);
599 }
600
601 else {
602 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
603 }
604
605 String sql = query.toString();
606
607 Session session = null;
608
609 try {
610 session = openSession();
611
612 Query q = session.createQuery(sql);
613
614 QueryPos qPos = QueryPos.getInstance(q);
615
616 qPos.add(active);
617
618 list = (List<SCLicense>)QueryUtil.list(q, getDialect(), start,
619 end);
620 }
621 catch (Exception e) {
622 throw processException(e);
623 }
624 finally {
625 if (list == null) {
626 FinderCacheUtil.removeResult(finderPath, finderArgs);
627 }
628 else {
629 cacheResult(list);
630
631 FinderCacheUtil.putResult(finderPath, finderArgs, list);
632 }
633
634 closeSession(session);
635 }
636 }
637
638 return list;
639 }
640
641
654 public SCLicense findByActive_First(boolean active,
655 OrderByComparator orderByComparator)
656 throws NoSuchLicenseException, SystemException {
657 List<SCLicense> list = findByActive(active, 0, 1, orderByComparator);
658
659 if (list.isEmpty()) {
660 StringBundler msg = new StringBundler(4);
661
662 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
663
664 msg.append("active=");
665 msg.append(active);
666
667 msg.append(StringPool.CLOSE_CURLY_BRACE);
668
669 throw new NoSuchLicenseException(msg.toString());
670 }
671 else {
672 return list.get(0);
673 }
674 }
675
676
689 public SCLicense findByActive_Last(boolean active,
690 OrderByComparator orderByComparator)
691 throws NoSuchLicenseException, SystemException {
692 int count = countByActive(active);
693
694 List<SCLicense> list = findByActive(active, count - 1, count,
695 orderByComparator);
696
697 if (list.isEmpty()) {
698 StringBundler msg = new StringBundler(4);
699
700 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
701
702 msg.append("active=");
703 msg.append(active);
704
705 msg.append(StringPool.CLOSE_CURLY_BRACE);
706
707 throw new NoSuchLicenseException(msg.toString());
708 }
709 else {
710 return list.get(0);
711 }
712 }
713
714
728 public SCLicense[] findByActive_PrevAndNext(long licenseId, boolean active,
729 OrderByComparator orderByComparator)
730 throws NoSuchLicenseException, SystemException {
731 SCLicense scLicense = findByPrimaryKey(licenseId);
732
733 Session session = null;
734
735 try {
736 session = openSession();
737
738 SCLicense[] array = new SCLicenseImpl[3];
739
740 array[0] = getByActive_PrevAndNext(session, scLicense, active,
741 orderByComparator, true);
742
743 array[1] = scLicense;
744
745 array[2] = getByActive_PrevAndNext(session, scLicense, active,
746 orderByComparator, false);
747
748 return array;
749 }
750 catch (Exception e) {
751 throw processException(e);
752 }
753 finally {
754 closeSession(session);
755 }
756 }
757
758 protected SCLicense getByActive_PrevAndNext(Session session,
759 SCLicense scLicense, boolean active,
760 OrderByComparator orderByComparator, boolean previous) {
761 StringBundler query = null;
762
763 if (orderByComparator != null) {
764 query = new StringBundler(6 +
765 (orderByComparator.getOrderByFields().length * 6));
766 }
767 else {
768 query = new StringBundler(3);
769 }
770
771 query.append(_SQL_SELECT_SCLICENSE_WHERE);
772
773 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
774
775 if (orderByComparator != null) {
776 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
777
778 if (orderByConditionFields.length > 0) {
779 query.append(WHERE_AND);
780 }
781
782 for (int i = 0; i < orderByConditionFields.length; i++) {
783 query.append(_ORDER_BY_ENTITY_ALIAS);
784 query.append(orderByConditionFields[i]);
785
786 if ((i + 1) < orderByConditionFields.length) {
787 if (orderByComparator.isAscending() ^ previous) {
788 query.append(WHERE_GREATER_THAN_HAS_NEXT);
789 }
790 else {
791 query.append(WHERE_LESSER_THAN_HAS_NEXT);
792 }
793 }
794 else {
795 if (orderByComparator.isAscending() ^ previous) {
796 query.append(WHERE_GREATER_THAN);
797 }
798 else {
799 query.append(WHERE_LESSER_THAN);
800 }
801 }
802 }
803
804 query.append(ORDER_BY_CLAUSE);
805
806 String[] orderByFields = orderByComparator.getOrderByFields();
807
808 for (int i = 0; i < orderByFields.length; i++) {
809 query.append(_ORDER_BY_ENTITY_ALIAS);
810 query.append(orderByFields[i]);
811
812 if ((i + 1) < orderByFields.length) {
813 if (orderByComparator.isAscending() ^ previous) {
814 query.append(ORDER_BY_ASC_HAS_NEXT);
815 }
816 else {
817 query.append(ORDER_BY_DESC_HAS_NEXT);
818 }
819 }
820 else {
821 if (orderByComparator.isAscending() ^ previous) {
822 query.append(ORDER_BY_ASC);
823 }
824 else {
825 query.append(ORDER_BY_DESC);
826 }
827 }
828 }
829 }
830
831 else {
832 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
833 }
834
835 String sql = query.toString();
836
837 Query q = session.createQuery(sql);
838
839 q.setFirstResult(0);
840 q.setMaxResults(2);
841
842 QueryPos qPos = QueryPos.getInstance(q);
843
844 qPos.add(active);
845
846 if (orderByComparator != null) {
847 Object[] values = orderByComparator.getOrderByConditionValues(scLicense);
848
849 for (Object value : values) {
850 qPos.add(value);
851 }
852 }
853
854 List<SCLicense> list = q.list();
855
856 if (list.size() == 2) {
857 return list.get(1);
858 }
859 else {
860 return null;
861 }
862 }
863
864
871 public List<SCLicense> filterFindByActive(boolean active)
872 throws SystemException {
873 return filterFindByActive(active, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
874 null);
875 }
876
877
890 public List<SCLicense> filterFindByActive(boolean active, int start, int end)
891 throws SystemException {
892 return filterFindByActive(active, start, end, null);
893 }
894
895
909 public List<SCLicense> filterFindByActive(boolean active, int start,
910 int end, OrderByComparator orderByComparator) throws SystemException {
911 if (!InlineSQLHelperUtil.isEnabled()) {
912 return findByActive(active, start, end, orderByComparator);
913 }
914
915 StringBundler query = null;
916
917 if (orderByComparator != null) {
918 query = new StringBundler(3 +
919 (orderByComparator.getOrderByFields().length * 3));
920 }
921 else {
922 query = new StringBundler(3);
923 }
924
925 if (getDB().isSupportsInlineDistinct()) {
926 query.append(_FILTER_SQL_SELECT_SCLICENSE_WHERE);
927 }
928 else {
929 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1);
930 }
931
932 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
933
934 if (!getDB().isSupportsInlineDistinct()) {
935 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2);
936 }
937
938 if (orderByComparator != null) {
939 if (getDB().isSupportsInlineDistinct()) {
940 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
941 orderByComparator);
942 }
943 else {
944 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
945 orderByComparator);
946 }
947 }
948
949 else {
950 if (getDB().isSupportsInlineDistinct()) {
951 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
952 }
953 else {
954 query.append(SCLicenseModelImpl.ORDER_BY_SQL);
955 }
956 }
957
958 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
959 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
960
961 Session session = null;
962
963 try {
964 session = openSession();
965
966 SQLQuery q = session.createSQLQuery(sql);
967
968 if (getDB().isSupportsInlineDistinct()) {
969 q.addEntity(_FILTER_ENTITY_ALIAS, SCLicenseImpl.class);
970 }
971 else {
972 q.addEntity(_FILTER_ENTITY_TABLE, SCLicenseImpl.class);
973 }
974
975 QueryPos qPos = QueryPos.getInstance(q);
976
977 qPos.add(active);
978
979 return (List<SCLicense>)QueryUtil.list(q, getDialect(), start, end);
980 }
981 catch (Exception e) {
982 throw processException(e);
983 }
984 finally {
985 closeSession(session);
986 }
987 }
988
989
999 public SCLicense[] filterFindByActive_PrevAndNext(long licenseId,
1000 boolean active, OrderByComparator orderByComparator)
1001 throws NoSuchLicenseException, SystemException {
1002 if (!InlineSQLHelperUtil.isEnabled()) {
1003 return findByActive_PrevAndNext(licenseId, active, orderByComparator);
1004 }
1005
1006 SCLicense scLicense = findByPrimaryKey(licenseId);
1007
1008 Session session = null;
1009
1010 try {
1011 session = openSession();
1012
1013 SCLicense[] array = new SCLicenseImpl[3];
1014
1015 array[0] = filterGetByActive_PrevAndNext(session, scLicense,
1016 active, orderByComparator, true);
1017
1018 array[1] = scLicense;
1019
1020 array[2] = filterGetByActive_PrevAndNext(session, scLicense,
1021 active, orderByComparator, false);
1022
1023 return array;
1024 }
1025 catch (Exception e) {
1026 throw processException(e);
1027 }
1028 finally {
1029 closeSession(session);
1030 }
1031 }
1032
1033 protected SCLicense filterGetByActive_PrevAndNext(Session session,
1034 SCLicense scLicense, boolean active,
1035 OrderByComparator orderByComparator, boolean previous) {
1036 StringBundler query = null;
1037
1038 if (orderByComparator != null) {
1039 query = new StringBundler(6 +
1040 (orderByComparator.getOrderByFields().length * 6));
1041 }
1042 else {
1043 query = new StringBundler(3);
1044 }
1045
1046 if (getDB().isSupportsInlineDistinct()) {
1047 query.append(_FILTER_SQL_SELECT_SCLICENSE_WHERE);
1048 }
1049 else {
1050 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1);
1051 }
1052
1053 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
1054
1055 if (!getDB().isSupportsInlineDistinct()) {
1056 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2);
1057 }
1058
1059 if (orderByComparator != null) {
1060 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1061
1062 if (orderByConditionFields.length > 0) {
1063 query.append(WHERE_AND);
1064 }
1065
1066 for (int i = 0; i < orderByConditionFields.length; i++) {
1067 if (getDB().isSupportsInlineDistinct()) {
1068 query.append(_ORDER_BY_ENTITY_ALIAS);
1069 }
1070 else {
1071 query.append(_ORDER_BY_ENTITY_TABLE);
1072 }
1073
1074 query.append(orderByConditionFields[i]);
1075
1076 if ((i + 1) < orderByConditionFields.length) {
1077 if (orderByComparator.isAscending() ^ previous) {
1078 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1079 }
1080 else {
1081 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1082 }
1083 }
1084 else {
1085 if (orderByComparator.isAscending() ^ previous) {
1086 query.append(WHERE_GREATER_THAN);
1087 }
1088 else {
1089 query.append(WHERE_LESSER_THAN);
1090 }
1091 }
1092 }
1093
1094 query.append(ORDER_BY_CLAUSE);
1095
1096 String[] orderByFields = orderByComparator.getOrderByFields();
1097
1098 for (int i = 0; i < orderByFields.length; i++) {
1099 if (getDB().isSupportsInlineDistinct()) {
1100 query.append(_ORDER_BY_ENTITY_ALIAS);
1101 }
1102 else {
1103 query.append(_ORDER_BY_ENTITY_TABLE);
1104 }
1105
1106 query.append(orderByFields[i]);
1107
1108 if ((i + 1) < orderByFields.length) {
1109 if (orderByComparator.isAscending() ^ previous) {
1110 query.append(ORDER_BY_ASC_HAS_NEXT);
1111 }
1112 else {
1113 query.append(ORDER_BY_DESC_HAS_NEXT);
1114 }
1115 }
1116 else {
1117 if (orderByComparator.isAscending() ^ previous) {
1118 query.append(ORDER_BY_ASC);
1119 }
1120 else {
1121 query.append(ORDER_BY_DESC);
1122 }
1123 }
1124 }
1125 }
1126
1127 else {
1128 if (getDB().isSupportsInlineDistinct()) {
1129 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1130 }
1131 else {
1132 query.append(SCLicenseModelImpl.ORDER_BY_SQL);
1133 }
1134 }
1135
1136 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1137 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1138
1139 SQLQuery q = session.createSQLQuery(sql);
1140
1141 q.setFirstResult(0);
1142 q.setMaxResults(2);
1143
1144 if (getDB().isSupportsInlineDistinct()) {
1145 q.addEntity(_FILTER_ENTITY_ALIAS, SCLicenseImpl.class);
1146 }
1147 else {
1148 q.addEntity(_FILTER_ENTITY_TABLE, SCLicenseImpl.class);
1149 }
1150
1151 QueryPos qPos = QueryPos.getInstance(q);
1152
1153 qPos.add(active);
1154
1155 if (orderByComparator != null) {
1156 Object[] values = orderByComparator.getOrderByConditionValues(scLicense);
1157
1158 for (Object value : values) {
1159 qPos.add(value);
1160 }
1161 }
1162
1163 List<SCLicense> list = q.list();
1164
1165 if (list.size() == 2) {
1166 return list.get(1);
1167 }
1168 else {
1169 return null;
1170 }
1171 }
1172
1173
1181 public List<SCLicense> findByA_R(boolean active, boolean recommended)
1182 throws SystemException {
1183 return findByA_R(active, recommended, QueryUtil.ALL_POS,
1184 QueryUtil.ALL_POS, null);
1185 }
1186
1187
1201 public List<SCLicense> findByA_R(boolean active, boolean recommended,
1202 int start, int end) throws SystemException {
1203 return findByA_R(active, recommended, start, end, null);
1204 }
1205
1206
1221 public List<SCLicense> findByA_R(boolean active, boolean recommended,
1222 int start, int end, OrderByComparator orderByComparator)
1223 throws SystemException {
1224 FinderPath finderPath = null;
1225 Object[] finderArgs = null;
1226
1227 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1228 (orderByComparator == null)) {
1229 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_A_R;
1230 finderArgs = new Object[] { active, recommended };
1231 }
1232 else {
1233 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_A_R;
1234 finderArgs = new Object[] {
1235 active, recommended,
1236
1237 start, end, orderByComparator
1238 };
1239 }
1240
1241 List<SCLicense> list = (List<SCLicense>)FinderCacheUtil.getResult(finderPath,
1242 finderArgs, this);
1243
1244 if (list == null) {
1245 StringBundler query = null;
1246
1247 if (orderByComparator != null) {
1248 query = new StringBundler(4 +
1249 (orderByComparator.getOrderByFields().length * 3));
1250 }
1251 else {
1252 query = new StringBundler(4);
1253 }
1254
1255 query.append(_SQL_SELECT_SCLICENSE_WHERE);
1256
1257 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1258
1259 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1260
1261 if (orderByComparator != null) {
1262 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1263 orderByComparator);
1264 }
1265
1266 else {
1267 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1268 }
1269
1270 String sql = query.toString();
1271
1272 Session session = null;
1273
1274 try {
1275 session = openSession();
1276
1277 Query q = session.createQuery(sql);
1278
1279 QueryPos qPos = QueryPos.getInstance(q);
1280
1281 qPos.add(active);
1282
1283 qPos.add(recommended);
1284
1285 list = (List<SCLicense>)QueryUtil.list(q, getDialect(), start,
1286 end);
1287 }
1288 catch (Exception e) {
1289 throw processException(e);
1290 }
1291 finally {
1292 if (list == null) {
1293 FinderCacheUtil.removeResult(finderPath, finderArgs);
1294 }
1295 else {
1296 cacheResult(list);
1297
1298 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1299 }
1300
1301 closeSession(session);
1302 }
1303 }
1304
1305 return list;
1306 }
1307
1308
1322 public SCLicense findByA_R_First(boolean active, boolean recommended,
1323 OrderByComparator orderByComparator)
1324 throws NoSuchLicenseException, SystemException {
1325 List<SCLicense> list = findByA_R(active, recommended, 0, 1,
1326 orderByComparator);
1327
1328 if (list.isEmpty()) {
1329 StringBundler msg = new StringBundler(6);
1330
1331 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1332
1333 msg.append("active=");
1334 msg.append(active);
1335
1336 msg.append(", recommended=");
1337 msg.append(recommended);
1338
1339 msg.append(StringPool.CLOSE_CURLY_BRACE);
1340
1341 throw new NoSuchLicenseException(msg.toString());
1342 }
1343 else {
1344 return list.get(0);
1345 }
1346 }
1347
1348
1362 public SCLicense findByA_R_Last(boolean active, boolean recommended,
1363 OrderByComparator orderByComparator)
1364 throws NoSuchLicenseException, SystemException {
1365 int count = countByA_R(active, recommended);
1366
1367 List<SCLicense> list = findByA_R(active, recommended, count - 1, count,
1368 orderByComparator);
1369
1370 if (list.isEmpty()) {
1371 StringBundler msg = new StringBundler(6);
1372
1373 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1374
1375 msg.append("active=");
1376 msg.append(active);
1377
1378 msg.append(", recommended=");
1379 msg.append(recommended);
1380
1381 msg.append(StringPool.CLOSE_CURLY_BRACE);
1382
1383 throw new NoSuchLicenseException(msg.toString());
1384 }
1385 else {
1386 return list.get(0);
1387 }
1388 }
1389
1390
1405 public SCLicense[] findByA_R_PrevAndNext(long licenseId, boolean active,
1406 boolean recommended, OrderByComparator orderByComparator)
1407 throws NoSuchLicenseException, SystemException {
1408 SCLicense scLicense = findByPrimaryKey(licenseId);
1409
1410 Session session = null;
1411
1412 try {
1413 session = openSession();
1414
1415 SCLicense[] array = new SCLicenseImpl[3];
1416
1417 array[0] = getByA_R_PrevAndNext(session, scLicense, active,
1418 recommended, orderByComparator, true);
1419
1420 array[1] = scLicense;
1421
1422 array[2] = getByA_R_PrevAndNext(session, scLicense, active,
1423 recommended, orderByComparator, false);
1424
1425 return array;
1426 }
1427 catch (Exception e) {
1428 throw processException(e);
1429 }
1430 finally {
1431 closeSession(session);
1432 }
1433 }
1434
1435 protected SCLicense getByA_R_PrevAndNext(Session session,
1436 SCLicense scLicense, boolean active, boolean recommended,
1437 OrderByComparator orderByComparator, boolean previous) {
1438 StringBundler query = null;
1439
1440 if (orderByComparator != null) {
1441 query = new StringBundler(6 +
1442 (orderByComparator.getOrderByFields().length * 6));
1443 }
1444 else {
1445 query = new StringBundler(3);
1446 }
1447
1448 query.append(_SQL_SELECT_SCLICENSE_WHERE);
1449
1450 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1451
1452 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1453
1454 if (orderByComparator != null) {
1455 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1456
1457 if (orderByConditionFields.length > 0) {
1458 query.append(WHERE_AND);
1459 }
1460
1461 for (int i = 0; i < orderByConditionFields.length; i++) {
1462 query.append(_ORDER_BY_ENTITY_ALIAS);
1463 query.append(orderByConditionFields[i]);
1464
1465 if ((i + 1) < orderByConditionFields.length) {
1466 if (orderByComparator.isAscending() ^ previous) {
1467 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1468 }
1469 else {
1470 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1471 }
1472 }
1473 else {
1474 if (orderByComparator.isAscending() ^ previous) {
1475 query.append(WHERE_GREATER_THAN);
1476 }
1477 else {
1478 query.append(WHERE_LESSER_THAN);
1479 }
1480 }
1481 }
1482
1483 query.append(ORDER_BY_CLAUSE);
1484
1485 String[] orderByFields = orderByComparator.getOrderByFields();
1486
1487 for (int i = 0; i < orderByFields.length; i++) {
1488 query.append(_ORDER_BY_ENTITY_ALIAS);
1489 query.append(orderByFields[i]);
1490
1491 if ((i + 1) < orderByFields.length) {
1492 if (orderByComparator.isAscending() ^ previous) {
1493 query.append(ORDER_BY_ASC_HAS_NEXT);
1494 }
1495 else {
1496 query.append(ORDER_BY_DESC_HAS_NEXT);
1497 }
1498 }
1499 else {
1500 if (orderByComparator.isAscending() ^ previous) {
1501 query.append(ORDER_BY_ASC);
1502 }
1503 else {
1504 query.append(ORDER_BY_DESC);
1505 }
1506 }
1507 }
1508 }
1509
1510 else {
1511 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1512 }
1513
1514 String sql = query.toString();
1515
1516 Query q = session.createQuery(sql);
1517
1518 q.setFirstResult(0);
1519 q.setMaxResults(2);
1520
1521 QueryPos qPos = QueryPos.getInstance(q);
1522
1523 qPos.add(active);
1524
1525 qPos.add(recommended);
1526
1527 if (orderByComparator != null) {
1528 Object[] values = orderByComparator.getOrderByConditionValues(scLicense);
1529
1530 for (Object value : values) {
1531 qPos.add(value);
1532 }
1533 }
1534
1535 List<SCLicense> list = q.list();
1536
1537 if (list.size() == 2) {
1538 return list.get(1);
1539 }
1540 else {
1541 return null;
1542 }
1543 }
1544
1545
1553 public List<SCLicense> filterFindByA_R(boolean active, boolean recommended)
1554 throws SystemException {
1555 return filterFindByA_R(active, recommended, QueryUtil.ALL_POS,
1556 QueryUtil.ALL_POS, null);
1557 }
1558
1559
1573 public List<SCLicense> filterFindByA_R(boolean active, boolean recommended,
1574 int start, int end) throws SystemException {
1575 return filterFindByA_R(active, recommended, start, end, null);
1576 }
1577
1578
1593 public List<SCLicense> filterFindByA_R(boolean active, boolean recommended,
1594 int start, int end, OrderByComparator orderByComparator)
1595 throws SystemException {
1596 if (!InlineSQLHelperUtil.isEnabled()) {
1597 return findByA_R(active, recommended, start, end, orderByComparator);
1598 }
1599
1600 StringBundler query = null;
1601
1602 if (orderByComparator != null) {
1603 query = new StringBundler(4 +
1604 (orderByComparator.getOrderByFields().length * 3));
1605 }
1606 else {
1607 query = new StringBundler(4);
1608 }
1609
1610 if (getDB().isSupportsInlineDistinct()) {
1611 query.append(_FILTER_SQL_SELECT_SCLICENSE_WHERE);
1612 }
1613 else {
1614 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1);
1615 }
1616
1617 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1618
1619 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1620
1621 if (!getDB().isSupportsInlineDistinct()) {
1622 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2);
1623 }
1624
1625 if (orderByComparator != null) {
1626 if (getDB().isSupportsInlineDistinct()) {
1627 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1628 orderByComparator);
1629 }
1630 else {
1631 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1632 orderByComparator);
1633 }
1634 }
1635
1636 else {
1637 if (getDB().isSupportsInlineDistinct()) {
1638 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1639 }
1640 else {
1641 query.append(SCLicenseModelImpl.ORDER_BY_SQL);
1642 }
1643 }
1644
1645 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1646 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1647
1648 Session session = null;
1649
1650 try {
1651 session = openSession();
1652
1653 SQLQuery q = session.createSQLQuery(sql);
1654
1655 if (getDB().isSupportsInlineDistinct()) {
1656 q.addEntity(_FILTER_ENTITY_ALIAS, SCLicenseImpl.class);
1657 }
1658 else {
1659 q.addEntity(_FILTER_ENTITY_TABLE, SCLicenseImpl.class);
1660 }
1661
1662 QueryPos qPos = QueryPos.getInstance(q);
1663
1664 qPos.add(active);
1665
1666 qPos.add(recommended);
1667
1668 return (List<SCLicense>)QueryUtil.list(q, getDialect(), start, end);
1669 }
1670 catch (Exception e) {
1671 throw processException(e);
1672 }
1673 finally {
1674 closeSession(session);
1675 }
1676 }
1677
1678
1689 public SCLicense[] filterFindByA_R_PrevAndNext(long licenseId,
1690 boolean active, boolean recommended, OrderByComparator orderByComparator)
1691 throws NoSuchLicenseException, SystemException {
1692 if (!InlineSQLHelperUtil.isEnabled()) {
1693 return findByA_R_PrevAndNext(licenseId, active, recommended,
1694 orderByComparator);
1695 }
1696
1697 SCLicense scLicense = findByPrimaryKey(licenseId);
1698
1699 Session session = null;
1700
1701 try {
1702 session = openSession();
1703
1704 SCLicense[] array = new SCLicenseImpl[3];
1705
1706 array[0] = filterGetByA_R_PrevAndNext(session, scLicense, active,
1707 recommended, orderByComparator, true);
1708
1709 array[1] = scLicense;
1710
1711 array[2] = filterGetByA_R_PrevAndNext(session, scLicense, active,
1712 recommended, orderByComparator, false);
1713
1714 return array;
1715 }
1716 catch (Exception e) {
1717 throw processException(e);
1718 }
1719 finally {
1720 closeSession(session);
1721 }
1722 }
1723
1724 protected SCLicense filterGetByA_R_PrevAndNext(Session session,
1725 SCLicense scLicense, boolean active, boolean recommended,
1726 OrderByComparator orderByComparator, boolean previous) {
1727 StringBundler query = null;
1728
1729 if (orderByComparator != null) {
1730 query = new StringBundler(6 +
1731 (orderByComparator.getOrderByFields().length * 6));
1732 }
1733 else {
1734 query = new StringBundler(3);
1735 }
1736
1737 if (getDB().isSupportsInlineDistinct()) {
1738 query.append(_FILTER_SQL_SELECT_SCLICENSE_WHERE);
1739 }
1740 else {
1741 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1);
1742 }
1743
1744 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1745
1746 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1747
1748 if (!getDB().isSupportsInlineDistinct()) {
1749 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2);
1750 }
1751
1752 if (orderByComparator != null) {
1753 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1754
1755 if (orderByConditionFields.length > 0) {
1756 query.append(WHERE_AND);
1757 }
1758
1759 for (int i = 0; i < orderByConditionFields.length; i++) {
1760 if (getDB().isSupportsInlineDistinct()) {
1761 query.append(_ORDER_BY_ENTITY_ALIAS);
1762 }
1763 else {
1764 query.append(_ORDER_BY_ENTITY_TABLE);
1765 }
1766
1767 query.append(orderByConditionFields[i]);
1768
1769 if ((i + 1) < orderByConditionFields.length) {
1770 if (orderByComparator.isAscending() ^ previous) {
1771 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1772 }
1773 else {
1774 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1775 }
1776 }
1777 else {
1778 if (orderByComparator.isAscending() ^ previous) {
1779 query.append(WHERE_GREATER_THAN);
1780 }
1781 else {
1782 query.append(WHERE_LESSER_THAN);
1783 }
1784 }
1785 }
1786
1787 query.append(ORDER_BY_CLAUSE);
1788
1789 String[] orderByFields = orderByComparator.getOrderByFields();
1790
1791 for (int i = 0; i < orderByFields.length; i++) {
1792 if (getDB().isSupportsInlineDistinct()) {
1793 query.append(_ORDER_BY_ENTITY_ALIAS);
1794 }
1795 else {
1796 query.append(_ORDER_BY_ENTITY_TABLE);
1797 }
1798
1799 query.append(orderByFields[i]);
1800
1801 if ((i + 1) < orderByFields.length) {
1802 if (orderByComparator.isAscending() ^ previous) {
1803 query.append(ORDER_BY_ASC_HAS_NEXT);
1804 }
1805 else {
1806 query.append(ORDER_BY_DESC_HAS_NEXT);
1807 }
1808 }
1809 else {
1810 if (orderByComparator.isAscending() ^ previous) {
1811 query.append(ORDER_BY_ASC);
1812 }
1813 else {
1814 query.append(ORDER_BY_DESC);
1815 }
1816 }
1817 }
1818 }
1819
1820 else {
1821 if (getDB().isSupportsInlineDistinct()) {
1822 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1823 }
1824 else {
1825 query.append(SCLicenseModelImpl.ORDER_BY_SQL);
1826 }
1827 }
1828
1829 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1830 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1831
1832 SQLQuery q = session.createSQLQuery(sql);
1833
1834 q.setFirstResult(0);
1835 q.setMaxResults(2);
1836
1837 if (getDB().isSupportsInlineDistinct()) {
1838 q.addEntity(_FILTER_ENTITY_ALIAS, SCLicenseImpl.class);
1839 }
1840 else {
1841 q.addEntity(_FILTER_ENTITY_TABLE, SCLicenseImpl.class);
1842 }
1843
1844 QueryPos qPos = QueryPos.getInstance(q);
1845
1846 qPos.add(active);
1847
1848 qPos.add(recommended);
1849
1850 if (orderByComparator != null) {
1851 Object[] values = orderByComparator.getOrderByConditionValues(scLicense);
1852
1853 for (Object value : values) {
1854 qPos.add(value);
1855 }
1856 }
1857
1858 List<SCLicense> list = q.list();
1859
1860 if (list.size() == 2) {
1861 return list.get(1);
1862 }
1863 else {
1864 return null;
1865 }
1866 }
1867
1868
1874 public List<SCLicense> findAll() throws SystemException {
1875 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1876 }
1877
1878
1890 public List<SCLicense> findAll(int start, int end)
1891 throws SystemException {
1892 return findAll(start, end, null);
1893 }
1894
1895
1908 public List<SCLicense> findAll(int start, int end,
1909 OrderByComparator orderByComparator) throws SystemException {
1910 FinderPath finderPath = null;
1911 Object[] finderArgs = new Object[] { start, end, orderByComparator };
1912
1913 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1914 (orderByComparator == null)) {
1915 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1916 finderArgs = FINDER_ARGS_EMPTY;
1917 }
1918 else {
1919 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1920 finderArgs = new Object[] { start, end, orderByComparator };
1921 }
1922
1923 List<SCLicense> list = (List<SCLicense>)FinderCacheUtil.getResult(finderPath,
1924 finderArgs, this);
1925
1926 if (list == null) {
1927 StringBundler query = null;
1928 String sql = null;
1929
1930 if (orderByComparator != null) {
1931 query = new StringBundler(2 +
1932 (orderByComparator.getOrderByFields().length * 3));
1933
1934 query.append(_SQL_SELECT_SCLICENSE);
1935
1936 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1937 orderByComparator);
1938
1939 sql = query.toString();
1940 }
1941 else {
1942 sql = _SQL_SELECT_SCLICENSE.concat(SCLicenseModelImpl.ORDER_BY_JPQL);
1943 }
1944
1945 Session session = null;
1946
1947 try {
1948 session = openSession();
1949
1950 Query q = session.createQuery(sql);
1951
1952 if (orderByComparator == null) {
1953 list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
1954 start, end, false);
1955
1956 Collections.sort(list);
1957 }
1958 else {
1959 list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
1960 start, end);
1961 }
1962 }
1963 catch (Exception e) {
1964 throw processException(e);
1965 }
1966 finally {
1967 if (list == null) {
1968 FinderCacheUtil.removeResult(finderPath, finderArgs);
1969 }
1970 else {
1971 cacheResult(list);
1972
1973 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1974 }
1975
1976 closeSession(session);
1977 }
1978 }
1979
1980 return list;
1981 }
1982
1983
1989 public void removeByActive(boolean active) throws SystemException {
1990 for (SCLicense scLicense : findByActive(active)) {
1991 scLicensePersistence.remove(scLicense);
1992 }
1993 }
1994
1995
2002 public void removeByA_R(boolean active, boolean recommended)
2003 throws SystemException {
2004 for (SCLicense scLicense : findByA_R(active, recommended)) {
2005 scLicensePersistence.remove(scLicense);
2006 }
2007 }
2008
2009
2014 public void removeAll() throws SystemException {
2015 for (SCLicense scLicense : findAll()) {
2016 scLicensePersistence.remove(scLicense);
2017 }
2018 }
2019
2020
2027 public int countByActive(boolean active) throws SystemException {
2028 Object[] finderArgs = new Object[] { active };
2029
2030 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ACTIVE,
2031 finderArgs, this);
2032
2033 if (count == null) {
2034 StringBundler query = new StringBundler(2);
2035
2036 query.append(_SQL_COUNT_SCLICENSE_WHERE);
2037
2038 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
2039
2040 String sql = query.toString();
2041
2042 Session session = null;
2043
2044 try {
2045 session = openSession();
2046
2047 Query q = session.createQuery(sql);
2048
2049 QueryPos qPos = QueryPos.getInstance(q);
2050
2051 qPos.add(active);
2052
2053 count = (Long)q.uniqueResult();
2054 }
2055 catch (Exception e) {
2056 throw processException(e);
2057 }
2058 finally {
2059 if (count == null) {
2060 count = Long.valueOf(0);
2061 }
2062
2063 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ACTIVE,
2064 finderArgs, count);
2065
2066 closeSession(session);
2067 }
2068 }
2069
2070 return count.intValue();
2071 }
2072
2073
2080 public int filterCountByActive(boolean active) throws SystemException {
2081 if (!InlineSQLHelperUtil.isEnabled()) {
2082 return countByActive(active);
2083 }
2084
2085 StringBundler query = new StringBundler(2);
2086
2087 query.append(_FILTER_SQL_COUNT_SCLICENSE_WHERE);
2088
2089 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
2090
2091 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2092 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2093
2094 Session session = null;
2095
2096 try {
2097 session = openSession();
2098
2099 SQLQuery q = session.createSQLQuery(sql);
2100
2101 q.addScalar(COUNT_COLUMN_NAME,
2102 com.liferay.portal.kernel.dao.orm.Type.LONG);
2103
2104 QueryPos qPos = QueryPos.getInstance(q);
2105
2106 qPos.add(active);
2107
2108 Long count = (Long)q.uniqueResult();
2109
2110 return count.intValue();
2111 }
2112 catch (Exception e) {
2113 throw processException(e);
2114 }
2115 finally {
2116 closeSession(session);
2117 }
2118 }
2119
2120
2128 public int countByA_R(boolean active, boolean recommended)
2129 throws SystemException {
2130 Object[] finderArgs = new Object[] { active, recommended };
2131
2132 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_A_R,
2133 finderArgs, this);
2134
2135 if (count == null) {
2136 StringBundler query = new StringBundler(3);
2137
2138 query.append(_SQL_COUNT_SCLICENSE_WHERE);
2139
2140 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
2141
2142 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
2143
2144 String sql = query.toString();
2145
2146 Session session = null;
2147
2148 try {
2149 session = openSession();
2150
2151 Query q = session.createQuery(sql);
2152
2153 QueryPos qPos = QueryPos.getInstance(q);
2154
2155 qPos.add(active);
2156
2157 qPos.add(recommended);
2158
2159 count = (Long)q.uniqueResult();
2160 }
2161 catch (Exception e) {
2162 throw processException(e);
2163 }
2164 finally {
2165 if (count == null) {
2166 count = Long.valueOf(0);
2167 }
2168
2169 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_A_R, finderArgs,
2170 count);
2171
2172 closeSession(session);
2173 }
2174 }
2175
2176 return count.intValue();
2177 }
2178
2179
2187 public int filterCountByA_R(boolean active, boolean recommended)
2188 throws SystemException {
2189 if (!InlineSQLHelperUtil.isEnabled()) {
2190 return countByA_R(active, recommended);
2191 }
2192
2193 StringBundler query = new StringBundler(3);
2194
2195 query.append(_FILTER_SQL_COUNT_SCLICENSE_WHERE);
2196
2197 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
2198
2199 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
2200
2201 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2202 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2203
2204 Session session = null;
2205
2206 try {
2207 session = openSession();
2208
2209 SQLQuery q = session.createSQLQuery(sql);
2210
2211 q.addScalar(COUNT_COLUMN_NAME,
2212 com.liferay.portal.kernel.dao.orm.Type.LONG);
2213
2214 QueryPos qPos = QueryPos.getInstance(q);
2215
2216 qPos.add(active);
2217
2218 qPos.add(recommended);
2219
2220 Long count = (Long)q.uniqueResult();
2221
2222 return count.intValue();
2223 }
2224 catch (Exception e) {
2225 throw processException(e);
2226 }
2227 finally {
2228 closeSession(session);
2229 }
2230 }
2231
2232
2238 public int countAll() throws SystemException {
2239 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2240 FINDER_ARGS_EMPTY, this);
2241
2242 if (count == null) {
2243 Session session = null;
2244
2245 try {
2246 session = openSession();
2247
2248 Query q = session.createQuery(_SQL_COUNT_SCLICENSE);
2249
2250 count = (Long)q.uniqueResult();
2251 }
2252 catch (Exception e) {
2253 throw processException(e);
2254 }
2255 finally {
2256 if (count == null) {
2257 count = Long.valueOf(0);
2258 }
2259
2260 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2261 FINDER_ARGS_EMPTY, count);
2262
2263 closeSession(session);
2264 }
2265 }
2266
2267 return count.intValue();
2268 }
2269
2270
2277 public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
2278 long pk) throws SystemException {
2279 return getSCProductEntries(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2280 }
2281
2282
2295 public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
2296 long pk, int start, int end) throws SystemException {
2297 return getSCProductEntries(pk, start, end, null);
2298 }
2299
2300 public static final FinderPath FINDER_PATH_GET_SCPRODUCTENTRIES = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
2301 SCLicenseModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
2302 com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryImpl.class,
2303 SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
2304 "getSCProductEntries",
2305 new String[] {
2306 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
2307 "com.liferay.portal.kernel.util.OrderByComparator"
2308 });
2309
2310
2324 public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
2325 long pk, int start, int end, OrderByComparator orderByComparator)
2326 throws SystemException {
2327 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
2328
2329 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> list = (List<com.liferay.portlet.softwarecatalog.model.SCProductEntry>)FinderCacheUtil.getResult(FINDER_PATH_GET_SCPRODUCTENTRIES,
2330 finderArgs, this);
2331
2332 if (list == null) {
2333 Session session = null;
2334
2335 try {
2336 session = openSession();
2337
2338 String sql = null;
2339
2340 if (orderByComparator != null) {
2341 sql = _SQL_GETSCPRODUCTENTRIES.concat(ORDER_BY_CLAUSE)
2342 .concat(orderByComparator.getOrderBy());
2343 }
2344 else {
2345 sql = _SQL_GETSCPRODUCTENTRIES.concat(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ORDER_BY_SQL);
2346 }
2347
2348 SQLQuery q = session.createSQLQuery(sql);
2349
2350 q.addEntity("SCProductEntry",
2351 com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryImpl.class);
2352
2353 QueryPos qPos = QueryPos.getInstance(q);
2354
2355 qPos.add(pk);
2356
2357 list = (List<com.liferay.portlet.softwarecatalog.model.SCProductEntry>)QueryUtil.list(q,
2358 getDialect(), start, end);
2359 }
2360 catch (Exception e) {
2361 throw processException(e);
2362 }
2363 finally {
2364 if (list == null) {
2365 FinderCacheUtil.removeResult(FINDER_PATH_GET_SCPRODUCTENTRIES,
2366 finderArgs);
2367 }
2368 else {
2369 scProductEntryPersistence.cacheResult(list);
2370
2371 FinderCacheUtil.putResult(FINDER_PATH_GET_SCPRODUCTENTRIES,
2372 finderArgs, list);
2373 }
2374
2375 closeSession(session);
2376 }
2377 }
2378
2379 return list;
2380 }
2381
2382 public static final FinderPath FINDER_PATH_GET_SCPRODUCTENTRIES_SIZE = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
2383 SCLicenseModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
2384 Long.class,
2385 SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
2386 "getSCProductEntriesSize", new String[] { Long.class.getName() });
2387
2388
2395 public int getSCProductEntriesSize(long pk) throws SystemException {
2396 Object[] finderArgs = new Object[] { pk };
2397
2398 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_SCPRODUCTENTRIES_SIZE,
2399 finderArgs, this);
2400
2401 if (count == null) {
2402 Session session = null;
2403
2404 try {
2405 session = openSession();
2406
2407 SQLQuery q = session.createSQLQuery(_SQL_GETSCPRODUCTENTRIESSIZE);
2408
2409 q.addScalar(COUNT_COLUMN_NAME,
2410 com.liferay.portal.kernel.dao.orm.Type.LONG);
2411
2412 QueryPos qPos = QueryPos.getInstance(q);
2413
2414 qPos.add(pk);
2415
2416 count = (Long)q.uniqueResult();
2417 }
2418 catch (Exception e) {
2419 throw processException(e);
2420 }
2421 finally {
2422 if (count == null) {
2423 count = Long.valueOf(0);
2424 }
2425
2426 FinderCacheUtil.putResult(FINDER_PATH_GET_SCPRODUCTENTRIES_SIZE,
2427 finderArgs, count);
2428
2429 closeSession(session);
2430 }
2431 }
2432
2433 return count.intValue();
2434 }
2435
2436 public static final FinderPath FINDER_PATH_CONTAINS_SCPRODUCTENTRY = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
2437 SCLicenseModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
2438 Boolean.class,
2439 SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
2440 "containsSCProductEntry",
2441 new String[] { Long.class.getName(), Long.class.getName() });
2442
2443
2451 public boolean containsSCProductEntry(long pk, long scProductEntryPK)
2452 throws SystemException {
2453 Object[] finderArgs = new Object[] { pk, scProductEntryPK };
2454
2455 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_SCPRODUCTENTRY,
2456 finderArgs, this);
2457
2458 if (value == null) {
2459 try {
2460 value = Boolean.valueOf(containsSCProductEntry.contains(pk,
2461 scProductEntryPK));
2462 }
2463 catch (Exception e) {
2464 throw processException(e);
2465 }
2466 finally {
2467 if (value == null) {
2468 value = Boolean.FALSE;
2469 }
2470
2471 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_SCPRODUCTENTRY,
2472 finderArgs, value);
2473 }
2474 }
2475
2476 return value.booleanValue();
2477 }
2478
2479
2486 public boolean containsSCProductEntries(long pk) throws SystemException {
2487 if (getSCProductEntriesSize(pk) > 0) {
2488 return true;
2489 }
2490 else {
2491 return false;
2492 }
2493 }
2494
2495
2502 public void addSCProductEntry(long pk, long scProductEntryPK)
2503 throws SystemException {
2504 try {
2505 addSCProductEntry.add(pk, scProductEntryPK);
2506 }
2507 catch (Exception e) {
2508 throw processException(e);
2509 }
2510 finally {
2511 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2512 }
2513 }
2514
2515
2522 public void addSCProductEntry(long pk,
2523 com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry)
2524 throws SystemException {
2525 try {
2526 addSCProductEntry.add(pk, scProductEntry.getPrimaryKey());
2527 }
2528 catch (Exception e) {
2529 throw processException(e);
2530 }
2531 finally {
2532 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2533 }
2534 }
2535
2536
2543 public void addSCProductEntries(long pk, long[] scProductEntryPKs)
2544 throws SystemException {
2545 try {
2546 for (long scProductEntryPK : scProductEntryPKs) {
2547 addSCProductEntry.add(pk, scProductEntryPK);
2548 }
2549 }
2550 catch (Exception e) {
2551 throw processException(e);
2552 }
2553 finally {
2554 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2555 }
2556 }
2557
2558
2565 public void addSCProductEntries(long pk,
2566 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries)
2567 throws SystemException {
2568 try {
2569 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2570 addSCProductEntry.add(pk, scProductEntry.getPrimaryKey());
2571 }
2572 }
2573 catch (Exception e) {
2574 throw processException(e);
2575 }
2576 finally {
2577 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2578 }
2579 }
2580
2581
2587 public void clearSCProductEntries(long pk) throws SystemException {
2588 try {
2589 clearSCProductEntries.clear(pk);
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 removeSCProductEntry(long pk, long scProductEntryPK)
2607 throws SystemException {
2608 try {
2609 removeSCProductEntry.remove(pk, scProductEntryPK);
2610 }
2611 catch (Exception e) {
2612 throw processException(e);
2613 }
2614 finally {
2615 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2616 }
2617 }
2618
2619
2626 public void removeSCProductEntry(long pk,
2627 com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry)
2628 throws SystemException {
2629 try {
2630 removeSCProductEntry.remove(pk, scProductEntry.getPrimaryKey());
2631 }
2632 catch (Exception e) {
2633 throw processException(e);
2634 }
2635 finally {
2636 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2637 }
2638 }
2639
2640
2647 public void removeSCProductEntries(long pk, long[] scProductEntryPKs)
2648 throws SystemException {
2649 try {
2650 for (long scProductEntryPK : scProductEntryPKs) {
2651 removeSCProductEntry.remove(pk, scProductEntryPK);
2652 }
2653 }
2654 catch (Exception e) {
2655 throw processException(e);
2656 }
2657 finally {
2658 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2659 }
2660 }
2661
2662
2669 public void removeSCProductEntries(long pk,
2670 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries)
2671 throws SystemException {
2672 try {
2673 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2674 removeSCProductEntry.remove(pk, scProductEntry.getPrimaryKey());
2675 }
2676 }
2677 catch (Exception e) {
2678 throw processException(e);
2679 }
2680 finally {
2681 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2682 }
2683 }
2684
2685
2692 public void setSCProductEntries(long pk, long[] scProductEntryPKs)
2693 throws SystemException {
2694 try {
2695 Set<Long> scProductEntryPKSet = SetUtil.fromArray(scProductEntryPKs);
2696
2697 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries =
2698 getSCProductEntries(pk);
2699
2700 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2701 if (!scProductEntryPKSet.remove(scProductEntry.getPrimaryKey())) {
2702 removeSCProductEntry.remove(pk,
2703 scProductEntry.getPrimaryKey());
2704 }
2705 }
2706
2707 for (Long scProductEntryPK : scProductEntryPKSet) {
2708 addSCProductEntry.add(pk, scProductEntryPK);
2709 }
2710 }
2711 catch (Exception e) {
2712 throw processException(e);
2713 }
2714 finally {
2715 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2716 }
2717 }
2718
2719
2726 public void setSCProductEntries(long pk,
2727 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries)
2728 throws SystemException {
2729 try {
2730 long[] scProductEntryPKs = new long[scProductEntries.size()];
2731
2732 for (int i = 0; i < scProductEntries.size(); i++) {
2733 com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry =
2734 scProductEntries.get(i);
2735
2736 scProductEntryPKs[i] = scProductEntry.getPrimaryKey();
2737 }
2738
2739 setSCProductEntries(pk, scProductEntryPKs);
2740 }
2741 catch (Exception e) {
2742 throw processException(e);
2743 }
2744 finally {
2745 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2746 }
2747 }
2748
2749
2752 public void afterPropertiesSet() {
2753 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2754 com.liferay.portal.util.PropsUtil.get(
2755 "value.object.listener.com.liferay.portlet.softwarecatalog.model.SCLicense")));
2756
2757 if (listenerClassNames.length > 0) {
2758 try {
2759 List<ModelListener<SCLicense>> listenersList = new ArrayList<ModelListener<SCLicense>>();
2760
2761 for (String listenerClassName : listenerClassNames) {
2762 listenersList.add((ModelListener<SCLicense>)InstanceFactory.newInstance(
2763 listenerClassName));
2764 }
2765
2766 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2767 }
2768 catch (Exception e) {
2769 _log.error(e);
2770 }
2771 }
2772
2773 containsSCProductEntry = new ContainsSCProductEntry(this);
2774
2775 addSCProductEntry = new AddSCProductEntry(this);
2776 clearSCProductEntries = new ClearSCProductEntries(this);
2777 removeSCProductEntry = new RemoveSCProductEntry(this);
2778 }
2779
2780 public void destroy() {
2781 EntityCacheUtil.removeCache(SCLicenseImpl.class.getName());
2782 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2783 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2784 }
2785
2786 @BeanReference(type = SCFrameworkVersionPersistence.class)
2787 protected SCFrameworkVersionPersistence scFrameworkVersionPersistence;
2788 @BeanReference(type = SCLicensePersistence.class)
2789 protected SCLicensePersistence scLicensePersistence;
2790 @BeanReference(type = SCProductEntryPersistence.class)
2791 protected SCProductEntryPersistence scProductEntryPersistence;
2792 @BeanReference(type = SCProductScreenshotPersistence.class)
2793 protected SCProductScreenshotPersistence scProductScreenshotPersistence;
2794 @BeanReference(type = SCProductVersionPersistence.class)
2795 protected SCProductVersionPersistence scProductVersionPersistence;
2796 @BeanReference(type = ResourcePersistence.class)
2797 protected ResourcePersistence resourcePersistence;
2798 @BeanReference(type = UserPersistence.class)
2799 protected UserPersistence userPersistence;
2800 protected ContainsSCProductEntry containsSCProductEntry;
2801 protected AddSCProductEntry addSCProductEntry;
2802 protected ClearSCProductEntries clearSCProductEntries;
2803 protected RemoveSCProductEntry removeSCProductEntry;
2804
2805 protected class ContainsSCProductEntry {
2806 protected ContainsSCProductEntry(
2807 SCLicensePersistenceImpl persistenceImpl) {
2808 super();
2809
2810 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2811 _SQL_CONTAINSSCPRODUCTENTRY,
2812 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
2813 RowMapper.COUNT);
2814 }
2815
2816 protected boolean contains(long licenseId, long productEntryId) {
2817 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2818 new Long(licenseId), new Long(productEntryId)
2819 });
2820
2821 if (results.size() > 0) {
2822 Integer count = results.get(0);
2823
2824 if (count.intValue() > 0) {
2825 return true;
2826 }
2827 }
2828
2829 return false;
2830 }
2831
2832 private MappingSqlQuery<Integer> _mappingSqlQuery;
2833 }
2834
2835 protected class AddSCProductEntry {
2836 protected AddSCProductEntry(SCLicensePersistenceImpl persistenceImpl) {
2837 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2838 "INSERT INTO SCLicenses_SCProductEntries (licenseId, productEntryId) VALUES (?, ?)",
2839 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2840 _persistenceImpl = persistenceImpl;
2841 }
2842
2843 protected void add(long licenseId, long productEntryId)
2844 throws SystemException {
2845 if (!_persistenceImpl.containsSCProductEntry.contains(licenseId,
2846 productEntryId)) {
2847 ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry>[] scProductEntryListeners =
2848 scProductEntryPersistence.getListeners();
2849
2850 for (ModelListener<SCLicense> listener : listeners) {
2851 listener.onBeforeAddAssociation(licenseId,
2852 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2853 productEntryId);
2854 }
2855
2856 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2857 listener.onBeforeAddAssociation(productEntryId,
2858 SCLicense.class.getName(), licenseId);
2859 }
2860
2861 _sqlUpdate.update(new Object[] {
2862 new Long(licenseId), new Long(productEntryId)
2863 });
2864
2865 for (ModelListener<SCLicense> listener : listeners) {
2866 listener.onAfterAddAssociation(licenseId,
2867 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2868 productEntryId);
2869 }
2870
2871 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2872 listener.onAfterAddAssociation(productEntryId,
2873 SCLicense.class.getName(), licenseId);
2874 }
2875 }
2876 }
2877
2878 private SqlUpdate _sqlUpdate;
2879 private SCLicensePersistenceImpl _persistenceImpl;
2880 }
2881
2882 protected class ClearSCProductEntries {
2883 protected ClearSCProductEntries(
2884 SCLicensePersistenceImpl persistenceImpl) {
2885 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2886 "DELETE FROM SCLicenses_SCProductEntries WHERE licenseId = ?",
2887 new int[] { java.sql.Types.BIGINT });
2888 }
2889
2890 protected void clear(long licenseId) throws SystemException {
2891 ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry>[] scProductEntryListeners =
2892 scProductEntryPersistence.getListeners();
2893
2894 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries =
2895 null;
2896
2897 if ((listeners.length > 0) || (scProductEntryListeners.length > 0)) {
2898 scProductEntries = getSCProductEntries(licenseId);
2899
2900 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2901 for (ModelListener<SCLicense> listener : listeners) {
2902 listener.onBeforeRemoveAssociation(licenseId,
2903 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2904 scProductEntry.getPrimaryKey());
2905 }
2906
2907 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2908 listener.onBeforeRemoveAssociation(scProductEntry.getPrimaryKey(),
2909 SCLicense.class.getName(), licenseId);
2910 }
2911 }
2912 }
2913
2914 _sqlUpdate.update(new Object[] { new Long(licenseId) });
2915
2916 if ((listeners.length > 0) || (scProductEntryListeners.length > 0)) {
2917 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2918 for (ModelListener<SCLicense> listener : listeners) {
2919 listener.onAfterRemoveAssociation(licenseId,
2920 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2921 scProductEntry.getPrimaryKey());
2922 }
2923
2924 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2925 listener.onAfterRemoveAssociation(scProductEntry.getPrimaryKey(),
2926 SCLicense.class.getName(), licenseId);
2927 }
2928 }
2929 }
2930 }
2931
2932 private SqlUpdate _sqlUpdate;
2933 }
2934
2935 protected class RemoveSCProductEntry {
2936 protected RemoveSCProductEntry(SCLicensePersistenceImpl persistenceImpl) {
2937 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2938 "DELETE FROM SCLicenses_SCProductEntries WHERE licenseId = ? AND productEntryId = ?",
2939 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2940 _persistenceImpl = persistenceImpl;
2941 }
2942
2943 protected void remove(long licenseId, long productEntryId)
2944 throws SystemException {
2945 if (_persistenceImpl.containsSCProductEntry.contains(licenseId,
2946 productEntryId)) {
2947 ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry>[] scProductEntryListeners =
2948 scProductEntryPersistence.getListeners();
2949
2950 for (ModelListener<SCLicense> listener : listeners) {
2951 listener.onBeforeRemoveAssociation(licenseId,
2952 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2953 productEntryId);
2954 }
2955
2956 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2957 listener.onBeforeRemoveAssociation(productEntryId,
2958 SCLicense.class.getName(), licenseId);
2959 }
2960
2961 _sqlUpdate.update(new Object[] {
2962 new Long(licenseId), new Long(productEntryId)
2963 });
2964
2965 for (ModelListener<SCLicense> listener : listeners) {
2966 listener.onAfterRemoveAssociation(licenseId,
2967 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2968 productEntryId);
2969 }
2970
2971 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2972 listener.onAfterRemoveAssociation(productEntryId,
2973 SCLicense.class.getName(), licenseId);
2974 }
2975 }
2976 }
2977
2978 private SqlUpdate _sqlUpdate;
2979 private SCLicensePersistenceImpl _persistenceImpl;
2980 }
2981
2982 private static final String _SQL_SELECT_SCLICENSE = "SELECT scLicense FROM SCLicense scLicense";
2983 private static final String _SQL_SELECT_SCLICENSE_WHERE = "SELECT scLicense FROM SCLicense scLicense WHERE ";
2984 private static final String _SQL_COUNT_SCLICENSE = "SELECT COUNT(scLicense) FROM SCLicense scLicense";
2985 private static final String _SQL_COUNT_SCLICENSE_WHERE = "SELECT COUNT(scLicense) FROM SCLicense scLicense WHERE ";
2986 private static final String _SQL_GETSCPRODUCTENTRIES = "SELECT {SCProductEntry.*} FROM SCProductEntry INNER JOIN SCLicenses_SCProductEntries ON (SCLicenses_SCProductEntries.productEntryId = SCProductEntry.productEntryId) WHERE (SCLicenses_SCProductEntries.licenseId = ?)";
2987 private static final String _SQL_GETSCPRODUCTENTRIESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE licenseId = ?";
2988 private static final String _SQL_CONTAINSSCPRODUCTENTRY = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE licenseId = ? AND productEntryId = ?";
2989 private static final String _FINDER_COLUMN_ACTIVE_ACTIVE_2 = "scLicense.active = ?";
2990 private static final String _FINDER_COLUMN_A_R_ACTIVE_2 = "scLicense.active = ? AND ";
2991 private static final String _FINDER_COLUMN_A_R_RECOMMENDED_2 = "scLicense.recommended = ?";
2992 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "scLicense.licenseId";
2993 private static final String _FILTER_SQL_SELECT_SCLICENSE_WHERE = "SELECT DISTINCT {scLicense.*} FROM SCLicense scLicense WHERE ";
2994 private static final String _FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1 =
2995 "SELECT {SCLicense.*} FROM (SELECT DISTINCT scLicense.licenseId FROM SCLicense scLicense WHERE ";
2996 private static final String _FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2 =
2997 ") TEMP_TABLE INNER JOIN SCLicense ON TEMP_TABLE.licenseId = SCLicense.licenseId";
2998 private static final String _FILTER_SQL_COUNT_SCLICENSE_WHERE = "SELECT COUNT(DISTINCT scLicense.licenseId) AS COUNT_VALUE FROM SCLicense scLicense WHERE ";
2999 private static final String _FILTER_ENTITY_ALIAS = "scLicense";
3000 private static final String _FILTER_ENTITY_TABLE = "SCLicense";
3001 private static final String _ORDER_BY_ENTITY_ALIAS = "scLicense.";
3002 private static final String _ORDER_BY_ENTITY_TABLE = "SCLicense.";
3003 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SCLicense exists with the primary key ";
3004 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SCLicense exists with the key {";
3005 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3006 private static Log _log = LogFactoryUtil.getLog(SCLicensePersistenceImpl.class);
3007 private static SCLicense _nullSCLicense = new SCLicenseImpl() {
3008 @Override
3009 public Object clone() {
3010 return this;
3011 }
3012
3013 @Override
3014 public CacheModel<SCLicense> toCacheModel() {
3015 return _nullSCLicenseCacheModel;
3016 }
3017 };
3018
3019 private static CacheModel<SCLicense> _nullSCLicenseCacheModel = new CacheModel<SCLicense>() {
3020 public SCLicense toEntityModel() {
3021 return _nullSCLicense;
3022 }
3023 };
3024 }