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_WITH_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_WITHOUT_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 else {
347 if ((scLicenseModelImpl.getColumnBitmask() &
348 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE.getColumnBitmask()) != 0) {
349 Object[] args = new Object[] {
350 Boolean.valueOf(scLicenseModelImpl.getOriginalActive())
351 };
352
353 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ACTIVE, args);
354 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE,
355 args);
356
357 args = new Object[] {
358 Boolean.valueOf(scLicenseModelImpl.getActive())
359 };
360
361 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ACTIVE, args);
362 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE,
363 args);
364 }
365
366 if ((scLicenseModelImpl.getColumnBitmask() &
367 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_A_R.getColumnBitmask()) != 0) {
368 Object[] args = new Object[] {
369 Boolean.valueOf(scLicenseModelImpl.getOriginalActive()),
370 Boolean.valueOf(scLicenseModelImpl.getOriginalRecommended())
371 };
372
373 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_A_R, args);
374 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_A_R,
375 args);
376
377 args = new Object[] {
378 Boolean.valueOf(scLicenseModelImpl.getActive()),
379 Boolean.valueOf(scLicenseModelImpl.getRecommended())
380 };
381
382 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_A_R, args);
383 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_A_R,
384 args);
385 }
386 }
387
388 EntityCacheUtil.putResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
389 SCLicenseImpl.class, scLicense.getPrimaryKey(), scLicense);
390
391 return scLicense;
392 }
393
394 protected SCLicense toUnwrappedModel(SCLicense scLicense) {
395 if (scLicense instanceof SCLicenseImpl) {
396 return scLicense;
397 }
398
399 SCLicenseImpl scLicenseImpl = new SCLicenseImpl();
400
401 scLicenseImpl.setNew(scLicense.isNew());
402 scLicenseImpl.setPrimaryKey(scLicense.getPrimaryKey());
403
404 scLicenseImpl.setLicenseId(scLicense.getLicenseId());
405 scLicenseImpl.setName(scLicense.getName());
406 scLicenseImpl.setUrl(scLicense.getUrl());
407 scLicenseImpl.setOpenSource(scLicense.isOpenSource());
408 scLicenseImpl.setActive(scLicense.isActive());
409 scLicenseImpl.setRecommended(scLicense.isRecommended());
410
411 return scLicenseImpl;
412 }
413
414
422 @Override
423 public SCLicense findByPrimaryKey(Serializable primaryKey)
424 throws NoSuchModelException, SystemException {
425 return findByPrimaryKey(((Long)primaryKey).longValue());
426 }
427
428
436 public SCLicense findByPrimaryKey(long licenseId)
437 throws NoSuchLicenseException, SystemException {
438 SCLicense scLicense = fetchByPrimaryKey(licenseId);
439
440 if (scLicense == null) {
441 if (_log.isWarnEnabled()) {
442 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + licenseId);
443 }
444
445 throw new NoSuchLicenseException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
446 licenseId);
447 }
448
449 return scLicense;
450 }
451
452
459 @Override
460 public SCLicense fetchByPrimaryKey(Serializable primaryKey)
461 throws SystemException {
462 return fetchByPrimaryKey(((Long)primaryKey).longValue());
463 }
464
465
472 public SCLicense fetchByPrimaryKey(long licenseId)
473 throws SystemException {
474 SCLicense scLicense = (SCLicense)EntityCacheUtil.getResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
475 SCLicenseImpl.class, licenseId);
476
477 if (scLicense == _nullSCLicense) {
478 return null;
479 }
480
481 if (scLicense == null) {
482 Session session = null;
483
484 boolean hasException = false;
485
486 try {
487 session = openSession();
488
489 scLicense = (SCLicense)session.get(SCLicenseImpl.class,
490 Long.valueOf(licenseId));
491 }
492 catch (Exception e) {
493 hasException = true;
494
495 throw processException(e);
496 }
497 finally {
498 if (scLicense != null) {
499 cacheResult(scLicense);
500 }
501 else if (!hasException) {
502 EntityCacheUtil.putResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
503 SCLicenseImpl.class, licenseId, _nullSCLicense);
504 }
505
506 closeSession(session);
507 }
508 }
509
510 return scLicense;
511 }
512
513
520 public List<SCLicense> findByActive(boolean active)
521 throws SystemException {
522 return findByActive(active, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
523 }
524
525
538 public List<SCLicense> findByActive(boolean active, int start, int end)
539 throws SystemException {
540 return findByActive(active, start, end, null);
541 }
542
543
557 public List<SCLicense> findByActive(boolean active, int start, int end,
558 OrderByComparator orderByComparator) throws SystemException {
559 FinderPath finderPath = null;
560 Object[] finderArgs = null;
561
562 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
563 (orderByComparator == null)) {
564 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE;
565 finderArgs = new Object[] { active };
566 }
567 else {
568 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_ACTIVE;
569 finderArgs = new Object[] { active, start, end, orderByComparator };
570 }
571
572 List<SCLicense> list = (List<SCLicense>)FinderCacheUtil.getResult(finderPath,
573 finderArgs, this);
574
575 if ((list != null) && !list.isEmpty()) {
576 for (SCLicense scLicense : list) {
577 if ((active != scLicense.getActive())) {
578 list = null;
579
580 break;
581 }
582 }
583 }
584
585 if (list == null) {
586 StringBundler query = null;
587
588 if (orderByComparator != null) {
589 query = new StringBundler(3 +
590 (orderByComparator.getOrderByFields().length * 3));
591 }
592 else {
593 query = new StringBundler(3);
594 }
595
596 query.append(_SQL_SELECT_SCLICENSE_WHERE);
597
598 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
599
600 if (orderByComparator != null) {
601 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
602 orderByComparator);
603 }
604
605 else {
606 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
607 }
608
609 String sql = query.toString();
610
611 Session session = null;
612
613 try {
614 session = openSession();
615
616 Query q = session.createQuery(sql);
617
618 QueryPos qPos = QueryPos.getInstance(q);
619
620 qPos.add(active);
621
622 list = (List<SCLicense>)QueryUtil.list(q, getDialect(), start,
623 end);
624 }
625 catch (Exception e) {
626 throw processException(e);
627 }
628 finally {
629 if (list == null) {
630 FinderCacheUtil.removeResult(finderPath, finderArgs);
631 }
632 else {
633 cacheResult(list);
634
635 FinderCacheUtil.putResult(finderPath, finderArgs, list);
636 }
637
638 closeSession(session);
639 }
640 }
641
642 return list;
643 }
644
645
658 public SCLicense findByActive_First(boolean active,
659 OrderByComparator orderByComparator)
660 throws NoSuchLicenseException, SystemException {
661 List<SCLicense> list = findByActive(active, 0, 1, orderByComparator);
662
663 if (list.isEmpty()) {
664 StringBundler msg = new StringBundler(4);
665
666 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
667
668 msg.append("active=");
669 msg.append(active);
670
671 msg.append(StringPool.CLOSE_CURLY_BRACE);
672
673 throw new NoSuchLicenseException(msg.toString());
674 }
675 else {
676 return list.get(0);
677 }
678 }
679
680
693 public SCLicense findByActive_Last(boolean active,
694 OrderByComparator orderByComparator)
695 throws NoSuchLicenseException, SystemException {
696 int count = countByActive(active);
697
698 List<SCLicense> list = findByActive(active, count - 1, count,
699 orderByComparator);
700
701 if (list.isEmpty()) {
702 StringBundler msg = new StringBundler(4);
703
704 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
705
706 msg.append("active=");
707 msg.append(active);
708
709 msg.append(StringPool.CLOSE_CURLY_BRACE);
710
711 throw new NoSuchLicenseException(msg.toString());
712 }
713 else {
714 return list.get(0);
715 }
716 }
717
718
732 public SCLicense[] findByActive_PrevAndNext(long licenseId, boolean active,
733 OrderByComparator orderByComparator)
734 throws NoSuchLicenseException, SystemException {
735 SCLicense scLicense = findByPrimaryKey(licenseId);
736
737 Session session = null;
738
739 try {
740 session = openSession();
741
742 SCLicense[] array = new SCLicenseImpl[3];
743
744 array[0] = getByActive_PrevAndNext(session, scLicense, active,
745 orderByComparator, true);
746
747 array[1] = scLicense;
748
749 array[2] = getByActive_PrevAndNext(session, scLicense, active,
750 orderByComparator, false);
751
752 return array;
753 }
754 catch (Exception e) {
755 throw processException(e);
756 }
757 finally {
758 closeSession(session);
759 }
760 }
761
762 protected SCLicense getByActive_PrevAndNext(Session session,
763 SCLicense scLicense, boolean active,
764 OrderByComparator orderByComparator, boolean previous) {
765 StringBundler query = null;
766
767 if (orderByComparator != null) {
768 query = new StringBundler(6 +
769 (orderByComparator.getOrderByFields().length * 6));
770 }
771 else {
772 query = new StringBundler(3);
773 }
774
775 query.append(_SQL_SELECT_SCLICENSE_WHERE);
776
777 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
778
779 if (orderByComparator != null) {
780 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
781
782 if (orderByConditionFields.length > 0) {
783 query.append(WHERE_AND);
784 }
785
786 for (int i = 0; i < orderByConditionFields.length; i++) {
787 query.append(_ORDER_BY_ENTITY_ALIAS);
788 query.append(orderByConditionFields[i]);
789
790 if ((i + 1) < orderByConditionFields.length) {
791 if (orderByComparator.isAscending() ^ previous) {
792 query.append(WHERE_GREATER_THAN_HAS_NEXT);
793 }
794 else {
795 query.append(WHERE_LESSER_THAN_HAS_NEXT);
796 }
797 }
798 else {
799 if (orderByComparator.isAscending() ^ previous) {
800 query.append(WHERE_GREATER_THAN);
801 }
802 else {
803 query.append(WHERE_LESSER_THAN);
804 }
805 }
806 }
807
808 query.append(ORDER_BY_CLAUSE);
809
810 String[] orderByFields = orderByComparator.getOrderByFields();
811
812 for (int i = 0; i < orderByFields.length; i++) {
813 query.append(_ORDER_BY_ENTITY_ALIAS);
814 query.append(orderByFields[i]);
815
816 if ((i + 1) < orderByFields.length) {
817 if (orderByComparator.isAscending() ^ previous) {
818 query.append(ORDER_BY_ASC_HAS_NEXT);
819 }
820 else {
821 query.append(ORDER_BY_DESC_HAS_NEXT);
822 }
823 }
824 else {
825 if (orderByComparator.isAscending() ^ previous) {
826 query.append(ORDER_BY_ASC);
827 }
828 else {
829 query.append(ORDER_BY_DESC);
830 }
831 }
832 }
833 }
834
835 else {
836 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
837 }
838
839 String sql = query.toString();
840
841 Query q = session.createQuery(sql);
842
843 q.setFirstResult(0);
844 q.setMaxResults(2);
845
846 QueryPos qPos = QueryPos.getInstance(q);
847
848 qPos.add(active);
849
850 if (orderByComparator != null) {
851 Object[] values = orderByComparator.getOrderByConditionValues(scLicense);
852
853 for (Object value : values) {
854 qPos.add(value);
855 }
856 }
857
858 List<SCLicense> list = q.list();
859
860 if (list.size() == 2) {
861 return list.get(1);
862 }
863 else {
864 return null;
865 }
866 }
867
868
875 public List<SCLicense> filterFindByActive(boolean active)
876 throws SystemException {
877 return filterFindByActive(active, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
878 null);
879 }
880
881
894 public List<SCLicense> filterFindByActive(boolean active, int start, int end)
895 throws SystemException {
896 return filterFindByActive(active, start, end, null);
897 }
898
899
913 public List<SCLicense> filterFindByActive(boolean active, int start,
914 int end, OrderByComparator orderByComparator) throws SystemException {
915 if (!InlineSQLHelperUtil.isEnabled()) {
916 return findByActive(active, start, end, orderByComparator);
917 }
918
919 StringBundler query = null;
920
921 if (orderByComparator != null) {
922 query = new StringBundler(3 +
923 (orderByComparator.getOrderByFields().length * 3));
924 }
925 else {
926 query = new StringBundler(3);
927 }
928
929 if (getDB().isSupportsInlineDistinct()) {
930 query.append(_FILTER_SQL_SELECT_SCLICENSE_WHERE);
931 }
932 else {
933 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1);
934 }
935
936 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
937
938 if (!getDB().isSupportsInlineDistinct()) {
939 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2);
940 }
941
942 if (orderByComparator != null) {
943 if (getDB().isSupportsInlineDistinct()) {
944 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
945 orderByComparator);
946 }
947 else {
948 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
949 orderByComparator);
950 }
951 }
952
953 else {
954 if (getDB().isSupportsInlineDistinct()) {
955 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
956 }
957 else {
958 query.append(SCLicenseModelImpl.ORDER_BY_SQL);
959 }
960 }
961
962 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
963 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
964
965 Session session = null;
966
967 try {
968 session = openSession();
969
970 SQLQuery q = session.createSQLQuery(sql);
971
972 if (getDB().isSupportsInlineDistinct()) {
973 q.addEntity(_FILTER_ENTITY_ALIAS, SCLicenseImpl.class);
974 }
975 else {
976 q.addEntity(_FILTER_ENTITY_TABLE, SCLicenseImpl.class);
977 }
978
979 QueryPos qPos = QueryPos.getInstance(q);
980
981 qPos.add(active);
982
983 return (List<SCLicense>)QueryUtil.list(q, getDialect(), start, end);
984 }
985 catch (Exception e) {
986 throw processException(e);
987 }
988 finally {
989 closeSession(session);
990 }
991 }
992
993
1003 public SCLicense[] filterFindByActive_PrevAndNext(long licenseId,
1004 boolean active, OrderByComparator orderByComparator)
1005 throws NoSuchLicenseException, SystemException {
1006 if (!InlineSQLHelperUtil.isEnabled()) {
1007 return findByActive_PrevAndNext(licenseId, active, orderByComparator);
1008 }
1009
1010 SCLicense scLicense = findByPrimaryKey(licenseId);
1011
1012 Session session = null;
1013
1014 try {
1015 session = openSession();
1016
1017 SCLicense[] array = new SCLicenseImpl[3];
1018
1019 array[0] = filterGetByActive_PrevAndNext(session, scLicense,
1020 active, orderByComparator, true);
1021
1022 array[1] = scLicense;
1023
1024 array[2] = filterGetByActive_PrevAndNext(session, scLicense,
1025 active, orderByComparator, false);
1026
1027 return array;
1028 }
1029 catch (Exception e) {
1030 throw processException(e);
1031 }
1032 finally {
1033 closeSession(session);
1034 }
1035 }
1036
1037 protected SCLicense filterGetByActive_PrevAndNext(Session session,
1038 SCLicense scLicense, boolean active,
1039 OrderByComparator orderByComparator, boolean previous) {
1040 StringBundler query = null;
1041
1042 if (orderByComparator != null) {
1043 query = new StringBundler(6 +
1044 (orderByComparator.getOrderByFields().length * 6));
1045 }
1046 else {
1047 query = new StringBundler(3);
1048 }
1049
1050 if (getDB().isSupportsInlineDistinct()) {
1051 query.append(_FILTER_SQL_SELECT_SCLICENSE_WHERE);
1052 }
1053 else {
1054 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1);
1055 }
1056
1057 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
1058
1059 if (!getDB().isSupportsInlineDistinct()) {
1060 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2);
1061 }
1062
1063 if (orderByComparator != null) {
1064 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1065
1066 if (orderByConditionFields.length > 0) {
1067 query.append(WHERE_AND);
1068 }
1069
1070 for (int i = 0; i < orderByConditionFields.length; i++) {
1071 if (getDB().isSupportsInlineDistinct()) {
1072 query.append(_ORDER_BY_ENTITY_ALIAS);
1073 }
1074 else {
1075 query.append(_ORDER_BY_ENTITY_TABLE);
1076 }
1077
1078 query.append(orderByConditionFields[i]);
1079
1080 if ((i + 1) < orderByConditionFields.length) {
1081 if (orderByComparator.isAscending() ^ previous) {
1082 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1083 }
1084 else {
1085 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1086 }
1087 }
1088 else {
1089 if (orderByComparator.isAscending() ^ previous) {
1090 query.append(WHERE_GREATER_THAN);
1091 }
1092 else {
1093 query.append(WHERE_LESSER_THAN);
1094 }
1095 }
1096 }
1097
1098 query.append(ORDER_BY_CLAUSE);
1099
1100 String[] orderByFields = orderByComparator.getOrderByFields();
1101
1102 for (int i = 0; i < orderByFields.length; i++) {
1103 if (getDB().isSupportsInlineDistinct()) {
1104 query.append(_ORDER_BY_ENTITY_ALIAS);
1105 }
1106 else {
1107 query.append(_ORDER_BY_ENTITY_TABLE);
1108 }
1109
1110 query.append(orderByFields[i]);
1111
1112 if ((i + 1) < orderByFields.length) {
1113 if (orderByComparator.isAscending() ^ previous) {
1114 query.append(ORDER_BY_ASC_HAS_NEXT);
1115 }
1116 else {
1117 query.append(ORDER_BY_DESC_HAS_NEXT);
1118 }
1119 }
1120 else {
1121 if (orderByComparator.isAscending() ^ previous) {
1122 query.append(ORDER_BY_ASC);
1123 }
1124 else {
1125 query.append(ORDER_BY_DESC);
1126 }
1127 }
1128 }
1129 }
1130
1131 else {
1132 if (getDB().isSupportsInlineDistinct()) {
1133 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1134 }
1135 else {
1136 query.append(SCLicenseModelImpl.ORDER_BY_SQL);
1137 }
1138 }
1139
1140 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1141 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1142
1143 SQLQuery q = session.createSQLQuery(sql);
1144
1145 q.setFirstResult(0);
1146 q.setMaxResults(2);
1147
1148 if (getDB().isSupportsInlineDistinct()) {
1149 q.addEntity(_FILTER_ENTITY_ALIAS, SCLicenseImpl.class);
1150 }
1151 else {
1152 q.addEntity(_FILTER_ENTITY_TABLE, SCLicenseImpl.class);
1153 }
1154
1155 QueryPos qPos = QueryPos.getInstance(q);
1156
1157 qPos.add(active);
1158
1159 if (orderByComparator != null) {
1160 Object[] values = orderByComparator.getOrderByConditionValues(scLicense);
1161
1162 for (Object value : values) {
1163 qPos.add(value);
1164 }
1165 }
1166
1167 List<SCLicense> list = q.list();
1168
1169 if (list.size() == 2) {
1170 return list.get(1);
1171 }
1172 else {
1173 return null;
1174 }
1175 }
1176
1177
1185 public List<SCLicense> findByA_R(boolean active, boolean recommended)
1186 throws SystemException {
1187 return findByA_R(active, recommended, QueryUtil.ALL_POS,
1188 QueryUtil.ALL_POS, null);
1189 }
1190
1191
1205 public List<SCLicense> findByA_R(boolean active, boolean recommended,
1206 int start, int end) throws SystemException {
1207 return findByA_R(active, recommended, start, end, null);
1208 }
1209
1210
1225 public List<SCLicense> findByA_R(boolean active, boolean recommended,
1226 int start, int end, OrderByComparator orderByComparator)
1227 throws SystemException {
1228 FinderPath finderPath = null;
1229 Object[] finderArgs = null;
1230
1231 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1232 (orderByComparator == null)) {
1233 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_A_R;
1234 finderArgs = new Object[] { active, recommended };
1235 }
1236 else {
1237 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_A_R;
1238 finderArgs = new Object[] {
1239 active, recommended,
1240
1241 start, end, orderByComparator
1242 };
1243 }
1244
1245 List<SCLicense> list = (List<SCLicense>)FinderCacheUtil.getResult(finderPath,
1246 finderArgs, this);
1247
1248 if ((list != null) && !list.isEmpty()) {
1249 for (SCLicense scLicense : list) {
1250 if ((active != scLicense.getActive()) ||
1251 (recommended != scLicense.getRecommended())) {
1252 list = null;
1253
1254 break;
1255 }
1256 }
1257 }
1258
1259 if (list == null) {
1260 StringBundler query = null;
1261
1262 if (orderByComparator != null) {
1263 query = new StringBundler(4 +
1264 (orderByComparator.getOrderByFields().length * 3));
1265 }
1266 else {
1267 query = new StringBundler(4);
1268 }
1269
1270 query.append(_SQL_SELECT_SCLICENSE_WHERE);
1271
1272 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1273
1274 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1275
1276 if (orderByComparator != null) {
1277 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1278 orderByComparator);
1279 }
1280
1281 else {
1282 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1283 }
1284
1285 String sql = query.toString();
1286
1287 Session session = null;
1288
1289 try {
1290 session = openSession();
1291
1292 Query q = session.createQuery(sql);
1293
1294 QueryPos qPos = QueryPos.getInstance(q);
1295
1296 qPos.add(active);
1297
1298 qPos.add(recommended);
1299
1300 list = (List<SCLicense>)QueryUtil.list(q, getDialect(), start,
1301 end);
1302 }
1303 catch (Exception e) {
1304 throw processException(e);
1305 }
1306 finally {
1307 if (list == null) {
1308 FinderCacheUtil.removeResult(finderPath, finderArgs);
1309 }
1310 else {
1311 cacheResult(list);
1312
1313 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1314 }
1315
1316 closeSession(session);
1317 }
1318 }
1319
1320 return list;
1321 }
1322
1323
1337 public SCLicense findByA_R_First(boolean active, boolean recommended,
1338 OrderByComparator orderByComparator)
1339 throws NoSuchLicenseException, SystemException {
1340 List<SCLicense> list = findByA_R(active, recommended, 0, 1,
1341 orderByComparator);
1342
1343 if (list.isEmpty()) {
1344 StringBundler msg = new StringBundler(6);
1345
1346 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1347
1348 msg.append("active=");
1349 msg.append(active);
1350
1351 msg.append(", recommended=");
1352 msg.append(recommended);
1353
1354 msg.append(StringPool.CLOSE_CURLY_BRACE);
1355
1356 throw new NoSuchLicenseException(msg.toString());
1357 }
1358 else {
1359 return list.get(0);
1360 }
1361 }
1362
1363
1377 public SCLicense findByA_R_Last(boolean active, boolean recommended,
1378 OrderByComparator orderByComparator)
1379 throws NoSuchLicenseException, SystemException {
1380 int count = countByA_R(active, recommended);
1381
1382 List<SCLicense> list = findByA_R(active, recommended, count - 1, count,
1383 orderByComparator);
1384
1385 if (list.isEmpty()) {
1386 StringBundler msg = new StringBundler(6);
1387
1388 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1389
1390 msg.append("active=");
1391 msg.append(active);
1392
1393 msg.append(", recommended=");
1394 msg.append(recommended);
1395
1396 msg.append(StringPool.CLOSE_CURLY_BRACE);
1397
1398 throw new NoSuchLicenseException(msg.toString());
1399 }
1400 else {
1401 return list.get(0);
1402 }
1403 }
1404
1405
1420 public SCLicense[] findByA_R_PrevAndNext(long licenseId, boolean active,
1421 boolean recommended, OrderByComparator orderByComparator)
1422 throws NoSuchLicenseException, SystemException {
1423 SCLicense scLicense = findByPrimaryKey(licenseId);
1424
1425 Session session = null;
1426
1427 try {
1428 session = openSession();
1429
1430 SCLicense[] array = new SCLicenseImpl[3];
1431
1432 array[0] = getByA_R_PrevAndNext(session, scLicense, active,
1433 recommended, orderByComparator, true);
1434
1435 array[1] = scLicense;
1436
1437 array[2] = getByA_R_PrevAndNext(session, scLicense, active,
1438 recommended, orderByComparator, false);
1439
1440 return array;
1441 }
1442 catch (Exception e) {
1443 throw processException(e);
1444 }
1445 finally {
1446 closeSession(session);
1447 }
1448 }
1449
1450 protected SCLicense getByA_R_PrevAndNext(Session session,
1451 SCLicense scLicense, boolean active, boolean recommended,
1452 OrderByComparator orderByComparator, boolean previous) {
1453 StringBundler query = null;
1454
1455 if (orderByComparator != null) {
1456 query = new StringBundler(6 +
1457 (orderByComparator.getOrderByFields().length * 6));
1458 }
1459 else {
1460 query = new StringBundler(3);
1461 }
1462
1463 query.append(_SQL_SELECT_SCLICENSE_WHERE);
1464
1465 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1466
1467 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1468
1469 if (orderByComparator != null) {
1470 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1471
1472 if (orderByConditionFields.length > 0) {
1473 query.append(WHERE_AND);
1474 }
1475
1476 for (int i = 0; i < orderByConditionFields.length; i++) {
1477 query.append(_ORDER_BY_ENTITY_ALIAS);
1478 query.append(orderByConditionFields[i]);
1479
1480 if ((i + 1) < orderByConditionFields.length) {
1481 if (orderByComparator.isAscending() ^ previous) {
1482 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1483 }
1484 else {
1485 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1486 }
1487 }
1488 else {
1489 if (orderByComparator.isAscending() ^ previous) {
1490 query.append(WHERE_GREATER_THAN);
1491 }
1492 else {
1493 query.append(WHERE_LESSER_THAN);
1494 }
1495 }
1496 }
1497
1498 query.append(ORDER_BY_CLAUSE);
1499
1500 String[] orderByFields = orderByComparator.getOrderByFields();
1501
1502 for (int i = 0; i < orderByFields.length; i++) {
1503 query.append(_ORDER_BY_ENTITY_ALIAS);
1504 query.append(orderByFields[i]);
1505
1506 if ((i + 1) < orderByFields.length) {
1507 if (orderByComparator.isAscending() ^ previous) {
1508 query.append(ORDER_BY_ASC_HAS_NEXT);
1509 }
1510 else {
1511 query.append(ORDER_BY_DESC_HAS_NEXT);
1512 }
1513 }
1514 else {
1515 if (orderByComparator.isAscending() ^ previous) {
1516 query.append(ORDER_BY_ASC);
1517 }
1518 else {
1519 query.append(ORDER_BY_DESC);
1520 }
1521 }
1522 }
1523 }
1524
1525 else {
1526 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1527 }
1528
1529 String sql = query.toString();
1530
1531 Query q = session.createQuery(sql);
1532
1533 q.setFirstResult(0);
1534 q.setMaxResults(2);
1535
1536 QueryPos qPos = QueryPos.getInstance(q);
1537
1538 qPos.add(active);
1539
1540 qPos.add(recommended);
1541
1542 if (orderByComparator != null) {
1543 Object[] values = orderByComparator.getOrderByConditionValues(scLicense);
1544
1545 for (Object value : values) {
1546 qPos.add(value);
1547 }
1548 }
1549
1550 List<SCLicense> list = q.list();
1551
1552 if (list.size() == 2) {
1553 return list.get(1);
1554 }
1555 else {
1556 return null;
1557 }
1558 }
1559
1560
1568 public List<SCLicense> filterFindByA_R(boolean active, boolean recommended)
1569 throws SystemException {
1570 return filterFindByA_R(active, recommended, QueryUtil.ALL_POS,
1571 QueryUtil.ALL_POS, null);
1572 }
1573
1574
1588 public List<SCLicense> filterFindByA_R(boolean active, boolean recommended,
1589 int start, int end) throws SystemException {
1590 return filterFindByA_R(active, recommended, start, end, null);
1591 }
1592
1593
1608 public List<SCLicense> filterFindByA_R(boolean active, boolean recommended,
1609 int start, int end, OrderByComparator orderByComparator)
1610 throws SystemException {
1611 if (!InlineSQLHelperUtil.isEnabled()) {
1612 return findByA_R(active, recommended, start, end, orderByComparator);
1613 }
1614
1615 StringBundler query = null;
1616
1617 if (orderByComparator != null) {
1618 query = new StringBundler(4 +
1619 (orderByComparator.getOrderByFields().length * 3));
1620 }
1621 else {
1622 query = new StringBundler(4);
1623 }
1624
1625 if (getDB().isSupportsInlineDistinct()) {
1626 query.append(_FILTER_SQL_SELECT_SCLICENSE_WHERE);
1627 }
1628 else {
1629 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1);
1630 }
1631
1632 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1633
1634 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1635
1636 if (!getDB().isSupportsInlineDistinct()) {
1637 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2);
1638 }
1639
1640 if (orderByComparator != null) {
1641 if (getDB().isSupportsInlineDistinct()) {
1642 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1643 orderByComparator);
1644 }
1645 else {
1646 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1647 orderByComparator);
1648 }
1649 }
1650
1651 else {
1652 if (getDB().isSupportsInlineDistinct()) {
1653 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1654 }
1655 else {
1656 query.append(SCLicenseModelImpl.ORDER_BY_SQL);
1657 }
1658 }
1659
1660 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1661 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1662
1663 Session session = null;
1664
1665 try {
1666 session = openSession();
1667
1668 SQLQuery q = session.createSQLQuery(sql);
1669
1670 if (getDB().isSupportsInlineDistinct()) {
1671 q.addEntity(_FILTER_ENTITY_ALIAS, SCLicenseImpl.class);
1672 }
1673 else {
1674 q.addEntity(_FILTER_ENTITY_TABLE, SCLicenseImpl.class);
1675 }
1676
1677 QueryPos qPos = QueryPos.getInstance(q);
1678
1679 qPos.add(active);
1680
1681 qPos.add(recommended);
1682
1683 return (List<SCLicense>)QueryUtil.list(q, getDialect(), start, end);
1684 }
1685 catch (Exception e) {
1686 throw processException(e);
1687 }
1688 finally {
1689 closeSession(session);
1690 }
1691 }
1692
1693
1704 public SCLicense[] filterFindByA_R_PrevAndNext(long licenseId,
1705 boolean active, boolean recommended, OrderByComparator orderByComparator)
1706 throws NoSuchLicenseException, SystemException {
1707 if (!InlineSQLHelperUtil.isEnabled()) {
1708 return findByA_R_PrevAndNext(licenseId, active, recommended,
1709 orderByComparator);
1710 }
1711
1712 SCLicense scLicense = findByPrimaryKey(licenseId);
1713
1714 Session session = null;
1715
1716 try {
1717 session = openSession();
1718
1719 SCLicense[] array = new SCLicenseImpl[3];
1720
1721 array[0] = filterGetByA_R_PrevAndNext(session, scLicense, active,
1722 recommended, orderByComparator, true);
1723
1724 array[1] = scLicense;
1725
1726 array[2] = filterGetByA_R_PrevAndNext(session, scLicense, active,
1727 recommended, orderByComparator, false);
1728
1729 return array;
1730 }
1731 catch (Exception e) {
1732 throw processException(e);
1733 }
1734 finally {
1735 closeSession(session);
1736 }
1737 }
1738
1739 protected SCLicense filterGetByA_R_PrevAndNext(Session session,
1740 SCLicense scLicense, boolean active, boolean recommended,
1741 OrderByComparator orderByComparator, boolean previous) {
1742 StringBundler query = null;
1743
1744 if (orderByComparator != null) {
1745 query = new StringBundler(6 +
1746 (orderByComparator.getOrderByFields().length * 6));
1747 }
1748 else {
1749 query = new StringBundler(3);
1750 }
1751
1752 if (getDB().isSupportsInlineDistinct()) {
1753 query.append(_FILTER_SQL_SELECT_SCLICENSE_WHERE);
1754 }
1755 else {
1756 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1);
1757 }
1758
1759 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1760
1761 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1762
1763 if (!getDB().isSupportsInlineDistinct()) {
1764 query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2);
1765 }
1766
1767 if (orderByComparator != null) {
1768 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1769
1770 if (orderByConditionFields.length > 0) {
1771 query.append(WHERE_AND);
1772 }
1773
1774 for (int i = 0; i < orderByConditionFields.length; i++) {
1775 if (getDB().isSupportsInlineDistinct()) {
1776 query.append(_ORDER_BY_ENTITY_ALIAS);
1777 }
1778 else {
1779 query.append(_ORDER_BY_ENTITY_TABLE);
1780 }
1781
1782 query.append(orderByConditionFields[i]);
1783
1784 if ((i + 1) < orderByConditionFields.length) {
1785 if (orderByComparator.isAscending() ^ previous) {
1786 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1787 }
1788 else {
1789 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1790 }
1791 }
1792 else {
1793 if (orderByComparator.isAscending() ^ previous) {
1794 query.append(WHERE_GREATER_THAN);
1795 }
1796 else {
1797 query.append(WHERE_LESSER_THAN);
1798 }
1799 }
1800 }
1801
1802 query.append(ORDER_BY_CLAUSE);
1803
1804 String[] orderByFields = orderByComparator.getOrderByFields();
1805
1806 for (int i = 0; i < orderByFields.length; i++) {
1807 if (getDB().isSupportsInlineDistinct()) {
1808 query.append(_ORDER_BY_ENTITY_ALIAS);
1809 }
1810 else {
1811 query.append(_ORDER_BY_ENTITY_TABLE);
1812 }
1813
1814 query.append(orderByFields[i]);
1815
1816 if ((i + 1) < orderByFields.length) {
1817 if (orderByComparator.isAscending() ^ previous) {
1818 query.append(ORDER_BY_ASC_HAS_NEXT);
1819 }
1820 else {
1821 query.append(ORDER_BY_DESC_HAS_NEXT);
1822 }
1823 }
1824 else {
1825 if (orderByComparator.isAscending() ^ previous) {
1826 query.append(ORDER_BY_ASC);
1827 }
1828 else {
1829 query.append(ORDER_BY_DESC);
1830 }
1831 }
1832 }
1833 }
1834
1835 else {
1836 if (getDB().isSupportsInlineDistinct()) {
1837 query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1838 }
1839 else {
1840 query.append(SCLicenseModelImpl.ORDER_BY_SQL);
1841 }
1842 }
1843
1844 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1845 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1846
1847 SQLQuery q = session.createSQLQuery(sql);
1848
1849 q.setFirstResult(0);
1850 q.setMaxResults(2);
1851
1852 if (getDB().isSupportsInlineDistinct()) {
1853 q.addEntity(_FILTER_ENTITY_ALIAS, SCLicenseImpl.class);
1854 }
1855 else {
1856 q.addEntity(_FILTER_ENTITY_TABLE, SCLicenseImpl.class);
1857 }
1858
1859 QueryPos qPos = QueryPos.getInstance(q);
1860
1861 qPos.add(active);
1862
1863 qPos.add(recommended);
1864
1865 if (orderByComparator != null) {
1866 Object[] values = orderByComparator.getOrderByConditionValues(scLicense);
1867
1868 for (Object value : values) {
1869 qPos.add(value);
1870 }
1871 }
1872
1873 List<SCLicense> list = q.list();
1874
1875 if (list.size() == 2) {
1876 return list.get(1);
1877 }
1878 else {
1879 return null;
1880 }
1881 }
1882
1883
1889 public List<SCLicense> findAll() throws SystemException {
1890 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1891 }
1892
1893
1905 public List<SCLicense> findAll(int start, int end)
1906 throws SystemException {
1907 return findAll(start, end, null);
1908 }
1909
1910
1923 public List<SCLicense> findAll(int start, int end,
1924 OrderByComparator orderByComparator) throws SystemException {
1925 FinderPath finderPath = null;
1926 Object[] finderArgs = new Object[] { start, end, orderByComparator };
1927
1928 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1929 (orderByComparator == null)) {
1930 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1931 finderArgs = FINDER_ARGS_EMPTY;
1932 }
1933 else {
1934 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1935 finderArgs = new Object[] { start, end, orderByComparator };
1936 }
1937
1938 List<SCLicense> list = (List<SCLicense>)FinderCacheUtil.getResult(finderPath,
1939 finderArgs, this);
1940
1941 if (list == null) {
1942 StringBundler query = null;
1943 String sql = null;
1944
1945 if (orderByComparator != null) {
1946 query = new StringBundler(2 +
1947 (orderByComparator.getOrderByFields().length * 3));
1948
1949 query.append(_SQL_SELECT_SCLICENSE);
1950
1951 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1952 orderByComparator);
1953
1954 sql = query.toString();
1955 }
1956 else {
1957 sql = _SQL_SELECT_SCLICENSE.concat(SCLicenseModelImpl.ORDER_BY_JPQL);
1958 }
1959
1960 Session session = null;
1961
1962 try {
1963 session = openSession();
1964
1965 Query q = session.createQuery(sql);
1966
1967 if (orderByComparator == null) {
1968 list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
1969 start, end, false);
1970
1971 Collections.sort(list);
1972 }
1973 else {
1974 list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
1975 start, end);
1976 }
1977 }
1978 catch (Exception e) {
1979 throw processException(e);
1980 }
1981 finally {
1982 if (list == null) {
1983 FinderCacheUtil.removeResult(finderPath, finderArgs);
1984 }
1985 else {
1986 cacheResult(list);
1987
1988 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1989 }
1990
1991 closeSession(session);
1992 }
1993 }
1994
1995 return list;
1996 }
1997
1998
2004 public void removeByActive(boolean active) throws SystemException {
2005 for (SCLicense scLicense : findByActive(active)) {
2006 remove(scLicense);
2007 }
2008 }
2009
2010
2017 public void removeByA_R(boolean active, boolean recommended)
2018 throws SystemException {
2019 for (SCLicense scLicense : findByA_R(active, recommended)) {
2020 remove(scLicense);
2021 }
2022 }
2023
2024
2029 public void removeAll() throws SystemException {
2030 for (SCLicense scLicense : findAll()) {
2031 remove(scLicense);
2032 }
2033 }
2034
2035
2042 public int countByActive(boolean active) throws SystemException {
2043 Object[] finderArgs = new Object[] { active };
2044
2045 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ACTIVE,
2046 finderArgs, this);
2047
2048 if (count == null) {
2049 StringBundler query = new StringBundler(2);
2050
2051 query.append(_SQL_COUNT_SCLICENSE_WHERE);
2052
2053 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
2054
2055 String sql = query.toString();
2056
2057 Session session = null;
2058
2059 try {
2060 session = openSession();
2061
2062 Query q = session.createQuery(sql);
2063
2064 QueryPos qPos = QueryPos.getInstance(q);
2065
2066 qPos.add(active);
2067
2068 count = (Long)q.uniqueResult();
2069 }
2070 catch (Exception e) {
2071 throw processException(e);
2072 }
2073 finally {
2074 if (count == null) {
2075 count = Long.valueOf(0);
2076 }
2077
2078 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ACTIVE,
2079 finderArgs, count);
2080
2081 closeSession(session);
2082 }
2083 }
2084
2085 return count.intValue();
2086 }
2087
2088
2095 public int filterCountByActive(boolean active) throws SystemException {
2096 if (!InlineSQLHelperUtil.isEnabled()) {
2097 return countByActive(active);
2098 }
2099
2100 StringBundler query = new StringBundler(2);
2101
2102 query.append(_FILTER_SQL_COUNT_SCLICENSE_WHERE);
2103
2104 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
2105
2106 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2107 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2108
2109 Session session = null;
2110
2111 try {
2112 session = openSession();
2113
2114 SQLQuery q = session.createSQLQuery(sql);
2115
2116 q.addScalar(COUNT_COLUMN_NAME,
2117 com.liferay.portal.kernel.dao.orm.Type.LONG);
2118
2119 QueryPos qPos = QueryPos.getInstance(q);
2120
2121 qPos.add(active);
2122
2123 Long count = (Long)q.uniqueResult();
2124
2125 return count.intValue();
2126 }
2127 catch (Exception e) {
2128 throw processException(e);
2129 }
2130 finally {
2131 closeSession(session);
2132 }
2133 }
2134
2135
2143 public int countByA_R(boolean active, boolean recommended)
2144 throws SystemException {
2145 Object[] finderArgs = new Object[] { active, recommended };
2146
2147 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_A_R,
2148 finderArgs, this);
2149
2150 if (count == null) {
2151 StringBundler query = new StringBundler(3);
2152
2153 query.append(_SQL_COUNT_SCLICENSE_WHERE);
2154
2155 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
2156
2157 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
2158
2159 String sql = query.toString();
2160
2161 Session session = null;
2162
2163 try {
2164 session = openSession();
2165
2166 Query q = session.createQuery(sql);
2167
2168 QueryPos qPos = QueryPos.getInstance(q);
2169
2170 qPos.add(active);
2171
2172 qPos.add(recommended);
2173
2174 count = (Long)q.uniqueResult();
2175 }
2176 catch (Exception e) {
2177 throw processException(e);
2178 }
2179 finally {
2180 if (count == null) {
2181 count = Long.valueOf(0);
2182 }
2183
2184 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_A_R, finderArgs,
2185 count);
2186
2187 closeSession(session);
2188 }
2189 }
2190
2191 return count.intValue();
2192 }
2193
2194
2202 public int filterCountByA_R(boolean active, boolean recommended)
2203 throws SystemException {
2204 if (!InlineSQLHelperUtil.isEnabled()) {
2205 return countByA_R(active, recommended);
2206 }
2207
2208 StringBundler query = new StringBundler(3);
2209
2210 query.append(_FILTER_SQL_COUNT_SCLICENSE_WHERE);
2211
2212 query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
2213
2214 query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
2215
2216 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2217 SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2218
2219 Session session = null;
2220
2221 try {
2222 session = openSession();
2223
2224 SQLQuery q = session.createSQLQuery(sql);
2225
2226 q.addScalar(COUNT_COLUMN_NAME,
2227 com.liferay.portal.kernel.dao.orm.Type.LONG);
2228
2229 QueryPos qPos = QueryPos.getInstance(q);
2230
2231 qPos.add(active);
2232
2233 qPos.add(recommended);
2234
2235 Long count = (Long)q.uniqueResult();
2236
2237 return count.intValue();
2238 }
2239 catch (Exception e) {
2240 throw processException(e);
2241 }
2242 finally {
2243 closeSession(session);
2244 }
2245 }
2246
2247
2253 public int countAll() throws SystemException {
2254 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2255 FINDER_ARGS_EMPTY, this);
2256
2257 if (count == null) {
2258 Session session = null;
2259
2260 try {
2261 session = openSession();
2262
2263 Query q = session.createQuery(_SQL_COUNT_SCLICENSE);
2264
2265 count = (Long)q.uniqueResult();
2266 }
2267 catch (Exception e) {
2268 throw processException(e);
2269 }
2270 finally {
2271 if (count == null) {
2272 count = Long.valueOf(0);
2273 }
2274
2275 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2276 FINDER_ARGS_EMPTY, count);
2277
2278 closeSession(session);
2279 }
2280 }
2281
2282 return count.intValue();
2283 }
2284
2285
2292 public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
2293 long pk) throws SystemException {
2294 return getSCProductEntries(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2295 }
2296
2297
2310 public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
2311 long pk, int start, int end) throws SystemException {
2312 return getSCProductEntries(pk, start, end, null);
2313 }
2314
2315 public static final FinderPath FINDER_PATH_GET_SCPRODUCTENTRIES = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
2316 SCLicenseModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
2317 com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryImpl.class,
2318 SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
2319 "getSCProductEntries",
2320 new String[] {
2321 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
2322 "com.liferay.portal.kernel.util.OrderByComparator"
2323 });
2324
2325 static {
2326 FINDER_PATH_GET_SCPRODUCTENTRIES.setCacheKeyGeneratorCacheName(null);
2327 }
2328
2329
2343 public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
2344 long pk, int start, int end, OrderByComparator orderByComparator)
2345 throws SystemException {
2346 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
2347
2348 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> list = (List<com.liferay.portlet.softwarecatalog.model.SCProductEntry>)FinderCacheUtil.getResult(FINDER_PATH_GET_SCPRODUCTENTRIES,
2349 finderArgs, this);
2350
2351 if (list == null) {
2352 Session session = null;
2353
2354 try {
2355 session = openSession();
2356
2357 String sql = null;
2358
2359 if (orderByComparator != null) {
2360 sql = _SQL_GETSCPRODUCTENTRIES.concat(ORDER_BY_CLAUSE)
2361 .concat(orderByComparator.getOrderBy());
2362 }
2363 else {
2364 sql = _SQL_GETSCPRODUCTENTRIES.concat(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ORDER_BY_SQL);
2365 }
2366
2367 SQLQuery q = session.createSQLQuery(sql);
2368
2369 q.addEntity("SCProductEntry",
2370 com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryImpl.class);
2371
2372 QueryPos qPos = QueryPos.getInstance(q);
2373
2374 qPos.add(pk);
2375
2376 list = (List<com.liferay.portlet.softwarecatalog.model.SCProductEntry>)QueryUtil.list(q,
2377 getDialect(), start, end);
2378 }
2379 catch (Exception e) {
2380 throw processException(e);
2381 }
2382 finally {
2383 if (list == null) {
2384 FinderCacheUtil.removeResult(FINDER_PATH_GET_SCPRODUCTENTRIES,
2385 finderArgs);
2386 }
2387 else {
2388 scProductEntryPersistence.cacheResult(list);
2389
2390 FinderCacheUtil.putResult(FINDER_PATH_GET_SCPRODUCTENTRIES,
2391 finderArgs, list);
2392 }
2393
2394 closeSession(session);
2395 }
2396 }
2397
2398 return list;
2399 }
2400
2401 public static final FinderPath FINDER_PATH_GET_SCPRODUCTENTRIES_SIZE = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
2402 SCLicenseModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
2403 Long.class,
2404 SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
2405 "getSCProductEntriesSize", new String[] { Long.class.getName() });
2406
2407 static {
2408 FINDER_PATH_GET_SCPRODUCTENTRIES_SIZE.setCacheKeyGeneratorCacheName(null);
2409 }
2410
2411
2418 public int getSCProductEntriesSize(long pk) throws SystemException {
2419 Object[] finderArgs = new Object[] { pk };
2420
2421 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_SCPRODUCTENTRIES_SIZE,
2422 finderArgs, this);
2423
2424 if (count == null) {
2425 Session session = null;
2426
2427 try {
2428 session = openSession();
2429
2430 SQLQuery q = session.createSQLQuery(_SQL_GETSCPRODUCTENTRIESSIZE);
2431
2432 q.addScalar(COUNT_COLUMN_NAME,
2433 com.liferay.portal.kernel.dao.orm.Type.LONG);
2434
2435 QueryPos qPos = QueryPos.getInstance(q);
2436
2437 qPos.add(pk);
2438
2439 count = (Long)q.uniqueResult();
2440 }
2441 catch (Exception e) {
2442 throw processException(e);
2443 }
2444 finally {
2445 if (count == null) {
2446 count = Long.valueOf(0);
2447 }
2448
2449 FinderCacheUtil.putResult(FINDER_PATH_GET_SCPRODUCTENTRIES_SIZE,
2450 finderArgs, count);
2451
2452 closeSession(session);
2453 }
2454 }
2455
2456 return count.intValue();
2457 }
2458
2459 public static final FinderPath FINDER_PATH_CONTAINS_SCPRODUCTENTRY = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
2460 SCLicenseModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
2461 Boolean.class,
2462 SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
2463 "containsSCProductEntry",
2464 new String[] { Long.class.getName(), Long.class.getName() });
2465
2466
2474 public boolean containsSCProductEntry(long pk, long scProductEntryPK)
2475 throws SystemException {
2476 Object[] finderArgs = new Object[] { pk, scProductEntryPK };
2477
2478 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_SCPRODUCTENTRY,
2479 finderArgs, this);
2480
2481 if (value == null) {
2482 try {
2483 value = Boolean.valueOf(containsSCProductEntry.contains(pk,
2484 scProductEntryPK));
2485 }
2486 catch (Exception e) {
2487 throw processException(e);
2488 }
2489 finally {
2490 if (value == null) {
2491 value = Boolean.FALSE;
2492 }
2493
2494 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_SCPRODUCTENTRY,
2495 finderArgs, value);
2496 }
2497 }
2498
2499 return value.booleanValue();
2500 }
2501
2502
2509 public boolean containsSCProductEntries(long pk) throws SystemException {
2510 if (getSCProductEntriesSize(pk) > 0) {
2511 return true;
2512 }
2513 else {
2514 return false;
2515 }
2516 }
2517
2518
2525 public void addSCProductEntry(long pk, long scProductEntryPK)
2526 throws SystemException {
2527 try {
2528 addSCProductEntry.add(pk, scProductEntryPK);
2529 }
2530 catch (Exception e) {
2531 throw processException(e);
2532 }
2533 finally {
2534 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2535 }
2536 }
2537
2538
2545 public void addSCProductEntry(long pk,
2546 com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry)
2547 throws SystemException {
2548 try {
2549 addSCProductEntry.add(pk, scProductEntry.getPrimaryKey());
2550 }
2551 catch (Exception e) {
2552 throw processException(e);
2553 }
2554 finally {
2555 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2556 }
2557 }
2558
2559
2566 public void addSCProductEntries(long pk, long[] scProductEntryPKs)
2567 throws SystemException {
2568 try {
2569 for (long scProductEntryPK : scProductEntryPKs) {
2570 addSCProductEntry.add(pk, scProductEntryPK);
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
2588 public void addSCProductEntries(long pk,
2589 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries)
2590 throws SystemException {
2591 try {
2592 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2593 addSCProductEntry.add(pk, scProductEntry.getPrimaryKey());
2594 }
2595 }
2596 catch (Exception e) {
2597 throw processException(e);
2598 }
2599 finally {
2600 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2601 }
2602 }
2603
2604
2610 public void clearSCProductEntries(long pk) throws SystemException {
2611 try {
2612 clearSCProductEntries.clear(pk);
2613 }
2614 catch (Exception e) {
2615 throw processException(e);
2616 }
2617 finally {
2618 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2619 }
2620 }
2621
2622
2629 public void removeSCProductEntry(long pk, long scProductEntryPK)
2630 throws SystemException {
2631 try {
2632 removeSCProductEntry.remove(pk, scProductEntryPK);
2633 }
2634 catch (Exception e) {
2635 throw processException(e);
2636 }
2637 finally {
2638 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2639 }
2640 }
2641
2642
2649 public void removeSCProductEntry(long pk,
2650 com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry)
2651 throws SystemException {
2652 try {
2653 removeSCProductEntry.remove(pk, scProductEntry.getPrimaryKey());
2654 }
2655 catch (Exception e) {
2656 throw processException(e);
2657 }
2658 finally {
2659 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2660 }
2661 }
2662
2663
2670 public void removeSCProductEntries(long pk, long[] scProductEntryPKs)
2671 throws SystemException {
2672 try {
2673 for (long scProductEntryPK : scProductEntryPKs) {
2674 removeSCProductEntry.remove(pk, scProductEntryPK);
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 removeSCProductEntries(long pk,
2693 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries)
2694 throws SystemException {
2695 try {
2696 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2697 removeSCProductEntry.remove(pk, scProductEntry.getPrimaryKey());
2698 }
2699 }
2700 catch (Exception e) {
2701 throw processException(e);
2702 }
2703 finally {
2704 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2705 }
2706 }
2707
2708
2715 public void setSCProductEntries(long pk, long[] scProductEntryPKs)
2716 throws SystemException {
2717 try {
2718 Set<Long> scProductEntryPKSet = SetUtil.fromArray(scProductEntryPKs);
2719
2720 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries =
2721 getSCProductEntries(pk);
2722
2723 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2724 if (!scProductEntryPKSet.remove(scProductEntry.getPrimaryKey())) {
2725 removeSCProductEntry.remove(pk,
2726 scProductEntry.getPrimaryKey());
2727 }
2728 }
2729
2730 for (Long scProductEntryPK : scProductEntryPKSet) {
2731 addSCProductEntry.add(pk, scProductEntryPK);
2732 }
2733 }
2734 catch (Exception e) {
2735 throw processException(e);
2736 }
2737 finally {
2738 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2739 }
2740 }
2741
2742
2749 public void setSCProductEntries(long pk,
2750 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries)
2751 throws SystemException {
2752 try {
2753 long[] scProductEntryPKs = new long[scProductEntries.size()];
2754
2755 for (int i = 0; i < scProductEntries.size(); i++) {
2756 com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry =
2757 scProductEntries.get(i);
2758
2759 scProductEntryPKs[i] = scProductEntry.getPrimaryKey();
2760 }
2761
2762 setSCProductEntries(pk, scProductEntryPKs);
2763 }
2764 catch (Exception e) {
2765 throw processException(e);
2766 }
2767 finally {
2768 FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2769 }
2770 }
2771
2772
2775 public void afterPropertiesSet() {
2776 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2777 com.liferay.portal.util.PropsUtil.get(
2778 "value.object.listener.com.liferay.portlet.softwarecatalog.model.SCLicense")));
2779
2780 if (listenerClassNames.length > 0) {
2781 try {
2782 List<ModelListener<SCLicense>> listenersList = new ArrayList<ModelListener<SCLicense>>();
2783
2784 for (String listenerClassName : listenerClassNames) {
2785 listenersList.add((ModelListener<SCLicense>)InstanceFactory.newInstance(
2786 listenerClassName));
2787 }
2788
2789 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2790 }
2791 catch (Exception e) {
2792 _log.error(e);
2793 }
2794 }
2795
2796 containsSCProductEntry = new ContainsSCProductEntry();
2797
2798 addSCProductEntry = new AddSCProductEntry();
2799 clearSCProductEntries = new ClearSCProductEntries();
2800 removeSCProductEntry = new RemoveSCProductEntry();
2801 }
2802
2803 public void destroy() {
2804 EntityCacheUtil.removeCache(SCLicenseImpl.class.getName());
2805 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2806 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2807 }
2808
2809 @BeanReference(type = SCFrameworkVersionPersistence.class)
2810 protected SCFrameworkVersionPersistence scFrameworkVersionPersistence;
2811 @BeanReference(type = SCLicensePersistence.class)
2812 protected SCLicensePersistence scLicensePersistence;
2813 @BeanReference(type = SCProductEntryPersistence.class)
2814 protected SCProductEntryPersistence scProductEntryPersistence;
2815 @BeanReference(type = SCProductScreenshotPersistence.class)
2816 protected SCProductScreenshotPersistence scProductScreenshotPersistence;
2817 @BeanReference(type = SCProductVersionPersistence.class)
2818 protected SCProductVersionPersistence scProductVersionPersistence;
2819 @BeanReference(type = ResourcePersistence.class)
2820 protected ResourcePersistence resourcePersistence;
2821 @BeanReference(type = UserPersistence.class)
2822 protected UserPersistence userPersistence;
2823 protected ContainsSCProductEntry containsSCProductEntry;
2824 protected AddSCProductEntry addSCProductEntry;
2825 protected ClearSCProductEntries clearSCProductEntries;
2826 protected RemoveSCProductEntry removeSCProductEntry;
2827
2828 protected class ContainsSCProductEntry {
2829 protected ContainsSCProductEntry() {
2830 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2831 _SQL_CONTAINSSCPRODUCTENTRY,
2832 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
2833 RowMapper.COUNT);
2834 }
2835
2836 protected boolean contains(long licenseId, long productEntryId) {
2837 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2838 new Long(licenseId), new Long(productEntryId)
2839 });
2840
2841 if (results.size() > 0) {
2842 Integer count = results.get(0);
2843
2844 if (count.intValue() > 0) {
2845 return true;
2846 }
2847 }
2848
2849 return false;
2850 }
2851
2852 private MappingSqlQuery<Integer> _mappingSqlQuery;
2853 }
2854
2855 protected class AddSCProductEntry {
2856 protected AddSCProductEntry() {
2857 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2858 "INSERT INTO SCLicenses_SCProductEntries (licenseId, productEntryId) VALUES (?, ?)",
2859 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2860 }
2861
2862 protected void add(long licenseId, long productEntryId)
2863 throws SystemException {
2864 if (!containsSCProductEntry.contains(licenseId, productEntryId)) {
2865 ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry>[] scProductEntryListeners =
2866 scProductEntryPersistence.getListeners();
2867
2868 for (ModelListener<SCLicense> listener : listeners) {
2869 listener.onBeforeAddAssociation(licenseId,
2870 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2871 productEntryId);
2872 }
2873
2874 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2875 listener.onBeforeAddAssociation(productEntryId,
2876 SCLicense.class.getName(), licenseId);
2877 }
2878
2879 _sqlUpdate.update(new Object[] {
2880 new Long(licenseId), new Long(productEntryId)
2881 });
2882
2883 for (ModelListener<SCLicense> listener : listeners) {
2884 listener.onAfterAddAssociation(licenseId,
2885 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2886 productEntryId);
2887 }
2888
2889 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2890 listener.onAfterAddAssociation(productEntryId,
2891 SCLicense.class.getName(), licenseId);
2892 }
2893 }
2894 }
2895
2896 private SqlUpdate _sqlUpdate;
2897 }
2898
2899 protected class ClearSCProductEntries {
2900 protected ClearSCProductEntries() {
2901 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2902 "DELETE FROM SCLicenses_SCProductEntries WHERE licenseId = ?",
2903 new int[] { java.sql.Types.BIGINT });
2904 }
2905
2906 protected void clear(long licenseId) throws SystemException {
2907 ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry>[] scProductEntryListeners =
2908 scProductEntryPersistence.getListeners();
2909
2910 List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries =
2911 null;
2912
2913 if ((listeners.length > 0) || (scProductEntryListeners.length > 0)) {
2914 scProductEntries = getSCProductEntries(licenseId);
2915
2916 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2917 for (ModelListener<SCLicense> listener : listeners) {
2918 listener.onBeforeRemoveAssociation(licenseId,
2919 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2920 scProductEntry.getPrimaryKey());
2921 }
2922
2923 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2924 listener.onBeforeRemoveAssociation(scProductEntry.getPrimaryKey(),
2925 SCLicense.class.getName(), licenseId);
2926 }
2927 }
2928 }
2929
2930 _sqlUpdate.update(new Object[] { new Long(licenseId) });
2931
2932 if ((listeners.length > 0) || (scProductEntryListeners.length > 0)) {
2933 for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2934 for (ModelListener<SCLicense> listener : listeners) {
2935 listener.onAfterRemoveAssociation(licenseId,
2936 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2937 scProductEntry.getPrimaryKey());
2938 }
2939
2940 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2941 listener.onAfterRemoveAssociation(scProductEntry.getPrimaryKey(),
2942 SCLicense.class.getName(), licenseId);
2943 }
2944 }
2945 }
2946 }
2947
2948 private SqlUpdate _sqlUpdate;
2949 }
2950
2951 protected class RemoveSCProductEntry {
2952 protected RemoveSCProductEntry() {
2953 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2954 "DELETE FROM SCLicenses_SCProductEntries WHERE licenseId = ? AND productEntryId = ?",
2955 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2956 }
2957
2958 protected void remove(long licenseId, long productEntryId)
2959 throws SystemException {
2960 if (containsSCProductEntry.contains(licenseId, productEntryId)) {
2961 ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry>[] scProductEntryListeners =
2962 scProductEntryPersistence.getListeners();
2963
2964 for (ModelListener<SCLicense> listener : listeners) {
2965 listener.onBeforeRemoveAssociation(licenseId,
2966 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2967 productEntryId);
2968 }
2969
2970 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2971 listener.onBeforeRemoveAssociation(productEntryId,
2972 SCLicense.class.getName(), licenseId);
2973 }
2974
2975 _sqlUpdate.update(new Object[] {
2976 new Long(licenseId), new Long(productEntryId)
2977 });
2978
2979 for (ModelListener<SCLicense> listener : listeners) {
2980 listener.onAfterRemoveAssociation(licenseId,
2981 com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2982 productEntryId);
2983 }
2984
2985 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2986 listener.onAfterRemoveAssociation(productEntryId,
2987 SCLicense.class.getName(), licenseId);
2988 }
2989 }
2990 }
2991
2992 private SqlUpdate _sqlUpdate;
2993 }
2994
2995 private static final String _SQL_SELECT_SCLICENSE = "SELECT scLicense FROM SCLicense scLicense";
2996 private static final String _SQL_SELECT_SCLICENSE_WHERE = "SELECT scLicense FROM SCLicense scLicense WHERE ";
2997 private static final String _SQL_COUNT_SCLICENSE = "SELECT COUNT(scLicense) FROM SCLicense scLicense";
2998 private static final String _SQL_COUNT_SCLICENSE_WHERE = "SELECT COUNT(scLicense) FROM SCLicense scLicense WHERE ";
2999 private static final String _SQL_GETSCPRODUCTENTRIES = "SELECT {SCProductEntry.*} FROM SCProductEntry INNER JOIN SCLicenses_SCProductEntries ON (SCLicenses_SCProductEntries.productEntryId = SCProductEntry.productEntryId) WHERE (SCLicenses_SCProductEntries.licenseId = ?)";
3000 private static final String _SQL_GETSCPRODUCTENTRIESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE licenseId = ?";
3001 private static final String _SQL_CONTAINSSCPRODUCTENTRY = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE licenseId = ? AND productEntryId = ?";
3002 private static final String _FINDER_COLUMN_ACTIVE_ACTIVE_2 = "scLicense.active = ?";
3003 private static final String _FINDER_COLUMN_A_R_ACTIVE_2 = "scLicense.active = ? AND ";
3004 private static final String _FINDER_COLUMN_A_R_RECOMMENDED_2 = "scLicense.recommended = ?";
3005 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "scLicense.licenseId";
3006 private static final String _FILTER_SQL_SELECT_SCLICENSE_WHERE = "SELECT DISTINCT {scLicense.*} FROM SCLicense scLicense WHERE ";
3007 private static final String _FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1 =
3008 "SELECT {SCLicense.*} FROM (SELECT DISTINCT scLicense.licenseId FROM SCLicense scLicense WHERE ";
3009 private static final String _FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2 =
3010 ") TEMP_TABLE INNER JOIN SCLicense ON TEMP_TABLE.licenseId = SCLicense.licenseId";
3011 private static final String _FILTER_SQL_COUNT_SCLICENSE_WHERE = "SELECT COUNT(DISTINCT scLicense.licenseId) AS COUNT_VALUE FROM SCLicense scLicense WHERE ";
3012 private static final String _FILTER_ENTITY_ALIAS = "scLicense";
3013 private static final String _FILTER_ENTITY_TABLE = "SCLicense";
3014 private static final String _ORDER_BY_ENTITY_ALIAS = "scLicense.";
3015 private static final String _ORDER_BY_ENTITY_TABLE = "SCLicense.";
3016 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SCLicense exists with the primary key ";
3017 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SCLicense exists with the key {";
3018 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3019 private static Log _log = LogFactoryUtil.getLog(SCLicensePersistenceImpl.class);
3020 private static SCLicense _nullSCLicense = new SCLicenseImpl() {
3021 @Override
3022 public Object clone() {
3023 return this;
3024 }
3025
3026 @Override
3027 public CacheModel<SCLicense> toCacheModel() {
3028 return _nullSCLicenseCacheModel;
3029 }
3030 };
3031
3032 private static CacheModel<SCLicense> _nullSCLicenseCacheModel = new CacheModel<SCLicense>() {
3033 public SCLicense toEntityModel() {
3034 return _nullSCLicense;
3035 }
3036 };
3037 }