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 @Override
202 public void clearCache(List<SCLicense> scLicenses) {
203 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
204 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
205
206 for (SCLicense scLicense : scLicenses) {
207 EntityCacheUtil.removeResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
208 SCLicenseImpl.class, scLicense.getPrimaryKey());
209 }
210 }
211
212
218 public SCLicense create(long licenseId) {
219 SCLicense scLicense = new SCLicenseImpl();
220
221 scLicense.setNew(true);
222 scLicense.setPrimaryKey(licenseId);
223
224 return scLicense;
225 }
226
227
235 public SCLicense remove(long licenseId)
236 throws NoSuchLicenseException, SystemException {
237 return remove(Long.valueOf(licenseId));
238 }
239
240
248 @Override
249 public SCLicense remove(Serializable primaryKey)
250 throws NoSuchLicenseException, SystemException {
251 Session session = null;
252
253 try {
254 session = openSession();
255
256 SCLicense scLicense = (SCLicense)session.get(SCLicenseImpl.class,
257 primaryKey);
258
259 if (scLicense == null) {
260 if (_log.isWarnEnabled()) {
261 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
262 }
263
264 throw new NoSuchLicenseException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
265 primaryKey);
266 }
267
268 return remove(scLicense);
269 }
270 catch (NoSuchLicenseException nsee) {
271 throw nsee;
272 }
273 catch (Exception e) {
274 throw processException(e);
275 }
276 finally {
277 closeSession(session);
278 }
279 }
280
281 @Override
282 protected SCLicense removeImpl(SCLicense scLicense)
283 throws SystemException {
284 scLicense = toUnwrappedModel(scLicense);
285
286 try {
287 clearSCProductEntries.clear(scLicense.getPrimaryKey());
288 }
289 catch (Exception e) {
290 throw processException(e);
291 }
292 finally {
293 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
294 }
295
296 Session session = null;
297
298 try {
299 session = openSession();
300
301 BatchSessionUtil.delete(session, scLicense);
302 }
303 catch (Exception e) {
304 throw processException(e);
305 }
306 finally {
307 closeSession(session);
308 }
309
310 clearCache(scLicense);
311
312 return scLicense;
313 }
314
315 @Override
316 public SCLicense updateImpl(
317 com.liferay.portlet.softwarecatalog.model.SCLicense scLicense,
318 boolean merge) throws SystemException {
319 scLicense = toUnwrappedModel(scLicense);
320
321 boolean isNew = scLicense.isNew();
322
323 SCLicenseModelImpl scLicenseModelImpl = (SCLicenseModelImpl)scLicense;
324
325 Session session = null;
326
327 try {
328 session = openSession();
329
330 BatchSessionUtil.update(session, scLicense, merge);
331
332 scLicense.setNew(false);
333 }
334 catch (Exception e) {
335 throw processException(e);
336 }
337 finally {
338 closeSession(session);
339 }
340
341 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
342
343 if (isNew || !SCLicenseModelImpl.COLUMN_BITMASK_ENABLED) {
344 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
345 }
346
347 else {
348 if ((scLicenseModelImpl.getColumnBitmask() &
349 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE.getColumnBitmask()) != 0) {
350 Object[] args = new Object[] {
351 Boolean.valueOf(scLicenseModelImpl.getOriginalActive())
352 };
353
354 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ACTIVE, args);
355 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE,
356 args);
357
358 args = new Object[] {
359 Boolean.valueOf(scLicenseModelImpl.getActive())
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
367 if ((scLicenseModelImpl.getColumnBitmask() &
368 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_A_R.getColumnBitmask()) != 0) {
369 Object[] args = new Object[] {
370 Boolean.valueOf(scLicenseModelImpl.getOriginalActive()),
371 Boolean.valueOf(scLicenseModelImpl.getOriginalRecommended())
372 };
373
374 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_A_R, args);
375 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_A_R,
376 args);
377
378 args = new Object[] {
379 Boolean.valueOf(scLicenseModelImpl.getActive()),
380 Boolean.valueOf(scLicenseModelImpl.getRecommended())
381 };
382
383 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_A_R, args);
384 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_A_R,
385 args);
386 }
387 }
388
389 EntityCacheUtil.putResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
390 SCLicenseImpl.class, scLicense.getPrimaryKey(), scLicense);
391
392 return scLicense;
393 }
394
395 protected SCLicense toUnwrappedModel(SCLicense scLicense) {
396 if (scLicense instanceof SCLicenseImpl) {
397 return scLicense;
398 }
399
400 SCLicenseImpl scLicenseImpl = new SCLicenseImpl();
401
402 scLicenseImpl.setNew(scLicense.isNew());
403 scLicenseImpl.setPrimaryKey(scLicense.getPrimaryKey());
404
405 scLicenseImpl.setLicenseId(scLicense.getLicenseId());
406 scLicenseImpl.setName(scLicense.getName());
407 scLicenseImpl.setUrl(scLicense.getUrl());
408 scLicenseImpl.setOpenSource(scLicense.isOpenSource());
409 scLicenseImpl.setActive(scLicense.isActive());
410 scLicenseImpl.setRecommended(scLicense.isRecommended());
411
412 return scLicenseImpl;
413 }
414
415
423 @Override
424 public SCLicense findByPrimaryKey(Serializable primaryKey)
425 throws NoSuchModelException, SystemException {
426 return findByPrimaryKey(((Long)primaryKey).longValue());
427 }
428
429
437 public SCLicense findByPrimaryKey(long licenseId)
438 throws NoSuchLicenseException, SystemException {
439 SCLicense scLicense = fetchByPrimaryKey(licenseId);
440
441 if (scLicense == null) {
442 if (_log.isWarnEnabled()) {
443 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + licenseId);
444 }
445
446 throw new NoSuchLicenseException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
447 licenseId);
448 }
449
450 return scLicense;
451 }
452
453
460 @Override
461 public SCLicense fetchByPrimaryKey(Serializable primaryKey)
462 throws SystemException {
463 return fetchByPrimaryKey(((Long)primaryKey).longValue());
464 }
465
466
473 public SCLicense fetchByPrimaryKey(long licenseId)
474 throws SystemException {
475 SCLicense scLicense = (SCLicense)EntityCacheUtil.getResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
476 SCLicenseImpl.class, licenseId);
477
478 if (scLicense == _nullSCLicense) {
479 return null;
480 }
481
482 if (scLicense == null) {
483 Session session = null;
484
485 boolean hasException = false;
486
487 try {
488 session = openSession();
489
490 scLicense = (SCLicense)session.get(SCLicenseImpl.class,
491 Long.valueOf(licenseId));
492 }
493 catch (Exception e) {
494 hasException = true;
495
496 throw processException(e);
497 }
498 finally {
499 if (scLicense != null) {
500 cacheResult(scLicense);
501 }
502 else if (!hasException) {
503 EntityCacheUtil.putResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
504 SCLicenseImpl.class, licenseId, _nullSCLicense);
505 }
506
507 closeSession(session);
508 }
509 }
510
511 return scLicense;
512 }
513
514
521 public List<SCLicense> findByActive(boolean active)
522 throws SystemException {
523 return findByActive(active, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
524 }
525
526
539 public List<SCLicense> findByActive(boolean active, int start, int end)
540 throws SystemException {
541 return findByActive(active, start, end, null);
542 }
543
544
558 public List<SCLicense> findByActive(boolean active, int start, int end,
559 OrderByComparator orderByComparator) throws SystemException {
560 FinderPath finderPath = null;
561 Object[] finderArgs = null;
562
563 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
564 (orderByComparator == null)) {
565 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE;
566 finderArgs = new Object[] { active };
567 }
568 else {
569 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_ACTIVE;
570 finderArgs = new Object[] { active, start, end, orderByComparator };
571 }
572
573 List<SCLicense> list = (List<SCLicense>)FinderCacheUtil.getResult(finderPath,
574 finderArgs, this);
575
576 if (list == null) {
577 StringBundler query = null;
578
579 if (orderByComparator != null) {
580 query = new StringBundler(3 +
581 (orderByComparator.getOrderByFields().length * 3));
582 }
583 else {
584 query = new StringBundler(3);
585 }
586
587 query.append(_SQL_SELECT_SCLICENSE_WHERE);
588
589 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
590
591 if (orderByComparator != null) {
592 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
593 orderByComparator);
594 }
595
596 else {
597 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
598 }
599
600 String sql = query.toString();
601
602 Session session = null;
603
604 try {
605 session = openSession();
606
607 Query q = session.createQuery(sql);
608
609 QueryPos qPos = QueryPos.getInstance(q);
610
611 qPos.add(active);
612
613 list = (List<SCLicense>)QueryUtil.list(q, getDialect(), start,
614 end);
615 }
616 catch (Exception e) {
617 throw processException(e);
618 }
619 finally {
620 if (list == null) {
621 FinderCacheUtil.removeResult(finderPath, finderArgs);
622 }
623 else {
624 cacheResult(list);
625
626 FinderCacheUtil.putResult(finderPath, finderArgs, list);
627 }
628
629 closeSession(session);
630 }
631 }
632
633 return list;
634 }
635
636
649 public SCLicense findByActive_First(boolean active,
650 OrderByComparator orderByComparator)
651 throws NoSuchLicenseException, SystemException {
652 List<SCLicense> list = findByActive(active, 0, 1, orderByComparator);
653
654 if (list.isEmpty()) {
655 StringBundler msg = new StringBundler(4);
656
657 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
658
659 msg.append("active=");
660 msg.append(active);
661
662 msg.append(StringPool.CLOSE_CURLY_BRACE);
663
664 throw new NoSuchLicenseException(msg.toString());
665 }
666 else {
667 return list.get(0);
668 }
669 }
670
671
684 public SCLicense findByActive_Last(boolean active,
685 OrderByComparator orderByComparator)
686 throws NoSuchLicenseException, SystemException {
687 int count = countByActive(active);
688
689 List<SCLicense> list = findByActive(active, count - 1, count,
690 orderByComparator);
691
692 if (list.isEmpty()) {
693 StringBundler msg = new StringBundler(4);
694
695 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
696
697 msg.append("active=");
698 msg.append(active);
699
700 msg.append(StringPool.CLOSE_CURLY_BRACE);
701
702 throw new NoSuchLicenseException(msg.toString());
703 }
704 else {
705 return list.get(0);
706 }
707 }
708
709
723 public SCLicense[] findByActive_PrevAndNext(long licenseId, boolean active,
724 OrderByComparator orderByComparator)
725 throws NoSuchLicenseException, SystemException {
726 SCLicense scLicense = findByPrimaryKey(licenseId);
727
728 Session session = null;
729
730 try {
731 session = openSession();
732
733 SCLicense[] array = new SCLicenseImpl[3];
734
735 array[0] = getByActive_PrevAndNext(session, scLicense, active,
736 orderByComparator, true);
737
738 array[1] = scLicense;
739
740 array[2] = getByActive_PrevAndNext(session, scLicense, active,
741 orderByComparator, false);
742
743 return array;
744 }
745 catch (Exception e) {
746 throw processException(e);
747 }
748 finally {
749 closeSession(session);
750 }
751 }
752
753 protected SCLicense getByActive_PrevAndNext(Session session,
754 SCLicense scLicense, boolean active,
755 OrderByComparator orderByComparator, boolean previous) {
756 StringBundler query = null;
757
758 if (orderByComparator != null) {
759 query = new StringBundler(6 +
760 (orderByComparator.getOrderByFields().length * 6));
761 }
762 else {
763 query = new StringBundler(3);
764 }
765
766 query.append(_SQL_SELECT_SCLICENSE_WHERE);
767
768 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
769
770 if (orderByComparator != null) {
771 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
772
773 if (orderByConditionFields.length > 0) {
774 query.append(WHERE_AND);
775 }
776
777 for (int i = 0; i < orderByConditionFields.length; i++) {
778 query.append(_ORDER_BY_ENTITY_ALIAS);
779 query.append(orderByConditionFields[i]);
780
781 if ((i + 1) < orderByConditionFields.length) {
782 if (orderByComparator.isAscending() ^ previous) {
783 query.append(WHERE_GREATER_THAN_HAS_NEXT);
784 }
785 else {
786 query.append(WHERE_LESSER_THAN_HAS_NEXT);
787 }
788 }
789 else {
790 if (orderByComparator.isAscending() ^ previous) {
791 query.append(WHERE_GREATER_THAN);
792 }
793 else {
794 query.append(WHERE_LESSER_THAN);
795 }
796 }
797 }
798
799 query.append(ORDER_BY_CLAUSE);
800
801 String[] orderByFields = orderByComparator.getOrderByFields();
802
803 for (int i = 0; i < orderByFields.length; i++) {
804 query.append(_ORDER_BY_ENTITY_ALIAS);
805 query.append(orderByFields[i]);
806
807 if ((i + 1) < orderByFields.length) {
808 if (orderByComparator.isAscending() ^ previous) {
809 query.append(ORDER_BY_ASC_HAS_NEXT);
810 }
811 else {
812 query.append(ORDER_BY_DESC_HAS_NEXT);
813 }
814 }
815 else {
816 if (orderByComparator.isAscending() ^ previous) {
817 query.append(ORDER_BY_ASC);
818 }
819 else {
820 query.append(ORDER_BY_DESC);
821 }
822 }
823 }
824 }
825
826 else {
827 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
828 }
829
830 String sql = query.toString();
831
832 Query q = session.createQuery(sql);
833
834 q.setFirstResult(0);
835 q.setMaxResults(2);
836
837 QueryPos qPos = QueryPos.getInstance(q);
838
839 qPos.add(active);
840
841 if (orderByComparator != null) {
842 Object[] values = orderByComparator.getOrderByConditionValues(scLicense);
843
844 for (Object value : values) {
845 qPos.add(value);
846 }
847 }
848
849 List<SCLicense> list = q.list();
850
851 if (list.size() == 2) {
852 return list.get(1);
853 }
854 else {
855 return null;
856 }
857 }
858
859
866 public List<SCLicense> filterFindByActive(boolean active)
867 throws SystemException {
868 return filterFindByActive(active, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
869 null);
870 }
871
872
885 public List<SCLicense> filterFindByActive(boolean active, int start, int end)
886 throws SystemException {
887 return filterFindByActive(active, start, end, null);
888 }
889
890
904 public List<SCLicense> filterFindByActive(boolean active, int start,
905 int end, OrderByComparator orderByComparator) throws SystemException {
906 if (!InlineSQLHelperUtil.isEnabled()) {
907 return findByActive(active, start, end, orderByComparator);
908 }
909
910 StringBundler query = null;
911
912 if (orderByComparator != null) {
913 query = new StringBundler(3 +
914 (orderByComparator.getOrderByFields().length * 3));
915 }
916 else {
917 query = new StringBundler(3);
918 }
919
920 if (getDB().isSupportsInlineDistinct()) {
921 query.append(_FILTER_SQL_SELECT_SCLICENSE_WHERE);
922 }
923 else {
924 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1);
925 }
926
927 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
928
929 if (!getDB().isSupportsInlineDistinct()) {
930 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2);
931 }
932
933 if (orderByComparator != null) {
934 if (getDB().isSupportsInlineDistinct()) {
935 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
936 orderByComparator);
937 }
938 else {
939 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
940 orderByComparator);
941 }
942 }
943
944 else {
945 if (getDB().isSupportsInlineDistinct()) {
946 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
947 }
948 else {
949 query.append(SCLicenseModelImpl.ORDER_BY_SQL);
950 }
951 }
952
953 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
954 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
955
956 Session session = null;
957
958 try {
959 session = openSession();
960
961 SQLQuery q = session.createSQLQuery(sql);
962
963 if (getDB().isSupportsInlineDistinct()) {
964 q.addEntity(_FILTER_ENTITY_ALIAS, SCLicenseImpl.class);
965 }
966 else {
967 q.addEntity(_FILTER_ENTITY_TABLE, SCLicenseImpl.class);
968 }
969
970 QueryPos qPos = QueryPos.getInstance(q);
971
972 qPos.add(active);
973
974 return (List<SCLicense>)QueryUtil.list(q, getDialect(), start, end);
975 }
976 catch (Exception e) {
977 throw processException(e);
978 }
979 finally {
980 closeSession(session);
981 }
982 }
983
984
994 public SCLicense[] filterFindByActive_PrevAndNext(long licenseId,
995 boolean active, OrderByComparator orderByComparator)
996 throws NoSuchLicenseException, SystemException {
997 if (!InlineSQLHelperUtil.isEnabled()) {
998 return findByActive_PrevAndNext(licenseId, active, orderByComparator);
999 }
1000
1001 SCLicense scLicense = findByPrimaryKey(licenseId);
1002
1003 Session session = null;
1004
1005 try {
1006 session = openSession();
1007
1008 SCLicense[] array = new SCLicenseImpl[3];
1009
1010 array[0] = filterGetByActive_PrevAndNext(session, scLicense,
1011 active, orderByComparator, true);
1012
1013 array[1] = scLicense;
1014
1015 array[2] = filterGetByActive_PrevAndNext(session, scLicense,
1016 active, orderByComparator, false);
1017
1018 return array;
1019 }
1020 catch (Exception e) {
1021 throw processException(e);
1022 }
1023 finally {
1024 closeSession(session);
1025 }
1026 }
1027
1028 protected SCLicense filterGetByActive_PrevAndNext(Session session,
1029 SCLicense scLicense, boolean active,
1030 OrderByComparator orderByComparator, boolean previous) {
1031 StringBundler query = null;
1032
1033 if (orderByComparator != null) {
1034 query = new StringBundler(6 +
1035 (orderByComparator.getOrderByFields().length * 6));
1036 }
1037 else {
1038 query = new StringBundler(3);
1039 }
1040
1041 if (getDB().isSupportsInlineDistinct()) {
1042 query.append(_FILTER_SQL_SELECT_SCLICENSE_WHERE);
1043 }
1044 else {
1045 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1);
1046 }
1047
1048 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
1049
1050 if (!getDB().isSupportsInlineDistinct()) {
1051 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2);
1052 }
1053
1054 if (orderByComparator != null) {
1055 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1056
1057 if (orderByConditionFields.length > 0) {
1058 query.append(WHERE_AND);
1059 }
1060
1061 for (int i = 0; i < orderByConditionFields.length; i++) {
1062 if (getDB().isSupportsInlineDistinct()) {
1063 query.append(_ORDER_BY_ENTITY_ALIAS);
1064 }
1065 else {
1066 query.append(_ORDER_BY_ENTITY_TABLE);
1067 }
1068
1069 query.append(orderByConditionFields[i]);
1070
1071 if ((i + 1) < orderByConditionFields.length) {
1072 if (orderByComparator.isAscending() ^ previous) {
1073 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1074 }
1075 else {
1076 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1077 }
1078 }
1079 else {
1080 if (orderByComparator.isAscending() ^ previous) {
1081 query.append(WHERE_GREATER_THAN);
1082 }
1083 else {
1084 query.append(WHERE_LESSER_THAN);
1085 }
1086 }
1087 }
1088
1089 query.append(ORDER_BY_CLAUSE);
1090
1091 String[] orderByFields = orderByComparator.getOrderByFields();
1092
1093 for (int i = 0; i < orderByFields.length; i++) {
1094 if (getDB().isSupportsInlineDistinct()) {
1095 query.append(_ORDER_BY_ENTITY_ALIAS);
1096 }
1097 else {
1098 query.append(_ORDER_BY_ENTITY_TABLE);
1099 }
1100
1101 query.append(orderByFields[i]);
1102
1103 if ((i + 1) < orderByFields.length) {
1104 if (orderByComparator.isAscending() ^ previous) {
1105 query.append(ORDER_BY_ASC_HAS_NEXT);
1106 }
1107 else {
1108 query.append(ORDER_BY_DESC_HAS_NEXT);
1109 }
1110 }
1111 else {
1112 if (orderByComparator.isAscending() ^ previous) {
1113 query.append(ORDER_BY_ASC);
1114 }
1115 else {
1116 query.append(ORDER_BY_DESC);
1117 }
1118 }
1119 }
1120 }
1121
1122 else {
1123 if (getDB().isSupportsInlineDistinct()) {
1124 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1125 }
1126 else {
1127 query.append(SCLicenseModelImpl.ORDER_BY_SQL);
1128 }
1129 }
1130
1131 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1132 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1133
1134 SQLQuery q = session.createSQLQuery(sql);
1135
1136 q.setFirstResult(0);
1137 q.setMaxResults(2);
1138
1139 if (getDB().isSupportsInlineDistinct()) {
1140 q.addEntity(_FILTER_ENTITY_ALIAS, SCLicenseImpl.class);
1141 }
1142 else {
1143 q.addEntity(_FILTER_ENTITY_TABLE, SCLicenseImpl.class);
1144 }
1145
1146 QueryPos qPos = QueryPos.getInstance(q);
1147
1148 qPos.add(active);
1149
1150 if (orderByComparator != null) {
1151 Object[] values = orderByComparator.getOrderByConditionValues(scLicense);
1152
1153 for (Object value : values) {
1154 qPos.add(value);
1155 }
1156 }
1157
1158 List<SCLicense> list = q.list();
1159
1160 if (list.size() == 2) {
1161 return list.get(1);
1162 }
1163 else {
1164 return null;
1165 }
1166 }
1167
1168
1176 public List<SCLicense> findByA_R(boolean active, boolean recommended)
1177 throws SystemException {
1178 return findByA_R(active, recommended, QueryUtil.ALL_POS,
1179 QueryUtil.ALL_POS, null);
1180 }
1181
1182
1196 public List<SCLicense> findByA_R(boolean active, boolean recommended,
1197 int start, int end) throws SystemException {
1198 return findByA_R(active, recommended, start, end, null);
1199 }
1200
1201
1216 public List<SCLicense> findByA_R(boolean active, boolean recommended,
1217 int start, int end, OrderByComparator orderByComparator)
1218 throws SystemException {
1219 FinderPath finderPath = null;
1220 Object[] finderArgs = null;
1221
1222 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1223 (orderByComparator == null)) {
1224 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_A_R;
1225 finderArgs = new Object[] { active, recommended };
1226 }
1227 else {
1228 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_A_R;
1229 finderArgs = new Object[] {
1230 active, recommended,
1231
1232 start, end, orderByComparator
1233 };
1234 }
1235
1236 List<SCLicense> list = (List<SCLicense>)FinderCacheUtil.getResult(finderPath,
1237 finderArgs, this);
1238
1239 if (list == null) {
1240 StringBundler query = null;
1241
1242 if (orderByComparator != null) {
1243 query = new StringBundler(4 +
1244 (orderByComparator.getOrderByFields().length * 3));
1245 }
1246 else {
1247 query = new StringBundler(4);
1248 }
1249
1250 query.append(_SQL_SELECT_SCLICENSE_WHERE);
1251
1252 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1253
1254 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1255
1256 if (orderByComparator != null) {
1257 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1258 orderByComparator);
1259 }
1260
1261 else {
1262 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1263 }
1264
1265 String sql = query.toString();
1266
1267 Session session = null;
1268
1269 try {
1270 session = openSession();
1271
1272 Query q = session.createQuery(sql);
1273
1274 QueryPos qPos = QueryPos.getInstance(q);
1275
1276 qPos.add(active);
1277
1278 qPos.add(recommended);
1279
1280 list = (List<SCLicense>)QueryUtil.list(q, getDialect(), start,
1281 end);
1282 }
1283 catch (Exception e) {
1284 throw processException(e);
1285 }
1286 finally {
1287 if (list == null) {
1288 FinderCacheUtil.removeResult(finderPath, finderArgs);
1289 }
1290 else {
1291 cacheResult(list);
1292
1293 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1294 }
1295
1296 closeSession(session);
1297 }
1298 }
1299
1300 return list;
1301 }
1302
1303
1317 public SCLicense findByA_R_First(boolean active, boolean recommended,
1318 OrderByComparator orderByComparator)
1319 throws NoSuchLicenseException, SystemException {
1320 List<SCLicense> list = findByA_R(active, recommended, 0, 1,
1321 orderByComparator);
1322
1323 if (list.isEmpty()) {
1324 StringBundler msg = new StringBundler(6);
1325
1326 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1327
1328 msg.append("active=");
1329 msg.append(active);
1330
1331 msg.append(", recommended=");
1332 msg.append(recommended);
1333
1334 msg.append(StringPool.CLOSE_CURLY_BRACE);
1335
1336 throw new NoSuchLicenseException(msg.toString());
1337 }
1338 else {
1339 return list.get(0);
1340 }
1341 }
1342
1343
1357 public SCLicense findByA_R_Last(boolean active, boolean recommended,
1358 OrderByComparator orderByComparator)
1359 throws NoSuchLicenseException, SystemException {
1360 int count = countByA_R(active, recommended);
1361
1362 List<SCLicense> list = findByA_R(active, recommended, count - 1, count,
1363 orderByComparator);
1364
1365 if (list.isEmpty()) {
1366 StringBundler msg = new StringBundler(6);
1367
1368 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1369
1370 msg.append("active=");
1371 msg.append(active);
1372
1373 msg.append(", recommended=");
1374 msg.append(recommended);
1375
1376 msg.append(StringPool.CLOSE_CURLY_BRACE);
1377
1378 throw new NoSuchLicenseException(msg.toString());
1379 }
1380 else {
1381 return list.get(0);
1382 }
1383 }
1384
1385
1400 public SCLicense[] findByA_R_PrevAndNext(long licenseId, boolean active,
1401 boolean recommended, OrderByComparator orderByComparator)
1402 throws NoSuchLicenseException, SystemException {
1403 SCLicense scLicense = findByPrimaryKey(licenseId);
1404
1405 Session session = null;
1406
1407 try {
1408 session = openSession();
1409
1410 SCLicense[] array = new SCLicenseImpl[3];
1411
1412 array[0] = getByA_R_PrevAndNext(session, scLicense, active,
1413 recommended, orderByComparator, true);
1414
1415 array[1] = scLicense;
1416
1417 array[2] = getByA_R_PrevAndNext(session, scLicense, active,
1418 recommended, orderByComparator, false);
1419
1420 return array;
1421 }
1422 catch (Exception e) {
1423 throw processException(e);
1424 }
1425 finally {
1426 closeSession(session);
1427 }
1428 }
1429
1430 protected SCLicense getByA_R_PrevAndNext(Session session,
1431 SCLicense scLicense, boolean active, boolean recommended,
1432 OrderByComparator orderByComparator, boolean previous) {
1433 StringBundler query = null;
1434
1435 if (orderByComparator != null) {
1436 query = new StringBundler(6 +
1437 (orderByComparator.getOrderByFields().length * 6));
1438 }
1439 else {
1440 query = new StringBundler(3);
1441 }
1442
1443 query.append(_SQL_SELECT_SCLICENSE_WHERE);
1444
1445 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1446
1447 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1448
1449 if (orderByComparator != null) {
1450 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1451
1452 if (orderByConditionFields.length > 0) {
1453 query.append(WHERE_AND);
1454 }
1455
1456 for (int i = 0; i < orderByConditionFields.length; i++) {
1457 query.append(_ORDER_BY_ENTITY_ALIAS);
1458 query.append(orderByConditionFields[i]);
1459
1460 if ((i + 1) < orderByConditionFields.length) {
1461 if (orderByComparator.isAscending() ^ previous) {
1462 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1463 }
1464 else {
1465 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1466 }
1467 }
1468 else {
1469 if (orderByComparator.isAscending() ^ previous) {
1470 query.append(WHERE_GREATER_THAN);
1471 }
1472 else {
1473 query.append(WHERE_LESSER_THAN);
1474 }
1475 }
1476 }
1477
1478 query.append(ORDER_BY_CLAUSE);
1479
1480 String[] orderByFields = orderByComparator.getOrderByFields();
1481
1482 for (int i = 0; i < orderByFields.length; i++) {
1483 query.append(_ORDER_BY_ENTITY_ALIAS);
1484 query.append(orderByFields[i]);
1485
1486 if ((i + 1) < orderByFields.length) {
1487 if (orderByComparator.isAscending() ^ previous) {
1488 query.append(ORDER_BY_ASC_HAS_NEXT);
1489 }
1490 else {
1491 query.append(ORDER_BY_DESC_HAS_NEXT);
1492 }
1493 }
1494 else {
1495 if (orderByComparator.isAscending() ^ previous) {
1496 query.append(ORDER_BY_ASC);
1497 }
1498 else {
1499 query.append(ORDER_BY_DESC);
1500 }
1501 }
1502 }
1503 }
1504
1505 else {
1506 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1507 }
1508
1509 String sql = query.toString();
1510
1511 Query q = session.createQuery(sql);
1512
1513 q.setFirstResult(0);
1514 q.setMaxResults(2);
1515
1516 QueryPos qPos = QueryPos.getInstance(q);
1517
1518 qPos.add(active);
1519
1520 qPos.add(recommended);
1521
1522 if (orderByComparator != null) {
1523 Object[] values = orderByComparator.getOrderByConditionValues(scLicense);
1524
1525 for (Object value : values) {
1526 qPos.add(value);
1527 }
1528 }
1529
1530 List<SCLicense> list = q.list();
1531
1532 if (list.size() == 2) {
1533 return list.get(1);
1534 }
1535 else {
1536 return null;
1537 }
1538 }
1539
1540
1548 public List<SCLicense> filterFindByA_R(boolean active, boolean recommended)
1549 throws SystemException {
1550 return filterFindByA_R(active, recommended, QueryUtil.ALL_POS,
1551 QueryUtil.ALL_POS, null);
1552 }
1553
1554
1568 public List<SCLicense> filterFindByA_R(boolean active, boolean recommended,
1569 int start, int end) throws SystemException {
1570 return filterFindByA_R(active, recommended, start, end, null);
1571 }
1572
1573
1588 public List<SCLicense> filterFindByA_R(boolean active, boolean recommended,
1589 int start, int end, OrderByComparator orderByComparator)
1590 throws SystemException {
1591 if (!InlineSQLHelperUtil.isEnabled()) {
1592 return findByA_R(active, recommended, start, end, orderByComparator);
1593 }
1594
1595 StringBundler query = null;
1596
1597 if (orderByComparator != null) {
1598 query = new StringBundler(4 +
1599 (orderByComparator.getOrderByFields().length * 3));
1600 }
1601 else {
1602 query = new StringBundler(4);
1603 }
1604
1605 if (getDB().isSupportsInlineDistinct()) {
1606 query.append(_FILTER_SQL_SELECT_SCLICENSE_WHERE);
1607 }
1608 else {
1609 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1);
1610 }
1611
1612 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1613
1614 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1615
1616 if (!getDB().isSupportsInlineDistinct()) {
1617 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2);
1618 }
1619
1620 if (orderByComparator != null) {
1621 if (getDB().isSupportsInlineDistinct()) {
1622 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1623 orderByComparator);
1624 }
1625 else {
1626 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1627 orderByComparator);
1628 }
1629 }
1630
1631 else {
1632 if (getDB().isSupportsInlineDistinct()) {
1633 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1634 }
1635 else {
1636 query.append(SCLicenseModelImpl.ORDER_BY_SQL);
1637 }
1638 }
1639
1640 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1641 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1642
1643 Session session = null;
1644
1645 try {
1646 session = openSession();
1647
1648 SQLQuery q = session.createSQLQuery(sql);
1649
1650 if (getDB().isSupportsInlineDistinct()) {
1651 q.addEntity(_FILTER_ENTITY_ALIAS, SCLicenseImpl.class);
1652 }
1653 else {
1654 q.addEntity(_FILTER_ENTITY_TABLE, SCLicenseImpl.class);
1655 }
1656
1657 QueryPos qPos = QueryPos.getInstance(q);
1658
1659 qPos.add(active);
1660
1661 qPos.add(recommended);
1662
1663 return (List<SCLicense>)QueryUtil.list(q, getDialect(), start, end);
1664 }
1665 catch (Exception e) {
1666 throw processException(e);
1667 }
1668 finally {
1669 closeSession(session);
1670 }
1671 }
1672
1673
1684 public SCLicense[] filterFindByA_R_PrevAndNext(long licenseId,
1685 boolean active, boolean recommended, OrderByComparator orderByComparator)
1686 throws NoSuchLicenseException, SystemException {
1687 if (!InlineSQLHelperUtil.isEnabled()) {
1688 return findByA_R_PrevAndNext(licenseId, active, recommended,
1689 orderByComparator);
1690 }
1691
1692 SCLicense scLicense = findByPrimaryKey(licenseId);
1693
1694 Session session = null;
1695
1696 try {
1697 session = openSession();
1698
1699 SCLicense[] array = new SCLicenseImpl[3];
1700
1701 array[0] = filterGetByA_R_PrevAndNext(session, scLicense, active,
1702 recommended, orderByComparator, true);
1703
1704 array[1] = scLicense;
1705
1706 array[2] = filterGetByA_R_PrevAndNext(session, scLicense, active,
1707 recommended, orderByComparator, false);
1708
1709 return array;
1710 }
1711 catch (Exception e) {
1712 throw processException(e);
1713 }
1714 finally {
1715 closeSession(session);
1716 }
1717 }
1718
1719 protected SCLicense filterGetByA_R_PrevAndNext(Session session,
1720 SCLicense scLicense, boolean active, boolean recommended,
1721 OrderByComparator orderByComparator, boolean previous) {
1722 StringBundler query = null;
1723
1724 if (orderByComparator != null) {
1725 query = new StringBundler(6 +
1726 (orderByComparator.getOrderByFields().length * 6));
1727 }
1728 else {
1729 query = new StringBundler(3);
1730 }
1731
1732 if (getDB().isSupportsInlineDistinct()) {
1733 query.append(_FILTER_SQL_SELECT_SCLICENSE_WHERE);
1734 }
1735 else {
1736 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1);
1737 }
1738
1739 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1740
1741 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1742
1743 if (!getDB().isSupportsInlineDistinct()) {
1744 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2);
1745 }
1746
1747 if (orderByComparator != null) {
1748 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1749
1750 if (orderByConditionFields.length > 0) {
1751 query.append(WHERE_AND);
1752 }
1753
1754 for (int i = 0; i < orderByConditionFields.length; i++) {
1755 if (getDB().isSupportsInlineDistinct()) {
1756 query.append(_ORDER_BY_ENTITY_ALIAS);
1757 }
1758 else {
1759 query.append(_ORDER_BY_ENTITY_TABLE);
1760 }
1761
1762 query.append(orderByConditionFields[i]);
1763
1764 if ((i + 1) < orderByConditionFields.length) {
1765 if (orderByComparator.isAscending() ^ previous) {
1766 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1767 }
1768 else {
1769 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1770 }
1771 }
1772 else {
1773 if (orderByComparator.isAscending() ^ previous) {
1774 query.append(WHERE_GREATER_THAN);
1775 }
1776 else {
1777 query.append(WHERE_LESSER_THAN);
1778 }
1779 }
1780 }
1781
1782 query.append(ORDER_BY_CLAUSE);
1783
1784 String[] orderByFields = orderByComparator.getOrderByFields();
1785
1786 for (int i = 0; i < orderByFields.length; i++) {
1787 if (getDB().isSupportsInlineDistinct()) {
1788 query.append(_ORDER_BY_ENTITY_ALIAS);
1789 }
1790 else {
1791 query.append(_ORDER_BY_ENTITY_TABLE);
1792 }
1793
1794 query.append(orderByFields[i]);
1795
1796 if ((i + 1) < orderByFields.length) {
1797 if (orderByComparator.isAscending() ^ previous) {
1798 query.append(ORDER_BY_ASC_HAS_NEXT);
1799 }
1800 else {
1801 query.append(ORDER_BY_DESC_HAS_NEXT);
1802 }
1803 }
1804 else {
1805 if (orderByComparator.isAscending() ^ previous) {
1806 query.append(ORDER_BY_ASC);
1807 }
1808 else {
1809 query.append(ORDER_BY_DESC);
1810 }
1811 }
1812 }
1813 }
1814
1815 else {
1816 if (getDB().isSupportsInlineDistinct()) {
1817 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1818 }
1819 else {
1820 query.append(SCLicenseModelImpl.ORDER_BY_SQL);
1821 }
1822 }
1823
1824 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1825 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1826
1827 SQLQuery q = session.createSQLQuery(sql);
1828
1829 q.setFirstResult(0);
1830 q.setMaxResults(2);
1831
1832 if (getDB().isSupportsInlineDistinct()) {
1833 q.addEntity(_FILTER_ENTITY_ALIAS, SCLicenseImpl.class);
1834 }
1835 else {
1836 q.addEntity(_FILTER_ENTITY_TABLE, SCLicenseImpl.class);
1837 }
1838
1839 QueryPos qPos = QueryPos.getInstance(q);
1840
1841 qPos.add(active);
1842
1843 qPos.add(recommended);
1844
1845 if (orderByComparator != null) {
1846 Object[] values = orderByComparator.getOrderByConditionValues(scLicense);
1847
1848 for (Object value : values) {
1849 qPos.add(value);
1850 }
1851 }
1852
1853 List<SCLicense> list = q.list();
1854
1855 if (list.size() == 2) {
1856 return list.get(1);
1857 }
1858 else {
1859 return null;
1860 }
1861 }
1862
1863
1869 public List<SCLicense> findAll() throws SystemException {
1870 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1871 }
1872
1873
1885 public List<SCLicense> findAll(int start, int end)
1886 throws SystemException {
1887 return findAll(start, end, null);
1888 }
1889
1890
1903 public List<SCLicense> findAll(int start, int end,
1904 OrderByComparator orderByComparator) throws SystemException {
1905 FinderPath finderPath = null;
1906 Object[] finderArgs = new Object[] { start, end, orderByComparator };
1907
1908 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1909 (orderByComparator == null)) {
1910 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1911 finderArgs = FINDER_ARGS_EMPTY;
1912 }
1913 else {
1914 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1915 finderArgs = new Object[] { start, end, orderByComparator };
1916 }
1917
1918 List<SCLicense> list = (List<SCLicense>)FinderCacheUtil.getResult(finderPath,
1919 finderArgs, this);
1920
1921 if (list == null) {
1922 StringBundler query = null;
1923 String sql = null;
1924
1925 if (orderByComparator != null) {
1926 query = new StringBundler(2 +
1927 (orderByComparator.getOrderByFields().length * 3));
1928
1929 query.append(_SQL_SELECT_SCLICENSE);
1930
1931 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1932 orderByComparator);
1933
1934 sql = query.toString();
1935 }
1936 else {
1937 sql = _SQL_SELECT_SCLICENSE.concat(SCLicenseModelImpl.ORDER_BY_JPQL);
1938 }
1939
1940 Session session = null;
1941
1942 try {
1943 session = openSession();
1944
1945 Query q = session.createQuery(sql);
1946
1947 if (orderByComparator == null) {
1948 list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
1949 start, end, false);
1950
1951 Collections.sort(list);
1952 }
1953 else {
1954 list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
1955 start, end);
1956 }
1957 }
1958 catch (Exception e) {
1959 throw processException(e);
1960 }
1961 finally {
1962 if (list == null) {
1963 FinderCacheUtil.removeResult(finderPath, finderArgs);
1964 }
1965 else {
1966 cacheResult(list);
1967
1968 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1969 }
1970
1971 closeSession(session);
1972 }
1973 }
1974
1975 return list;
1976 }
1977
1978
1984 public void removeByActive(boolean active) throws SystemException {
1985 for (SCLicense scLicense : findByActive(active)) {
1986 remove(scLicense);
1987 }
1988 }
1989
1990
1997 public void removeByA_R(boolean active, boolean recommended)
1998 throws SystemException {
1999 for (SCLicense scLicense : findByA_R(active, recommended)) {
2000 remove(scLicense);
2001 }
2002 }
2003
2004
2009 public void removeAll() throws SystemException {
2010 for (SCLicense scLicense : findAll()) {
2011 remove(scLicense);
2012 }
2013 }
2014
2015
2022 public int countByActive(boolean active) throws SystemException {
2023 Object[] finderArgs = new Object[] { active };
2024
2025 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ACTIVE,
2026 finderArgs, this);
2027
2028 if (count == null) {
2029 StringBundler query = new StringBundler(2);
2030
2031 query.append(_SQL_COUNT_SCLICENSE_WHERE);
2032
2033 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
2034
2035 String sql = query.toString();
2036
2037 Session session = null;
2038
2039 try {
2040 session = openSession();
2041
2042 Query q = session.createQuery(sql);
2043
2044 QueryPos qPos = QueryPos.getInstance(q);
2045
2046 qPos.add(active);
2047
2048 count = (Long)q.uniqueResult();
2049 }
2050 catch (Exception e) {
2051 throw processException(e);
2052 }
2053 finally {
2054 if (count == null) {
2055 count = Long.valueOf(0);
2056 }
2057
2058 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ACTIVE,
2059 finderArgs, count);
2060
2061 closeSession(session);
2062 }
2063 }
2064
2065 return count.intValue();
2066 }
2067
2068
2075 public int filterCountByActive(boolean active) throws SystemException {
2076 if (!InlineSQLHelperUtil.isEnabled()) {
2077 return countByActive(active);
2078 }
2079
2080 StringBundler query = new StringBundler(2);
2081
2082 query.append(_FILTER_SQL_COUNT_SCLICENSE_WHERE);
2083
2084 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
2085
2086 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2087 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2088
2089 Session session = null;
2090
2091 try {
2092 session = openSession();
2093
2094 SQLQuery q = session.createSQLQuery(sql);
2095
2096 q.addScalar(COUNT_COLUMN_NAME,
2097 com.liferay.portal.kernel.dao.orm.Type.LONG);
2098
2099 QueryPos qPos = QueryPos.getInstance(q);
2100
2101 qPos.add(active);
2102
2103 Long count = (Long)q.uniqueResult();
2104
2105 return count.intValue();
2106 }
2107 catch (Exception e) {
2108 throw processException(e);
2109 }
2110 finally {
2111 closeSession(session);
2112 }
2113 }
2114
2115
2123 public int countByA_R(boolean active, boolean recommended)
2124 throws SystemException {
2125 Object[] finderArgs = new Object[] { active, recommended };
2126
2127 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_A_R,
2128 finderArgs, this);
2129
2130 if (count == null) {
2131 StringBundler query = new StringBundler(3);
2132
2133 query.append(_SQL_COUNT_SCLICENSE_WHERE);
2134
2135 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
2136
2137 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
2138
2139 String sql = query.toString();
2140
2141 Session session = null;
2142
2143 try {
2144 session = openSession();
2145
2146 Query q = session.createQuery(sql);
2147
2148 QueryPos qPos = QueryPos.getInstance(q);
2149
2150 qPos.add(active);
2151
2152 qPos.add(recommended);
2153
2154 count = (Long)q.uniqueResult();
2155 }
2156 catch (Exception e) {
2157 throw processException(e);
2158 }
2159 finally {
2160 if (count == null) {
2161 count = Long.valueOf(0);
2162 }
2163
2164 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_A_R, finderArgs,
2165 count);
2166
2167 closeSession(session);
2168 }
2169 }
2170
2171 return count.intValue();
2172 }
2173
2174
2182 public int filterCountByA_R(boolean active, boolean recommended)
2183 throws SystemException {
2184 if (!InlineSQLHelperUtil.isEnabled()) {
2185 return countByA_R(active, recommended);
2186 }
2187
2188 StringBundler query = new StringBundler(3);
2189
2190 query.append(_FILTER_SQL_COUNT_SCLICENSE_WHERE);
2191
2192 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
2193
2194 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
2195
2196 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2197 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2198
2199 Session session = null;
2200
2201 try {
2202 session = openSession();
2203
2204 SQLQuery q = session.createSQLQuery(sql);
2205
2206 q.addScalar(COUNT_COLUMN_NAME,
2207 com.liferay.portal.kernel.dao.orm.Type.LONG);
2208
2209 QueryPos qPos = QueryPos.getInstance(q);
2210
2211 qPos.add(active);
2212
2213 qPos.add(recommended);
2214
2215 Long count = (Long)q.uniqueResult();
2216
2217 return count.intValue();
2218 }
2219 catch (Exception e) {
2220 throw processException(e);
2221 }
2222 finally {
2223 closeSession(session);
2224 }
2225 }
2226
2227
2233 public int countAll() throws SystemException {
2234 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2235 FINDER_ARGS_EMPTY, this);
2236
2237 if (count == null) {
2238 Session session = null;
2239
2240 try {
2241 session = openSession();
2242
2243 Query q = session.createQuery(_SQL_COUNT_SCLICENSE);
2244
2245 count = (Long)q.uniqueResult();
2246 }
2247 catch (Exception e) {
2248 throw processException(e);
2249 }
2250 finally {
2251 if (count == null) {
2252 count = Long.valueOf(0);
2253 }
2254
2255 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2256 FINDER_ARGS_EMPTY, count);
2257
2258 closeSession(session);
2259 }
2260 }
2261
2262 return count.intValue();
2263 }
2264
2265
2272 public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
2273 long pk) throws SystemException {
2274 return getSCProductEntries(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2275 }
2276
2277
2290 public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
2291 long pk, int start, int end) throws SystemException {
2292 return getSCProductEntries(pk, start, end, null);
2293 }
2294
2295 public static final FinderPath FINDER_PATH_GET_SCPRODUCTENTRIES = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
2296 SCLicenseModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
2297 com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryImpl.class,
2298 SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
2299 "getSCProductEntries",
2300 new String[] {
2301 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
2302 "com.liferay.portal.kernel.util.OrderByComparator"
2303 });
2304
2305
2319 public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
2320 long pk, int start, int end, OrderByComparator orderByComparator)
2321 throws SystemException {
2322 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
2323
2324 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> list = (List<com.liferay.portlet.softwarecatalog.model.SCProductEntry>)FinderCacheUtil.getResult(FINDER_PATH_GET_SCPRODUCTENTRIES,
2325 finderArgs, this);
2326
2327 if (list == null) {
2328 Session session = null;
2329
2330 try {
2331 session = openSession();
2332
2333 String sql = null;
2334
2335 if (orderByComparator != null) {
2336 sql = _SQL_GETSCPRODUCTENTRIES.concat(ORDER_BY_CLAUSE)
2337 .concat(orderByComparator.getOrderBy());
2338 }
2339 else {
2340 sql = _SQL_GETSCPRODUCTENTRIES.concat(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ORDER_BY_SQL);
2341 }
2342
2343 SQLQuery q = session.createSQLQuery(sql);
2344
2345 q.addEntity("SCProductEntry",
2346 com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryImpl.class);
2347
2348 QueryPos qPos = QueryPos.getInstance(q);
2349
2350 qPos.add(pk);
2351
2352 list = (List<com.liferay.portlet.softwarecatalog.model.SCProductEntry>)QueryUtil.list(q,
2353 getDialect(), start, end);
2354 }
2355 catch (Exception e) {
2356 throw processException(e);
2357 }
2358 finally {
2359 if (list == null) {
2360 FinderCacheUtil.removeResult(FINDER_PATH_GET_SCPRODUCTENTRIES,
2361 finderArgs);
2362 }
2363 else {
2364 scProductEntryPersistence.cacheResult(list);
2365
2366 FinderCacheUtil.putResult(FINDER_PATH_GET_SCPRODUCTENTRIES,
2367 finderArgs, list);
2368 }
2369
2370 closeSession(session);
2371 }
2372 }
2373
2374 return list;
2375 }
2376
2377 public static final FinderPath FINDER_PATH_GET_SCPRODUCTENTRIES_SIZE = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
2378 SCLicenseModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
2379 Long.class,
2380 SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
2381 "getSCProductEntriesSize", new String[] { Long.class.getName() });
2382
2383
2390 public int getSCProductEntriesSize(long pk) throws SystemException {
2391 Object[] finderArgs = new Object[] { pk };
2392
2393 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_SCPRODUCTENTRIES_SIZE,
2394 finderArgs, this);
2395
2396 if (count == null) {
2397 Session session = null;
2398
2399 try {
2400 session = openSession();
2401
2402 SQLQuery q = session.createSQLQuery(_SQL_GETSCPRODUCTENTRIESSIZE);
2403
2404 q.addScalar(COUNT_COLUMN_NAME,
2405 com.liferay.portal.kernel.dao.orm.Type.LONG);
2406
2407 QueryPos qPos = QueryPos.getInstance(q);
2408
2409 qPos.add(pk);
2410
2411 count = (Long)q.uniqueResult();
2412 }
2413 catch (Exception e) {
2414 throw processException(e);
2415 }
2416 finally {
2417 if (count == null) {
2418 count = Long.valueOf(0);
2419 }
2420
2421 FinderCacheUtil.putResult(FINDER_PATH_GET_SCPRODUCTENTRIES_SIZE,
2422 finderArgs, count);
2423
2424 closeSession(session);
2425 }
2426 }
2427
2428 return count.intValue();
2429 }
2430
2431 public static final FinderPath FINDER_PATH_CONTAINS_SCPRODUCTENTRY = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
2432 SCLicenseModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
2433 Boolean.class,
2434 SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
2435 "containsSCProductEntry",
2436 new String[] { Long.class.getName(), Long.class.getName() });
2437
2438
2446 public boolean containsSCProductEntry(long pk, long scProductEntryPK)
2447 throws SystemException {
2448 Object[] finderArgs = new Object[] { pk, scProductEntryPK };
2449
2450 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_SCPRODUCTENTRY,
2451 finderArgs, this);
2452
2453 if (value == null) {
2454 try {
2455 value = Boolean.valueOf(containsSCProductEntry.contains(pk,
2456 scProductEntryPK));
2457 }
2458 catch (Exception e) {
2459 throw processException(e);
2460 }
2461 finally {
2462 if (value == null) {
2463 value = Boolean.FALSE;
2464 }
2465
2466 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_SCPRODUCTENTRY,
2467 finderArgs, value);
2468 }
2469 }
2470
2471 return value.booleanValue();
2472 }
2473
2474
2481 public boolean containsSCProductEntries(long pk) throws SystemException {
2482 if (getSCProductEntriesSize(pk) > 0) {
2483 return true;
2484 }
2485 else {
2486 return false;
2487 }
2488 }
2489
2490
2497 public void addSCProductEntry(long pk, long scProductEntryPK)
2498 throws SystemException {
2499 try {
2500 addSCProductEntry.add(pk, scProductEntryPK);
2501 }
2502 catch (Exception e) {
2503 throw processException(e);
2504 }
2505 finally {
2506 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2507 }
2508 }
2509
2510
2517 public void addSCProductEntry(long pk,
2518 com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry)
2519 throws SystemException {
2520 try {
2521 addSCProductEntry.add(pk, scProductEntry.getPrimaryKey());
2522 }
2523 catch (Exception e) {
2524 throw processException(e);
2525 }
2526 finally {
2527 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2528 }
2529 }
2530
2531
2538 public void addSCProductEntries(long pk, long[] scProductEntryPKs)
2539 throws SystemException {
2540 try {
2541 for (long scProductEntryPK : scProductEntryPKs) {
2542 addSCProductEntry.add(pk, scProductEntryPK);
2543 }
2544 }
2545 catch (Exception e) {
2546 throw processException(e);
2547 }
2548 finally {
2549 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2550 }
2551 }
2552
2553
2560 public void addSCProductEntries(long pk,
2561 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries)
2562 throws SystemException {
2563 try {
2564 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2565 addSCProductEntry.add(pk, scProductEntry.getPrimaryKey());
2566 }
2567 }
2568 catch (Exception e) {
2569 throw processException(e);
2570 }
2571 finally {
2572 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2573 }
2574 }
2575
2576
2582 public void clearSCProductEntries(long pk) throws SystemException {
2583 try {
2584 clearSCProductEntries.clear(pk);
2585 }
2586 catch (Exception e) {
2587 throw processException(e);
2588 }
2589 finally {
2590 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2591 }
2592 }
2593
2594
2601 public void removeSCProductEntry(long pk, long scProductEntryPK)
2602 throws SystemException {
2603 try {
2604 removeSCProductEntry.remove(pk, scProductEntryPK);
2605 }
2606 catch (Exception e) {
2607 throw processException(e);
2608 }
2609 finally {
2610 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2611 }
2612 }
2613
2614
2621 public void removeSCProductEntry(long pk,
2622 com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry)
2623 throws SystemException {
2624 try {
2625 removeSCProductEntry.remove(pk, scProductEntry.getPrimaryKey());
2626 }
2627 catch (Exception e) {
2628 throw processException(e);
2629 }
2630 finally {
2631 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2632 }
2633 }
2634
2635
2642 public void removeSCProductEntries(long pk, long[] scProductEntryPKs)
2643 throws SystemException {
2644 try {
2645 for (long scProductEntryPK : scProductEntryPKs) {
2646 removeSCProductEntry.remove(pk, scProductEntryPK);
2647 }
2648 }
2649 catch (Exception e) {
2650 throw processException(e);
2651 }
2652 finally {
2653 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2654 }
2655 }
2656
2657
2664 public void removeSCProductEntries(long pk,
2665 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries)
2666 throws SystemException {
2667 try {
2668 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2669 removeSCProductEntry.remove(pk, scProductEntry.getPrimaryKey());
2670 }
2671 }
2672 catch (Exception e) {
2673 throw processException(e);
2674 }
2675 finally {
2676 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2677 }
2678 }
2679
2680
2687 public void setSCProductEntries(long pk, long[] scProductEntryPKs)
2688 throws SystemException {
2689 try {
2690 Set<Long> scProductEntryPKSet = SetUtil.fromArray(scProductEntryPKs);
2691
2692 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries =
2693 getSCProductEntries(pk);
2694
2695 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2696 if (!scProductEntryPKSet.remove(scProductEntry.getPrimaryKey())) {
2697 removeSCProductEntry.remove(pk,
2698 scProductEntry.getPrimaryKey());
2699 }
2700 }
2701
2702 for (Long scProductEntryPK : scProductEntryPKSet) {
2703 addSCProductEntry.add(pk, scProductEntryPK);
2704 }
2705 }
2706 catch (Exception e) {
2707 throw processException(e);
2708 }
2709 finally {
2710 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2711 }
2712 }
2713
2714
2721 public void setSCProductEntries(long pk,
2722 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries)
2723 throws SystemException {
2724 try {
2725 long[] scProductEntryPKs = new long[scProductEntries.size()];
2726
2727 for (int i = 0; i < scProductEntries.size(); i++) {
2728 com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry =
2729 scProductEntries.get(i);
2730
2731 scProductEntryPKs[i] = scProductEntry.getPrimaryKey();
2732 }
2733
2734 setSCProductEntries(pk, scProductEntryPKs);
2735 }
2736 catch (Exception e) {
2737 throw processException(e);
2738 }
2739 finally {
2740 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2741 }
2742 }
2743
2744
2747 public void afterPropertiesSet() {
2748 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2749 com.liferay.portal.util.PropsUtil.get(
2750 "value.object.listener.com.liferay.portlet.softwarecatalog.model.SCLicense")));
2751
2752 if (listenerClassNames.length > 0) {
2753 try {
2754 List<ModelListener<SCLicense>> listenersList = new ArrayList<ModelListener<SCLicense>>();
2755
2756 for (String listenerClassName : listenerClassNames) {
2757 listenersList.add((ModelListener<SCLicense>)InstanceFactory.newInstance(
2758 listenerClassName));
2759 }
2760
2761 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2762 }
2763 catch (Exception e) {
2764 _log.error(e);
2765 }
2766 }
2767
2768 containsSCProductEntry = new ContainsSCProductEntry();
2769
2770 addSCProductEntry = new AddSCProductEntry();
2771 clearSCProductEntries = new ClearSCProductEntries();
2772 removeSCProductEntry = new RemoveSCProductEntry();
2773 }
2774
2775 public void destroy() {
2776 EntityCacheUtil.removeCache(SCLicenseImpl.class.getName());
2777 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2778 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2779 }
2780
2781 @BeanReference(type = SCFrameworkVersionPersistence.class)
2782 protected SCFrameworkVersionPersistence scFrameworkVersionPersistence;
2783 @BeanReference(type = SCLicensePersistence.class)
2784 protected SCLicensePersistence scLicensePersistence;
2785 @BeanReference(type = SCProductEntryPersistence.class)
2786 protected SCProductEntryPersistence scProductEntryPersistence;
2787 @BeanReference(type = SCProductScreenshotPersistence.class)
2788 protected SCProductScreenshotPersistence scProductScreenshotPersistence;
2789 @BeanReference(type = SCProductVersionPersistence.class)
2790 protected SCProductVersionPersistence scProductVersionPersistence;
2791 @BeanReference(type = ResourcePersistence.class)
2792 protected ResourcePersistence resourcePersistence;
2793 @BeanReference(type = UserPersistence.class)
2794 protected UserPersistence userPersistence;
2795 protected ContainsSCProductEntry containsSCProductEntry;
2796 protected AddSCProductEntry addSCProductEntry;
2797 protected ClearSCProductEntries clearSCProductEntries;
2798 protected RemoveSCProductEntry removeSCProductEntry;
2799
2800 protected class ContainsSCProductEntry {
2801 protected ContainsSCProductEntry() {
2802 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2803 _SQL_CONTAINSSCPRODUCTENTRY,
2804 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
2805 RowMapper.COUNT);
2806 }
2807
2808 protected boolean contains(long licenseId, long productEntryId) {
2809 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2810 new Long(licenseId), new Long(productEntryId)
2811 });
2812
2813 if (results.size() > 0) {
2814 Integer count = results.get(0);
2815
2816 if (count.intValue() > 0) {
2817 return true;
2818 }
2819 }
2820
2821 return false;
2822 }
2823
2824 private MappingSqlQuery<Integer> _mappingSqlQuery;
2825 }
2826
2827 protected class AddSCProductEntry {
2828 protected AddSCProductEntry() {
2829 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2830 "INSERT INTO SCLicenses_SCProductEntries (licenseId, productEntryId) VALUES (?, ?)",
2831 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2832 }
2833
2834 protected void add(long licenseId, long productEntryId)
2835 throws SystemException {
2836 if (!containsSCProductEntry.contains(licenseId, productEntryId)) {
2837 ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry>[] scProductEntryListeners =
2838 scProductEntryPersistence.getListeners();
2839
2840 for (ModelListener<SCLicense> listener : listeners) {
2841 listener.onBeforeAddAssociation(licenseId,
2842 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2843 productEntryId);
2844 }
2845
2846 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2847 listener.onBeforeAddAssociation(productEntryId,
2848 SCLicense.class.getName(), licenseId);
2849 }
2850
2851 _sqlUpdate.update(new Object[] {
2852 new Long(licenseId), new Long(productEntryId)
2853 });
2854
2855 for (ModelListener<SCLicense> listener : listeners) {
2856 listener.onAfterAddAssociation(licenseId,
2857 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2858 productEntryId);
2859 }
2860
2861 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2862 listener.onAfterAddAssociation(productEntryId,
2863 SCLicense.class.getName(), licenseId);
2864 }
2865 }
2866 }
2867
2868 private SqlUpdate _sqlUpdate;
2869 }
2870
2871 protected class ClearSCProductEntries {
2872 protected ClearSCProductEntries() {
2873 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2874 "DELETE FROM SCLicenses_SCProductEntries WHERE licenseId = ?",
2875 new int[] { java.sql.Types.BIGINT });
2876 }
2877
2878 protected void clear(long licenseId) throws SystemException {
2879 ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry>[] scProductEntryListeners =
2880 scProductEntryPersistence.getListeners();
2881
2882 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries =
2883 null;
2884
2885 if ((listeners.length > 0) || (scProductEntryListeners.length > 0)) {
2886 scProductEntries = getSCProductEntries(licenseId);
2887
2888 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2889 for (ModelListener<SCLicense> listener : listeners) {
2890 listener.onBeforeRemoveAssociation(licenseId,
2891 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2892 scProductEntry.getPrimaryKey());
2893 }
2894
2895 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2896 listener.onBeforeRemoveAssociation(scProductEntry.getPrimaryKey(),
2897 SCLicense.class.getName(), licenseId);
2898 }
2899 }
2900 }
2901
2902 _sqlUpdate.update(new Object[] { new Long(licenseId) });
2903
2904 if ((listeners.length > 0) || (scProductEntryListeners.length > 0)) {
2905 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2906 for (ModelListener<SCLicense> listener : listeners) {
2907 listener.onAfterRemoveAssociation(licenseId,
2908 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2909 scProductEntry.getPrimaryKey());
2910 }
2911
2912 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2913 listener.onAfterRemoveAssociation(scProductEntry.getPrimaryKey(),
2914 SCLicense.class.getName(), licenseId);
2915 }
2916 }
2917 }
2918 }
2919
2920 private SqlUpdate _sqlUpdate;
2921 }
2922
2923 protected class RemoveSCProductEntry {
2924 protected RemoveSCProductEntry() {
2925 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2926 "DELETE FROM SCLicenses_SCProductEntries WHERE licenseId = ? AND productEntryId = ?",
2927 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2928 }
2929
2930 protected void remove(long licenseId, long productEntryId)
2931 throws SystemException {
2932 if (containsSCProductEntry.contains(licenseId, productEntryId)) {
2933 ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry>[] scProductEntryListeners =
2934 scProductEntryPersistence.getListeners();
2935
2936 for (ModelListener<SCLicense> listener : listeners) {
2937 listener.onBeforeRemoveAssociation(licenseId,
2938 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2939 productEntryId);
2940 }
2941
2942 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2943 listener.onBeforeRemoveAssociation(productEntryId,
2944 SCLicense.class.getName(), licenseId);
2945 }
2946
2947 _sqlUpdate.update(new Object[] {
2948 new Long(licenseId), new Long(productEntryId)
2949 });
2950
2951 for (ModelListener<SCLicense> listener : listeners) {
2952 listener.onAfterRemoveAssociation(licenseId,
2953 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2954 productEntryId);
2955 }
2956
2957 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2958 listener.onAfterRemoveAssociation(productEntryId,
2959 SCLicense.class.getName(), licenseId);
2960 }
2961 }
2962 }
2963
2964 private SqlUpdate _sqlUpdate;
2965 }
2966
2967 private static final String _SQL_SELECT_SCLICENSE = "SELECT scLicense FROM SCLicense scLicense";
2968 private static final String _SQL_SELECT_SCLICENSE_WHERE = "SELECT scLicense FROM SCLicense scLicense WHERE ";
2969 private static final String _SQL_COUNT_SCLICENSE = "SELECT COUNT(scLicense) FROM SCLicense scLicense";
2970 private static final String _SQL_COUNT_SCLICENSE_WHERE = "SELECT COUNT(scLicense) FROM SCLicense scLicense WHERE ";
2971 private static final String _SQL_GETSCPRODUCTENTRIES = "SELECT {SCProductEntry.*} FROM SCProductEntry INNER JOIN SCLicenses_SCProductEntries ON (SCLicenses_SCProductEntries.productEntryId = SCProductEntry.productEntryId) WHERE (SCLicenses_SCProductEntries.licenseId = ?)";
2972 private static final String _SQL_GETSCPRODUCTENTRIESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE licenseId = ?";
2973 private static final String _SQL_CONTAINSSCPRODUCTENTRY = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE licenseId = ? AND productEntryId = ?";
2974 private static final String _FINDER_COLUMN_ACTIVE_ACTIVE_2 = "scLicense.active = ?";
2975 private static final String _FINDER_COLUMN_A_R_ACTIVE_2 = "scLicense.active = ? AND ";
2976 private static final String _FINDER_COLUMN_A_R_RECOMMENDED_2 = "scLicense.recommended = ?";
2977 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "scLicense.licenseId";
2978 private static final String _FILTER_SQL_SELECT_SCLICENSE_WHERE = "SELECT DISTINCT {scLicense.*} FROM SCLicense scLicense WHERE ";
2979 private static final String _FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1 =
2980 "SELECT {SCLicense.*} FROM (SELECT DISTINCT scLicense.licenseId FROM SCLicense scLicense WHERE ";
2981 private static final String _FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2 =
2982 ") TEMP_TABLE INNER JOIN SCLicense ON TEMP_TABLE.licenseId = SCLicense.licenseId";
2983 private static final String _FILTER_SQL_COUNT_SCLICENSE_WHERE = "SELECT COUNT(DISTINCT scLicense.licenseId) AS COUNT_VALUE FROM SCLicense scLicense WHERE ";
2984 private static final String _FILTER_ENTITY_ALIAS = "scLicense";
2985 private static final String _FILTER_ENTITY_TABLE = "SCLicense";
2986 private static final String _ORDER_BY_ENTITY_ALIAS = "scLicense.";
2987 private static final String _ORDER_BY_ENTITY_TABLE = "SCLicense.";
2988 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SCLicense exists with the primary key ";
2989 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SCLicense exists with the key {";
2990 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2991 private static Log _log = LogFactoryUtil.getLog(SCLicensePersistenceImpl.class);
2992 private static SCLicense _nullSCLicense = new SCLicenseImpl() {
2993 @Override
2994 public Object clone() {
2995 return this;
2996 }
2997
2998 @Override
2999 public CacheModel<SCLicense> toCacheModel() {
3000 return _nullSCLicenseCacheModel;
3001 }
3002 };
3003
3004 private static CacheModel<SCLicense> _nullSCLicenseCacheModel = new CacheModel<SCLicense>() {
3005 public SCLicense toEntityModel() {
3006 return _nullSCLicense;
3007 }
3008 };
3009 }