001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
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    /**
064     * The persistence implementation for the s c license service.
065     *
066     * <p>
067     * Caching information and settings can be found in <code>portal.properties</code>
068     * </p>
069     *
070     * @author Brian Wing Shun Chan
071     * @see SCLicensePersistence
072     * @see SCLicenseUtil
073     * @generated
074     */
075    public class SCLicensePersistenceImpl extends BasePersistenceImpl<SCLicense>
076            implements SCLicensePersistence {
077            /*
078             * NOTE FOR DEVELOPERS:
079             *
080             * Never modify or reference this class directly. Always use {@link SCLicenseUtil} to access the s c license persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
081             */
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            /**
136             * Caches the s c license in the entity cache if it is enabled.
137             *
138             * @param scLicense the s c license
139             */
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            /**
148             * Caches the s c licenses in the entity cache if it is enabled.
149             *
150             * @param scLicenses the s c licenses
151             */
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            /**
166             * Clears the cache for all s c licenses.
167             *
168             * <p>
169             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
170             * </p>
171             */
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            /**
186             * Clears the cache for the s c license.
187             *
188             * <p>
189             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
190             * </p>
191             */
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            /**
213             * Creates a new s c license with the primary key. Does not add the s c license to the database.
214             *
215             * @param licenseId the primary key for the new s c license
216             * @return the new s c license
217             */
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            /**
228             * Removes the s c license with the primary key from the database. Also notifies the appropriate model listeners.
229             *
230             * @param licenseId the primary key of the s c license
231             * @return the s c license that was removed
232             * @throws com.liferay.portlet.softwarecatalog.NoSuchLicenseException if a s c license with the primary key could not be found
233             * @throws SystemException if a system exception occurred
234             */
235            public SCLicense remove(long licenseId)
236                    throws NoSuchLicenseException, SystemException {
237                    return remove(Long.valueOf(licenseId));
238            }
239    
240            /**
241             * Removes the s c license with the primary key from the database. Also notifies the appropriate model listeners.
242             *
243             * @param primaryKey the primary key of the s c license
244             * @return the s c license that was removed
245             * @throws com.liferay.portlet.softwarecatalog.NoSuchLicenseException if a s c license with the primary key could not be found
246             * @throws SystemException if a system exception occurred
247             */
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            /**
416             * Returns the s c license with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
417             *
418             * @param primaryKey the primary key of the s c license
419             * @return the s c license
420             * @throws com.liferay.portal.NoSuchModelException if a s c license with the primary key could not be found
421             * @throws SystemException if a system exception occurred
422             */
423            @Override
424            public SCLicense findByPrimaryKey(Serializable primaryKey)
425                    throws NoSuchModelException, SystemException {
426                    return findByPrimaryKey(((Long)primaryKey).longValue());
427            }
428    
429            /**
430             * Returns the s c license with the primary key or throws a {@link com.liferay.portlet.softwarecatalog.NoSuchLicenseException} if it could not be found.
431             *
432             * @param licenseId the primary key of the s c license
433             * @return the s c license
434             * @throws com.liferay.portlet.softwarecatalog.NoSuchLicenseException if a s c license with the primary key could not be found
435             * @throws SystemException if a system exception occurred
436             */
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            /**
454             * Returns the s c license with the primary key or returns <code>null</code> if it could not be found.
455             *
456             * @param primaryKey the primary key of the s c license
457             * @return the s c license, or <code>null</code> if a s c license with the primary key could not be found
458             * @throws SystemException if a system exception occurred
459             */
460            @Override
461            public SCLicense fetchByPrimaryKey(Serializable primaryKey)
462                    throws SystemException {
463                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
464            }
465    
466            /**
467             * Returns the s c license with the primary key or returns <code>null</code> if it could not be found.
468             *
469             * @param licenseId the primary key of the s c license
470             * @return the s c license, or <code>null</code> if a s c license with the primary key could not be found
471             * @throws SystemException if a system exception occurred
472             */
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            /**
515             * Returns all the s c licenses where active = &#63;.
516             *
517             * @param active the active
518             * @return the matching s c licenses
519             * @throws SystemException if a system exception occurred
520             */
521            public List<SCLicense> findByActive(boolean active)
522                    throws SystemException {
523                    return findByActive(active, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
524            }
525    
526            /**
527             * Returns a range of all the s c licenses where active = &#63;.
528             *
529             * <p>
530             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
531             * </p>
532             *
533             * @param active the active
534             * @param start the lower bound of the range of s c licenses
535             * @param end the upper bound of the range of s c licenses (not inclusive)
536             * @return the range of matching s c licenses
537             * @throws SystemException if a system exception occurred
538             */
539            public List<SCLicense> findByActive(boolean active, int start, int end)
540                    throws SystemException {
541                    return findByActive(active, start, end, null);
542            }
543    
544            /**
545             * Returns an ordered range of all the s c licenses where active = &#63;.
546             *
547             * <p>
548             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
549             * </p>
550             *
551             * @param active the active
552             * @param start the lower bound of the range of s c licenses
553             * @param end the upper bound of the range of s c licenses (not inclusive)
554             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
555             * @return the ordered range of matching s c licenses
556             * @throws SystemException if a system exception occurred
557             */
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) && !list.isEmpty()) {
577                            for (SCLicense scLicense : list) {
578                                    if ((active != scLicense.getActive())) {
579                                            list = null;
580    
581                                            break;
582                                    }
583                            }
584                    }
585    
586                    if (list == null) {
587                            StringBundler query = null;
588    
589                            if (orderByComparator != null) {
590                                    query = new StringBundler(3 +
591                                                    (orderByComparator.getOrderByFields().length * 3));
592                            }
593                            else {
594                                    query = new StringBundler(3);
595                            }
596    
597                            query.append(_SQL_SELECT_SCLICENSE_WHERE);
598    
599                            query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
600    
601                            if (orderByComparator != null) {
602                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
603                                            orderByComparator);
604                            }
605    
606                            else {
607                                    query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
608                            }
609    
610                            String sql = query.toString();
611    
612                            Session session = null;
613    
614                            try {
615                                    session = openSession();
616    
617                                    Query q = session.createQuery(sql);
618    
619                                    QueryPos qPos = QueryPos.getInstance(q);
620    
621                                    qPos.add(active);
622    
623                                    list = (List<SCLicense>)QueryUtil.list(q, getDialect(), start,
624                                                    end);
625                            }
626                            catch (Exception e) {
627                                    throw processException(e);
628                            }
629                            finally {
630                                    if (list == null) {
631                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
632                                    }
633                                    else {
634                                            cacheResult(list);
635    
636                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
637                                    }
638    
639                                    closeSession(session);
640                            }
641                    }
642    
643                    return list;
644            }
645    
646            /**
647             * Returns the first s c license in the ordered set where active = &#63;.
648             *
649             * @param active the active
650             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
651             * @return the first matching s c license
652             * @throws com.liferay.portlet.softwarecatalog.NoSuchLicenseException if a matching s c license could not be found
653             * @throws SystemException if a system exception occurred
654             */
655            public SCLicense findByActive_First(boolean active,
656                    OrderByComparator orderByComparator)
657                    throws NoSuchLicenseException, SystemException {
658                    SCLicense scLicense = fetchByActive_First(active, orderByComparator);
659    
660                    if (scLicense != null) {
661                            return scLicense;
662                    }
663    
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    
676            /**
677             * Returns the first s c license in the ordered set where active = &#63;.
678             *
679             * @param active the active
680             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
681             * @return the first matching s c license, or <code>null</code> if a matching s c license could not be found
682             * @throws SystemException if a system exception occurred
683             */
684            public SCLicense fetchByActive_First(boolean active,
685                    OrderByComparator orderByComparator) throws SystemException {
686                    List<SCLicense> list = findByActive(active, 0, 1, orderByComparator);
687    
688                    if (!list.isEmpty()) {
689                            return list.get(0);
690                    }
691    
692                    return null;
693            }
694    
695            /**
696             * Returns the last s c license in the ordered set where active = &#63;.
697             *
698             * @param active the active
699             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
700             * @return the last matching s c license
701             * @throws com.liferay.portlet.softwarecatalog.NoSuchLicenseException if a matching s c license could not be found
702             * @throws SystemException if a system exception occurred
703             */
704            public SCLicense findByActive_Last(boolean active,
705                    OrderByComparator orderByComparator)
706                    throws NoSuchLicenseException, SystemException {
707                    SCLicense scLicense = fetchByActive_Last(active, orderByComparator);
708    
709                    if (scLicense != null) {
710                            return scLicense;
711                    }
712    
713                    StringBundler msg = new StringBundler(4);
714    
715                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
716    
717                    msg.append("active=");
718                    msg.append(active);
719    
720                    msg.append(StringPool.CLOSE_CURLY_BRACE);
721    
722                    throw new NoSuchLicenseException(msg.toString());
723            }
724    
725            /**
726             * Returns the last s c license in the ordered set where active = &#63;.
727             *
728             * @param active the active
729             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
730             * @return the last matching s c license, or <code>null</code> if a matching s c license could not be found
731             * @throws SystemException if a system exception occurred
732             */
733            public SCLicense fetchByActive_Last(boolean active,
734                    OrderByComparator orderByComparator) throws SystemException {
735                    int count = countByActive(active);
736    
737                    List<SCLicense> list = findByActive(active, count - 1, count,
738                                    orderByComparator);
739    
740                    if (!list.isEmpty()) {
741                            return list.get(0);
742                    }
743    
744                    return null;
745            }
746    
747            /**
748             * Returns the s c licenses before and after the current s c license in the ordered set where active = &#63;.
749             *
750             * @param licenseId the primary key of the current s c license
751             * @param active the active
752             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
753             * @return the previous, current, and next s c license
754             * @throws com.liferay.portlet.softwarecatalog.NoSuchLicenseException if a s c license with the primary key could not be found
755             * @throws SystemException if a system exception occurred
756             */
757            public SCLicense[] findByActive_PrevAndNext(long licenseId, boolean active,
758                    OrderByComparator orderByComparator)
759                    throws NoSuchLicenseException, SystemException {
760                    SCLicense scLicense = findByPrimaryKey(licenseId);
761    
762                    Session session = null;
763    
764                    try {
765                            session = openSession();
766    
767                            SCLicense[] array = new SCLicenseImpl[3];
768    
769                            array[0] = getByActive_PrevAndNext(session, scLicense, active,
770                                            orderByComparator, true);
771    
772                            array[1] = scLicense;
773    
774                            array[2] = getByActive_PrevAndNext(session, scLicense, active,
775                                            orderByComparator, false);
776    
777                            return array;
778                    }
779                    catch (Exception e) {
780                            throw processException(e);
781                    }
782                    finally {
783                            closeSession(session);
784                    }
785            }
786    
787            protected SCLicense getByActive_PrevAndNext(Session session,
788                    SCLicense scLicense, boolean active,
789                    OrderByComparator orderByComparator, boolean previous) {
790                    StringBundler query = null;
791    
792                    if (orderByComparator != null) {
793                            query = new StringBundler(6 +
794                                            (orderByComparator.getOrderByFields().length * 6));
795                    }
796                    else {
797                            query = new StringBundler(3);
798                    }
799    
800                    query.append(_SQL_SELECT_SCLICENSE_WHERE);
801    
802                    query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
803    
804                    if (orderByComparator != null) {
805                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
806    
807                            if (orderByConditionFields.length > 0) {
808                                    query.append(WHERE_AND);
809                            }
810    
811                            for (int i = 0; i < orderByConditionFields.length; i++) {
812                                    query.append(_ORDER_BY_ENTITY_ALIAS);
813                                    query.append(orderByConditionFields[i]);
814    
815                                    if ((i + 1) < orderByConditionFields.length) {
816                                            if (orderByComparator.isAscending() ^ previous) {
817                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
818                                            }
819                                            else {
820                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
821                                            }
822                                    }
823                                    else {
824                                            if (orderByComparator.isAscending() ^ previous) {
825                                                    query.append(WHERE_GREATER_THAN);
826                                            }
827                                            else {
828                                                    query.append(WHERE_LESSER_THAN);
829                                            }
830                                    }
831                            }
832    
833                            query.append(ORDER_BY_CLAUSE);
834    
835                            String[] orderByFields = orderByComparator.getOrderByFields();
836    
837                            for (int i = 0; i < orderByFields.length; i++) {
838                                    query.append(_ORDER_BY_ENTITY_ALIAS);
839                                    query.append(orderByFields[i]);
840    
841                                    if ((i + 1) < orderByFields.length) {
842                                            if (orderByComparator.isAscending() ^ previous) {
843                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
844                                            }
845                                            else {
846                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
847                                            }
848                                    }
849                                    else {
850                                            if (orderByComparator.isAscending() ^ previous) {
851                                                    query.append(ORDER_BY_ASC);
852                                            }
853                                            else {
854                                                    query.append(ORDER_BY_DESC);
855                                            }
856                                    }
857                            }
858                    }
859    
860                    else {
861                            query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
862                    }
863    
864                    String sql = query.toString();
865    
866                    Query q = session.createQuery(sql);
867    
868                    q.setFirstResult(0);
869                    q.setMaxResults(2);
870    
871                    QueryPos qPos = QueryPos.getInstance(q);
872    
873                    qPos.add(active);
874    
875                    if (orderByComparator != null) {
876                            Object[] values = orderByComparator.getOrderByConditionValues(scLicense);
877    
878                            for (Object value : values) {
879                                    qPos.add(value);
880                            }
881                    }
882    
883                    List<SCLicense> list = q.list();
884    
885                    if (list.size() == 2) {
886                            return list.get(1);
887                    }
888                    else {
889                            return null;
890                    }
891            }
892    
893            /**
894             * Returns all the s c licenses that the user has permission to view where active = &#63;.
895             *
896             * @param active the active
897             * @return the matching s c licenses that the user has permission to view
898             * @throws SystemException if a system exception occurred
899             */
900            public List<SCLicense> filterFindByActive(boolean active)
901                    throws SystemException {
902                    return filterFindByActive(active, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
903                            null);
904            }
905    
906            /**
907             * Returns a range of all the s c licenses that the user has permission to view where active = &#63;.
908             *
909             * <p>
910             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
911             * </p>
912             *
913             * @param active the active
914             * @param start the lower bound of the range of s c licenses
915             * @param end the upper bound of the range of s c licenses (not inclusive)
916             * @return the range of matching s c licenses that the user has permission to view
917             * @throws SystemException if a system exception occurred
918             */
919            public List<SCLicense> filterFindByActive(boolean active, int start, int end)
920                    throws SystemException {
921                    return filterFindByActive(active, start, end, null);
922            }
923    
924            /**
925             * Returns an ordered range of all the s c licenses that the user has permissions to view where active = &#63;.
926             *
927             * <p>
928             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
929             * </p>
930             *
931             * @param active the active
932             * @param start the lower bound of the range of s c licenses
933             * @param end the upper bound of the range of s c licenses (not inclusive)
934             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
935             * @return the ordered range of matching s c licenses that the user has permission to view
936             * @throws SystemException if a system exception occurred
937             */
938            public List<SCLicense> filterFindByActive(boolean active, int start,
939                    int end, OrderByComparator orderByComparator) throws SystemException {
940                    if (!InlineSQLHelperUtil.isEnabled()) {
941                            return findByActive(active, start, end, orderByComparator);
942                    }
943    
944                    StringBundler query = null;
945    
946                    if (orderByComparator != null) {
947                            query = new StringBundler(3 +
948                                            (orderByComparator.getOrderByFields().length * 3));
949                    }
950                    else {
951                            query = new StringBundler(3);
952                    }
953    
954                    if (getDB().isSupportsInlineDistinct()) {
955                            query.append(_FILTER_SQL_SELECT_SCLICENSE_WHERE);
956                    }
957                    else {
958                            query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1);
959                    }
960    
961                    query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
962    
963                    if (!getDB().isSupportsInlineDistinct()) {
964                            query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2);
965                    }
966    
967                    if (orderByComparator != null) {
968                            if (getDB().isSupportsInlineDistinct()) {
969                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
970                                            orderByComparator);
971                            }
972                            else {
973                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
974                                            orderByComparator);
975                            }
976                    }
977    
978                    else {
979                            if (getDB().isSupportsInlineDistinct()) {
980                                    query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
981                            }
982                            else {
983                                    query.append(SCLicenseModelImpl.ORDER_BY_SQL);
984                            }
985                    }
986    
987                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
988                                    SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
989    
990                    Session session = null;
991    
992                    try {
993                            session = openSession();
994    
995                            SQLQuery q = session.createSQLQuery(sql);
996    
997                            if (getDB().isSupportsInlineDistinct()) {
998                                    q.addEntity(_FILTER_ENTITY_ALIAS, SCLicenseImpl.class);
999                            }
1000                            else {
1001                                    q.addEntity(_FILTER_ENTITY_TABLE, SCLicenseImpl.class);
1002                            }
1003    
1004                            QueryPos qPos = QueryPos.getInstance(q);
1005    
1006                            qPos.add(active);
1007    
1008                            return (List<SCLicense>)QueryUtil.list(q, getDialect(), start, end);
1009                    }
1010                    catch (Exception e) {
1011                            throw processException(e);
1012                    }
1013                    finally {
1014                            closeSession(session);
1015                    }
1016            }
1017    
1018            /**
1019             * Returns the s c licenses before and after the current s c license in the ordered set of s c licenses that the user has permission to view where active = &#63;.
1020             *
1021             * @param licenseId the primary key of the current s c license
1022             * @param active the active
1023             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1024             * @return the previous, current, and next s c license
1025             * @throws com.liferay.portlet.softwarecatalog.NoSuchLicenseException if a s c license with the primary key could not be found
1026             * @throws SystemException if a system exception occurred
1027             */
1028            public SCLicense[] filterFindByActive_PrevAndNext(long licenseId,
1029                    boolean active, OrderByComparator orderByComparator)
1030                    throws NoSuchLicenseException, SystemException {
1031                    if (!InlineSQLHelperUtil.isEnabled()) {
1032                            return findByActive_PrevAndNext(licenseId, active, orderByComparator);
1033                    }
1034    
1035                    SCLicense scLicense = findByPrimaryKey(licenseId);
1036    
1037                    Session session = null;
1038    
1039                    try {
1040                            session = openSession();
1041    
1042                            SCLicense[] array = new SCLicenseImpl[3];
1043    
1044                            array[0] = filterGetByActive_PrevAndNext(session, scLicense,
1045                                            active, orderByComparator, true);
1046    
1047                            array[1] = scLicense;
1048    
1049                            array[2] = filterGetByActive_PrevAndNext(session, scLicense,
1050                                            active, orderByComparator, false);
1051    
1052                            return array;
1053                    }
1054                    catch (Exception e) {
1055                            throw processException(e);
1056                    }
1057                    finally {
1058                            closeSession(session);
1059                    }
1060            }
1061    
1062            protected SCLicense filterGetByActive_PrevAndNext(Session session,
1063                    SCLicense scLicense, boolean active,
1064                    OrderByComparator orderByComparator, boolean previous) {
1065                    StringBundler query = null;
1066    
1067                    if (orderByComparator != null) {
1068                            query = new StringBundler(6 +
1069                                            (orderByComparator.getOrderByFields().length * 6));
1070                    }
1071                    else {
1072                            query = new StringBundler(3);
1073                    }
1074    
1075                    if (getDB().isSupportsInlineDistinct()) {
1076                            query.append(_FILTER_SQL_SELECT_SCLICENSE_WHERE);
1077                    }
1078                    else {
1079                            query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1);
1080                    }
1081    
1082                    query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
1083    
1084                    if (!getDB().isSupportsInlineDistinct()) {
1085                            query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2);
1086                    }
1087    
1088                    if (orderByComparator != null) {
1089                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1090    
1091                            if (orderByConditionFields.length > 0) {
1092                                    query.append(WHERE_AND);
1093                            }
1094    
1095                            for (int i = 0; i < orderByConditionFields.length; i++) {
1096                                    if (getDB().isSupportsInlineDistinct()) {
1097                                            query.append(_ORDER_BY_ENTITY_ALIAS);
1098                                    }
1099                                    else {
1100                                            query.append(_ORDER_BY_ENTITY_TABLE);
1101                                    }
1102    
1103                                    query.append(orderByConditionFields[i]);
1104    
1105                                    if ((i + 1) < orderByConditionFields.length) {
1106                                            if (orderByComparator.isAscending() ^ previous) {
1107                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1108                                            }
1109                                            else {
1110                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1111                                            }
1112                                    }
1113                                    else {
1114                                            if (orderByComparator.isAscending() ^ previous) {
1115                                                    query.append(WHERE_GREATER_THAN);
1116                                            }
1117                                            else {
1118                                                    query.append(WHERE_LESSER_THAN);
1119                                            }
1120                                    }
1121                            }
1122    
1123                            query.append(ORDER_BY_CLAUSE);
1124    
1125                            String[] orderByFields = orderByComparator.getOrderByFields();
1126    
1127                            for (int i = 0; i < orderByFields.length; i++) {
1128                                    if (getDB().isSupportsInlineDistinct()) {
1129                                            query.append(_ORDER_BY_ENTITY_ALIAS);
1130                                    }
1131                                    else {
1132                                            query.append(_ORDER_BY_ENTITY_TABLE);
1133                                    }
1134    
1135                                    query.append(orderByFields[i]);
1136    
1137                                    if ((i + 1) < orderByFields.length) {
1138                                            if (orderByComparator.isAscending() ^ previous) {
1139                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1140                                            }
1141                                            else {
1142                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1143                                            }
1144                                    }
1145                                    else {
1146                                            if (orderByComparator.isAscending() ^ previous) {
1147                                                    query.append(ORDER_BY_ASC);
1148                                            }
1149                                            else {
1150                                                    query.append(ORDER_BY_DESC);
1151                                            }
1152                                    }
1153                            }
1154                    }
1155    
1156                    else {
1157                            if (getDB().isSupportsInlineDistinct()) {
1158                                    query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1159                            }
1160                            else {
1161                                    query.append(SCLicenseModelImpl.ORDER_BY_SQL);
1162                            }
1163                    }
1164    
1165                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1166                                    SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1167    
1168                    SQLQuery q = session.createSQLQuery(sql);
1169    
1170                    q.setFirstResult(0);
1171                    q.setMaxResults(2);
1172    
1173                    if (getDB().isSupportsInlineDistinct()) {
1174                            q.addEntity(_FILTER_ENTITY_ALIAS, SCLicenseImpl.class);
1175                    }
1176                    else {
1177                            q.addEntity(_FILTER_ENTITY_TABLE, SCLicenseImpl.class);
1178                    }
1179    
1180                    QueryPos qPos = QueryPos.getInstance(q);
1181    
1182                    qPos.add(active);
1183    
1184                    if (orderByComparator != null) {
1185                            Object[] values = orderByComparator.getOrderByConditionValues(scLicense);
1186    
1187                            for (Object value : values) {
1188                                    qPos.add(value);
1189                            }
1190                    }
1191    
1192                    List<SCLicense> list = q.list();
1193    
1194                    if (list.size() == 2) {
1195                            return list.get(1);
1196                    }
1197                    else {
1198                            return null;
1199                    }
1200            }
1201    
1202            /**
1203             * Returns all the s c licenses where active = &#63; and recommended = &#63;.
1204             *
1205             * @param active the active
1206             * @param recommended the recommended
1207             * @return the matching s c licenses
1208             * @throws SystemException if a system exception occurred
1209             */
1210            public List<SCLicense> findByA_R(boolean active, boolean recommended)
1211                    throws SystemException {
1212                    return findByA_R(active, recommended, QueryUtil.ALL_POS,
1213                            QueryUtil.ALL_POS, null);
1214            }
1215    
1216            /**
1217             * Returns a range of all the s c licenses where active = &#63; and recommended = &#63;.
1218             *
1219             * <p>
1220             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1221             * </p>
1222             *
1223             * @param active the active
1224             * @param recommended the recommended
1225             * @param start the lower bound of the range of s c licenses
1226             * @param end the upper bound of the range of s c licenses (not inclusive)
1227             * @return the range of matching s c licenses
1228             * @throws SystemException if a system exception occurred
1229             */
1230            public List<SCLicense> findByA_R(boolean active, boolean recommended,
1231                    int start, int end) throws SystemException {
1232                    return findByA_R(active, recommended, start, end, null);
1233            }
1234    
1235            /**
1236             * Returns an ordered range of all the s c licenses where active = &#63; and recommended = &#63;.
1237             *
1238             * <p>
1239             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1240             * </p>
1241             *
1242             * @param active the active
1243             * @param recommended the recommended
1244             * @param start the lower bound of the range of s c licenses
1245             * @param end the upper bound of the range of s c licenses (not inclusive)
1246             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1247             * @return the ordered range of matching s c licenses
1248             * @throws SystemException if a system exception occurred
1249             */
1250            public List<SCLicense> findByA_R(boolean active, boolean recommended,
1251                    int start, int end, OrderByComparator orderByComparator)
1252                    throws SystemException {
1253                    FinderPath finderPath = null;
1254                    Object[] finderArgs = null;
1255    
1256                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1257                                    (orderByComparator == null)) {
1258                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_A_R;
1259                            finderArgs = new Object[] { active, recommended };
1260                    }
1261                    else {
1262                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_A_R;
1263                            finderArgs = new Object[] {
1264                                            active, recommended,
1265                                            
1266                                            start, end, orderByComparator
1267                                    };
1268                    }
1269    
1270                    List<SCLicense> list = (List<SCLicense>)FinderCacheUtil.getResult(finderPath,
1271                                    finderArgs, this);
1272    
1273                    if ((list != null) && !list.isEmpty()) {
1274                            for (SCLicense scLicense : list) {
1275                                    if ((active != scLicense.getActive()) ||
1276                                                    (recommended != scLicense.getRecommended())) {
1277                                            list = null;
1278    
1279                                            break;
1280                                    }
1281                            }
1282                    }
1283    
1284                    if (list == null) {
1285                            StringBundler query = null;
1286    
1287                            if (orderByComparator != null) {
1288                                    query = new StringBundler(4 +
1289                                                    (orderByComparator.getOrderByFields().length * 3));
1290                            }
1291                            else {
1292                                    query = new StringBundler(4);
1293                            }
1294    
1295                            query.append(_SQL_SELECT_SCLICENSE_WHERE);
1296    
1297                            query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1298    
1299                            query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1300    
1301                            if (orderByComparator != null) {
1302                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1303                                            orderByComparator);
1304                            }
1305    
1306                            else {
1307                                    query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1308                            }
1309    
1310                            String sql = query.toString();
1311    
1312                            Session session = null;
1313    
1314                            try {
1315                                    session = openSession();
1316    
1317                                    Query q = session.createQuery(sql);
1318    
1319                                    QueryPos qPos = QueryPos.getInstance(q);
1320    
1321                                    qPos.add(active);
1322    
1323                                    qPos.add(recommended);
1324    
1325                                    list = (List<SCLicense>)QueryUtil.list(q, getDialect(), start,
1326                                                    end);
1327                            }
1328                            catch (Exception e) {
1329                                    throw processException(e);
1330                            }
1331                            finally {
1332                                    if (list == null) {
1333                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1334                                    }
1335                                    else {
1336                                            cacheResult(list);
1337    
1338                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1339                                    }
1340    
1341                                    closeSession(session);
1342                            }
1343                    }
1344    
1345                    return list;
1346            }
1347    
1348            /**
1349             * Returns the first s c license in the ordered set where active = &#63; and recommended = &#63;.
1350             *
1351             * @param active the active
1352             * @param recommended the recommended
1353             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1354             * @return the first matching s c license
1355             * @throws com.liferay.portlet.softwarecatalog.NoSuchLicenseException if a matching s c license could not be found
1356             * @throws SystemException if a system exception occurred
1357             */
1358            public SCLicense findByA_R_First(boolean active, boolean recommended,
1359                    OrderByComparator orderByComparator)
1360                    throws NoSuchLicenseException, SystemException {
1361                    SCLicense scLicense = fetchByA_R_First(active, recommended,
1362                                    orderByComparator);
1363    
1364                    if (scLicense != null) {
1365                            return scLicense;
1366                    }
1367    
1368                    StringBundler msg = new StringBundler(6);
1369    
1370                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1371    
1372                    msg.append("active=");
1373                    msg.append(active);
1374    
1375                    msg.append(", recommended=");
1376                    msg.append(recommended);
1377    
1378                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1379    
1380                    throw new NoSuchLicenseException(msg.toString());
1381            }
1382    
1383            /**
1384             * Returns the first s c license in the ordered set where active = &#63; and recommended = &#63;.
1385             *
1386             * @param active the active
1387             * @param recommended the recommended
1388             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1389             * @return the first matching s c license, or <code>null</code> if a matching s c license could not be found
1390             * @throws SystemException if a system exception occurred
1391             */
1392            public SCLicense fetchByA_R_First(boolean active, boolean recommended,
1393                    OrderByComparator orderByComparator) throws SystemException {
1394                    List<SCLicense> list = findByA_R(active, recommended, 0, 1,
1395                                    orderByComparator);
1396    
1397                    if (!list.isEmpty()) {
1398                            return list.get(0);
1399                    }
1400    
1401                    return null;
1402            }
1403    
1404            /**
1405             * Returns the last s c license in the ordered set where active = &#63; and recommended = &#63;.
1406             *
1407             * @param active the active
1408             * @param recommended the recommended
1409             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1410             * @return the last matching s c license
1411             * @throws com.liferay.portlet.softwarecatalog.NoSuchLicenseException if a matching s c license could not be found
1412             * @throws SystemException if a system exception occurred
1413             */
1414            public SCLicense findByA_R_Last(boolean active, boolean recommended,
1415                    OrderByComparator orderByComparator)
1416                    throws NoSuchLicenseException, SystemException {
1417                    SCLicense scLicense = fetchByA_R_Last(active, recommended,
1418                                    orderByComparator);
1419    
1420                    if (scLicense != null) {
1421                            return scLicense;
1422                    }
1423    
1424                    StringBundler msg = new StringBundler(6);
1425    
1426                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1427    
1428                    msg.append("active=");
1429                    msg.append(active);
1430    
1431                    msg.append(", recommended=");
1432                    msg.append(recommended);
1433    
1434                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1435    
1436                    throw new NoSuchLicenseException(msg.toString());
1437            }
1438    
1439            /**
1440             * Returns the last s c license in the ordered set where active = &#63; and recommended = &#63;.
1441             *
1442             * @param active the active
1443             * @param recommended the recommended
1444             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1445             * @return the last matching s c license, or <code>null</code> if a matching s c license could not be found
1446             * @throws SystemException if a system exception occurred
1447             */
1448            public SCLicense fetchByA_R_Last(boolean active, boolean recommended,
1449                    OrderByComparator orderByComparator) throws SystemException {
1450                    int count = countByA_R(active, recommended);
1451    
1452                    List<SCLicense> list = findByA_R(active, recommended, count - 1, count,
1453                                    orderByComparator);
1454    
1455                    if (!list.isEmpty()) {
1456                            return list.get(0);
1457                    }
1458    
1459                    return null;
1460            }
1461    
1462            /**
1463             * Returns the s c licenses before and after the current s c license in the ordered set where active = &#63; and recommended = &#63;.
1464             *
1465             * @param licenseId the primary key of the current s c license
1466             * @param active the active
1467             * @param recommended the recommended
1468             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1469             * @return the previous, current, and next s c license
1470             * @throws com.liferay.portlet.softwarecatalog.NoSuchLicenseException if a s c license with the primary key could not be found
1471             * @throws SystemException if a system exception occurred
1472             */
1473            public SCLicense[] findByA_R_PrevAndNext(long licenseId, boolean active,
1474                    boolean recommended, OrderByComparator orderByComparator)
1475                    throws NoSuchLicenseException, SystemException {
1476                    SCLicense scLicense = findByPrimaryKey(licenseId);
1477    
1478                    Session session = null;
1479    
1480                    try {
1481                            session = openSession();
1482    
1483                            SCLicense[] array = new SCLicenseImpl[3];
1484    
1485                            array[0] = getByA_R_PrevAndNext(session, scLicense, active,
1486                                            recommended, orderByComparator, true);
1487    
1488                            array[1] = scLicense;
1489    
1490                            array[2] = getByA_R_PrevAndNext(session, scLicense, active,
1491                                            recommended, orderByComparator, false);
1492    
1493                            return array;
1494                    }
1495                    catch (Exception e) {
1496                            throw processException(e);
1497                    }
1498                    finally {
1499                            closeSession(session);
1500                    }
1501            }
1502    
1503            protected SCLicense getByA_R_PrevAndNext(Session session,
1504                    SCLicense scLicense, boolean active, boolean recommended,
1505                    OrderByComparator orderByComparator, boolean previous) {
1506                    StringBundler query = null;
1507    
1508                    if (orderByComparator != null) {
1509                            query = new StringBundler(6 +
1510                                            (orderByComparator.getOrderByFields().length * 6));
1511                    }
1512                    else {
1513                            query = new StringBundler(3);
1514                    }
1515    
1516                    query.append(_SQL_SELECT_SCLICENSE_WHERE);
1517    
1518                    query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1519    
1520                    query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1521    
1522                    if (orderByComparator != null) {
1523                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1524    
1525                            if (orderByConditionFields.length > 0) {
1526                                    query.append(WHERE_AND);
1527                            }
1528    
1529                            for (int i = 0; i < orderByConditionFields.length; i++) {
1530                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1531                                    query.append(orderByConditionFields[i]);
1532    
1533                                    if ((i + 1) < orderByConditionFields.length) {
1534                                            if (orderByComparator.isAscending() ^ previous) {
1535                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1536                                            }
1537                                            else {
1538                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1539                                            }
1540                                    }
1541                                    else {
1542                                            if (orderByComparator.isAscending() ^ previous) {
1543                                                    query.append(WHERE_GREATER_THAN);
1544                                            }
1545                                            else {
1546                                                    query.append(WHERE_LESSER_THAN);
1547                                            }
1548                                    }
1549                            }
1550    
1551                            query.append(ORDER_BY_CLAUSE);
1552    
1553                            String[] orderByFields = orderByComparator.getOrderByFields();
1554    
1555                            for (int i = 0; i < orderByFields.length; i++) {
1556                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1557                                    query.append(orderByFields[i]);
1558    
1559                                    if ((i + 1) < orderByFields.length) {
1560                                            if (orderByComparator.isAscending() ^ previous) {
1561                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1562                                            }
1563                                            else {
1564                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1565                                            }
1566                                    }
1567                                    else {
1568                                            if (orderByComparator.isAscending() ^ previous) {
1569                                                    query.append(ORDER_BY_ASC);
1570                                            }
1571                                            else {
1572                                                    query.append(ORDER_BY_DESC);
1573                                            }
1574                                    }
1575                            }
1576                    }
1577    
1578                    else {
1579                            query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1580                    }
1581    
1582                    String sql = query.toString();
1583    
1584                    Query q = session.createQuery(sql);
1585    
1586                    q.setFirstResult(0);
1587                    q.setMaxResults(2);
1588    
1589                    QueryPos qPos = QueryPos.getInstance(q);
1590    
1591                    qPos.add(active);
1592    
1593                    qPos.add(recommended);
1594    
1595                    if (orderByComparator != null) {
1596                            Object[] values = orderByComparator.getOrderByConditionValues(scLicense);
1597    
1598                            for (Object value : values) {
1599                                    qPos.add(value);
1600                            }
1601                    }
1602    
1603                    List<SCLicense> list = q.list();
1604    
1605                    if (list.size() == 2) {
1606                            return list.get(1);
1607                    }
1608                    else {
1609                            return null;
1610                    }
1611            }
1612    
1613            /**
1614             * Returns all the s c licenses that the user has permission to view where active = &#63; and recommended = &#63;.
1615             *
1616             * @param active the active
1617             * @param recommended the recommended
1618             * @return the matching s c licenses that the user has permission to view
1619             * @throws SystemException if a system exception occurred
1620             */
1621            public List<SCLicense> filterFindByA_R(boolean active, boolean recommended)
1622                    throws SystemException {
1623                    return filterFindByA_R(active, recommended, QueryUtil.ALL_POS,
1624                            QueryUtil.ALL_POS, null);
1625            }
1626    
1627            /**
1628             * Returns a range of all the s c licenses that the user has permission to view where active = &#63; and recommended = &#63;.
1629             *
1630             * <p>
1631             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1632             * </p>
1633             *
1634             * @param active the active
1635             * @param recommended the recommended
1636             * @param start the lower bound of the range of s c licenses
1637             * @param end the upper bound of the range of s c licenses (not inclusive)
1638             * @return the range of matching s c licenses that the user has permission to view
1639             * @throws SystemException if a system exception occurred
1640             */
1641            public List<SCLicense> filterFindByA_R(boolean active, boolean recommended,
1642                    int start, int end) throws SystemException {
1643                    return filterFindByA_R(active, recommended, start, end, null);
1644            }
1645    
1646            /**
1647             * Returns an ordered range of all the s c licenses that the user has permissions to view where active = &#63; and recommended = &#63;.
1648             *
1649             * <p>
1650             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1651             * </p>
1652             *
1653             * @param active the active
1654             * @param recommended the recommended
1655             * @param start the lower bound of the range of s c licenses
1656             * @param end the upper bound of the range of s c licenses (not inclusive)
1657             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1658             * @return the ordered range of matching s c licenses that the user has permission to view
1659             * @throws SystemException if a system exception occurred
1660             */
1661            public List<SCLicense> filterFindByA_R(boolean active, boolean recommended,
1662                    int start, int end, OrderByComparator orderByComparator)
1663                    throws SystemException {
1664                    if (!InlineSQLHelperUtil.isEnabled()) {
1665                            return findByA_R(active, recommended, start, end, orderByComparator);
1666                    }
1667    
1668                    StringBundler query = null;
1669    
1670                    if (orderByComparator != null) {
1671                            query = new StringBundler(4 +
1672                                            (orderByComparator.getOrderByFields().length * 3));
1673                    }
1674                    else {
1675                            query = new StringBundler(4);
1676                    }
1677    
1678                    if (getDB().isSupportsInlineDistinct()) {
1679                            query.append(_FILTER_SQL_SELECT_SCLICENSE_WHERE);
1680                    }
1681                    else {
1682                            query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1);
1683                    }
1684    
1685                    query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1686    
1687                    query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1688    
1689                    if (!getDB().isSupportsInlineDistinct()) {
1690                            query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2);
1691                    }
1692    
1693                    if (orderByComparator != null) {
1694                            if (getDB().isSupportsInlineDistinct()) {
1695                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1696                                            orderByComparator);
1697                            }
1698                            else {
1699                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1700                                            orderByComparator);
1701                            }
1702                    }
1703    
1704                    else {
1705                            if (getDB().isSupportsInlineDistinct()) {
1706                                    query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1707                            }
1708                            else {
1709                                    query.append(SCLicenseModelImpl.ORDER_BY_SQL);
1710                            }
1711                    }
1712    
1713                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1714                                    SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1715    
1716                    Session session = null;
1717    
1718                    try {
1719                            session = openSession();
1720    
1721                            SQLQuery q = session.createSQLQuery(sql);
1722    
1723                            if (getDB().isSupportsInlineDistinct()) {
1724                                    q.addEntity(_FILTER_ENTITY_ALIAS, SCLicenseImpl.class);
1725                            }
1726                            else {
1727                                    q.addEntity(_FILTER_ENTITY_TABLE, SCLicenseImpl.class);
1728                            }
1729    
1730                            QueryPos qPos = QueryPos.getInstance(q);
1731    
1732                            qPos.add(active);
1733    
1734                            qPos.add(recommended);
1735    
1736                            return (List<SCLicense>)QueryUtil.list(q, getDialect(), start, end);
1737                    }
1738                    catch (Exception e) {
1739                            throw processException(e);
1740                    }
1741                    finally {
1742                            closeSession(session);
1743                    }
1744            }
1745    
1746            /**
1747             * Returns the s c licenses before and after the current s c license in the ordered set of s c licenses that the user has permission to view where active = &#63; and recommended = &#63;.
1748             *
1749             * @param licenseId the primary key of the current s c license
1750             * @param active the active
1751             * @param recommended the recommended
1752             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1753             * @return the previous, current, and next s c license
1754             * @throws com.liferay.portlet.softwarecatalog.NoSuchLicenseException if a s c license with the primary key could not be found
1755             * @throws SystemException if a system exception occurred
1756             */
1757            public SCLicense[] filterFindByA_R_PrevAndNext(long licenseId,
1758                    boolean active, boolean recommended, OrderByComparator orderByComparator)
1759                    throws NoSuchLicenseException, SystemException {
1760                    if (!InlineSQLHelperUtil.isEnabled()) {
1761                            return findByA_R_PrevAndNext(licenseId, active, recommended,
1762                                    orderByComparator);
1763                    }
1764    
1765                    SCLicense scLicense = findByPrimaryKey(licenseId);
1766    
1767                    Session session = null;
1768    
1769                    try {
1770                            session = openSession();
1771    
1772                            SCLicense[] array = new SCLicenseImpl[3];
1773    
1774                            array[0] = filterGetByA_R_PrevAndNext(session, scLicense, active,
1775                                            recommended, orderByComparator, true);
1776    
1777                            array[1] = scLicense;
1778    
1779                            array[2] = filterGetByA_R_PrevAndNext(session, scLicense, active,
1780                                            recommended, orderByComparator, false);
1781    
1782                            return array;
1783                    }
1784                    catch (Exception e) {
1785                            throw processException(e);
1786                    }
1787                    finally {
1788                            closeSession(session);
1789                    }
1790            }
1791    
1792            protected SCLicense filterGetByA_R_PrevAndNext(Session session,
1793                    SCLicense scLicense, boolean active, boolean recommended,
1794                    OrderByComparator orderByComparator, boolean previous) {
1795                    StringBundler query = null;
1796    
1797                    if (orderByComparator != null) {
1798                            query = new StringBundler(6 +
1799                                            (orderByComparator.getOrderByFields().length * 6));
1800                    }
1801                    else {
1802                            query = new StringBundler(3);
1803                    }
1804    
1805                    if (getDB().isSupportsInlineDistinct()) {
1806                            query.append(_FILTER_SQL_SELECT_SCLICENSE_WHERE);
1807                    }
1808                    else {
1809                            query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1);
1810                    }
1811    
1812                    query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1813    
1814                    query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1815    
1816                    if (!getDB().isSupportsInlineDistinct()) {
1817                            query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2);
1818                    }
1819    
1820                    if (orderByComparator != null) {
1821                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1822    
1823                            if (orderByConditionFields.length > 0) {
1824                                    query.append(WHERE_AND);
1825                            }
1826    
1827                            for (int i = 0; i < orderByConditionFields.length; i++) {
1828                                    if (getDB().isSupportsInlineDistinct()) {
1829                                            query.append(_ORDER_BY_ENTITY_ALIAS);
1830                                    }
1831                                    else {
1832                                            query.append(_ORDER_BY_ENTITY_TABLE);
1833                                    }
1834    
1835                                    query.append(orderByConditionFields[i]);
1836    
1837                                    if ((i + 1) < orderByConditionFields.length) {
1838                                            if (orderByComparator.isAscending() ^ previous) {
1839                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1840                                            }
1841                                            else {
1842                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1843                                            }
1844                                    }
1845                                    else {
1846                                            if (orderByComparator.isAscending() ^ previous) {
1847                                                    query.append(WHERE_GREATER_THAN);
1848                                            }
1849                                            else {
1850                                                    query.append(WHERE_LESSER_THAN);
1851                                            }
1852                                    }
1853                            }
1854    
1855                            query.append(ORDER_BY_CLAUSE);
1856    
1857                            String[] orderByFields = orderByComparator.getOrderByFields();
1858    
1859                            for (int i = 0; i < orderByFields.length; i++) {
1860                                    if (getDB().isSupportsInlineDistinct()) {
1861                                            query.append(_ORDER_BY_ENTITY_ALIAS);
1862                                    }
1863                                    else {
1864                                            query.append(_ORDER_BY_ENTITY_TABLE);
1865                                    }
1866    
1867                                    query.append(orderByFields[i]);
1868    
1869                                    if ((i + 1) < orderByFields.length) {
1870                                            if (orderByComparator.isAscending() ^ previous) {
1871                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1872                                            }
1873                                            else {
1874                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1875                                            }
1876                                    }
1877                                    else {
1878                                            if (orderByComparator.isAscending() ^ previous) {
1879                                                    query.append(ORDER_BY_ASC);
1880                                            }
1881                                            else {
1882                                                    query.append(ORDER_BY_DESC);
1883                                            }
1884                                    }
1885                            }
1886                    }
1887    
1888                    else {
1889                            if (getDB().isSupportsInlineDistinct()) {
1890                                    query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1891                            }
1892                            else {
1893                                    query.append(SCLicenseModelImpl.ORDER_BY_SQL);
1894                            }
1895                    }
1896    
1897                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1898                                    SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1899    
1900                    SQLQuery q = session.createSQLQuery(sql);
1901    
1902                    q.setFirstResult(0);
1903                    q.setMaxResults(2);
1904    
1905                    if (getDB().isSupportsInlineDistinct()) {
1906                            q.addEntity(_FILTER_ENTITY_ALIAS, SCLicenseImpl.class);
1907                    }
1908                    else {
1909                            q.addEntity(_FILTER_ENTITY_TABLE, SCLicenseImpl.class);
1910                    }
1911    
1912                    QueryPos qPos = QueryPos.getInstance(q);
1913    
1914                    qPos.add(active);
1915    
1916                    qPos.add(recommended);
1917    
1918                    if (orderByComparator != null) {
1919                            Object[] values = orderByComparator.getOrderByConditionValues(scLicense);
1920    
1921                            for (Object value : values) {
1922                                    qPos.add(value);
1923                            }
1924                    }
1925    
1926                    List<SCLicense> list = q.list();
1927    
1928                    if (list.size() == 2) {
1929                            return list.get(1);
1930                    }
1931                    else {
1932                            return null;
1933                    }
1934            }
1935    
1936            /**
1937             * Returns all the s c licenses.
1938             *
1939             * @return the s c licenses
1940             * @throws SystemException if a system exception occurred
1941             */
1942            public List<SCLicense> findAll() throws SystemException {
1943                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1944            }
1945    
1946            /**
1947             * Returns a range of all the s c licenses.
1948             *
1949             * <p>
1950             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1951             * </p>
1952             *
1953             * @param start the lower bound of the range of s c licenses
1954             * @param end the upper bound of the range of s c licenses (not inclusive)
1955             * @return the range of s c licenses
1956             * @throws SystemException if a system exception occurred
1957             */
1958            public List<SCLicense> findAll(int start, int end)
1959                    throws SystemException {
1960                    return findAll(start, end, null);
1961            }
1962    
1963            /**
1964             * Returns an ordered range of all the s c licenses.
1965             *
1966             * <p>
1967             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1968             * </p>
1969             *
1970             * @param start the lower bound of the range of s c licenses
1971             * @param end the upper bound of the range of s c licenses (not inclusive)
1972             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1973             * @return the ordered range of s c licenses
1974             * @throws SystemException if a system exception occurred
1975             */
1976            public List<SCLicense> findAll(int start, int end,
1977                    OrderByComparator orderByComparator) throws SystemException {
1978                    FinderPath finderPath = null;
1979                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
1980    
1981                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1982                                    (orderByComparator == null)) {
1983                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1984                            finderArgs = FINDER_ARGS_EMPTY;
1985                    }
1986                    else {
1987                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1988                            finderArgs = new Object[] { start, end, orderByComparator };
1989                    }
1990    
1991                    List<SCLicense> list = (List<SCLicense>)FinderCacheUtil.getResult(finderPath,
1992                                    finderArgs, this);
1993    
1994                    if (list == null) {
1995                            StringBundler query = null;
1996                            String sql = null;
1997    
1998                            if (orderByComparator != null) {
1999                                    query = new StringBundler(2 +
2000                                                    (orderByComparator.getOrderByFields().length * 3));
2001    
2002                                    query.append(_SQL_SELECT_SCLICENSE);
2003    
2004                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2005                                            orderByComparator);
2006    
2007                                    sql = query.toString();
2008                            }
2009                            else {
2010                                    sql = _SQL_SELECT_SCLICENSE.concat(SCLicenseModelImpl.ORDER_BY_JPQL);
2011                            }
2012    
2013                            Session session = null;
2014    
2015                            try {
2016                                    session = openSession();
2017    
2018                                    Query q = session.createQuery(sql);
2019    
2020                                    if (orderByComparator == null) {
2021                                            list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
2022                                                            start, end, false);
2023    
2024                                            Collections.sort(list);
2025                                    }
2026                                    else {
2027                                            list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
2028                                                            start, end);
2029                                    }
2030                            }
2031                            catch (Exception e) {
2032                                    throw processException(e);
2033                            }
2034                            finally {
2035                                    if (list == null) {
2036                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2037                                    }
2038                                    else {
2039                                            cacheResult(list);
2040    
2041                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2042                                    }
2043    
2044                                    closeSession(session);
2045                            }
2046                    }
2047    
2048                    return list;
2049            }
2050    
2051            /**
2052             * Removes all the s c licenses where active = &#63; from the database.
2053             *
2054             * @param active the active
2055             * @throws SystemException if a system exception occurred
2056             */
2057            public void removeByActive(boolean active) throws SystemException {
2058                    for (SCLicense scLicense : findByActive(active)) {
2059                            remove(scLicense);
2060                    }
2061            }
2062    
2063            /**
2064             * Removes all the s c licenses where active = &#63; and recommended = &#63; from the database.
2065             *
2066             * @param active the active
2067             * @param recommended the recommended
2068             * @throws SystemException if a system exception occurred
2069             */
2070            public void removeByA_R(boolean active, boolean recommended)
2071                    throws SystemException {
2072                    for (SCLicense scLicense : findByA_R(active, recommended)) {
2073                            remove(scLicense);
2074                    }
2075            }
2076    
2077            /**
2078             * Removes all the s c licenses from the database.
2079             *
2080             * @throws SystemException if a system exception occurred
2081             */
2082            public void removeAll() throws SystemException {
2083                    for (SCLicense scLicense : findAll()) {
2084                            remove(scLicense);
2085                    }
2086            }
2087    
2088            /**
2089             * Returns the number of s c licenses where active = &#63;.
2090             *
2091             * @param active the active
2092             * @return the number of matching s c licenses
2093             * @throws SystemException if a system exception occurred
2094             */
2095            public int countByActive(boolean active) throws SystemException {
2096                    Object[] finderArgs = new Object[] { active };
2097    
2098                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ACTIVE,
2099                                    finderArgs, this);
2100    
2101                    if (count == null) {
2102                            StringBundler query = new StringBundler(2);
2103    
2104                            query.append(_SQL_COUNT_SCLICENSE_WHERE);
2105    
2106                            query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
2107    
2108                            String sql = query.toString();
2109    
2110                            Session session = null;
2111    
2112                            try {
2113                                    session = openSession();
2114    
2115                                    Query q = session.createQuery(sql);
2116    
2117                                    QueryPos qPos = QueryPos.getInstance(q);
2118    
2119                                    qPos.add(active);
2120    
2121                                    count = (Long)q.uniqueResult();
2122                            }
2123                            catch (Exception e) {
2124                                    throw processException(e);
2125                            }
2126                            finally {
2127                                    if (count == null) {
2128                                            count = Long.valueOf(0);
2129                                    }
2130    
2131                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ACTIVE,
2132                                            finderArgs, count);
2133    
2134                                    closeSession(session);
2135                            }
2136                    }
2137    
2138                    return count.intValue();
2139            }
2140    
2141            /**
2142             * Returns the number of s c licenses that the user has permission to view where active = &#63;.
2143             *
2144             * @param active the active
2145             * @return the number of matching s c licenses that the user has permission to view
2146             * @throws SystemException if a system exception occurred
2147             */
2148            public int filterCountByActive(boolean active) throws SystemException {
2149                    if (!InlineSQLHelperUtil.isEnabled()) {
2150                            return countByActive(active);
2151                    }
2152    
2153                    StringBundler query = new StringBundler(2);
2154    
2155                    query.append(_FILTER_SQL_COUNT_SCLICENSE_WHERE);
2156    
2157                    query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
2158    
2159                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2160                                    SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2161    
2162                    Session session = null;
2163    
2164                    try {
2165                            session = openSession();
2166    
2167                            SQLQuery q = session.createSQLQuery(sql);
2168    
2169                            q.addScalar(COUNT_COLUMN_NAME,
2170                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2171    
2172                            QueryPos qPos = QueryPos.getInstance(q);
2173    
2174                            qPos.add(active);
2175    
2176                            Long count = (Long)q.uniqueResult();
2177    
2178                            return count.intValue();
2179                    }
2180                    catch (Exception e) {
2181                            throw processException(e);
2182                    }
2183                    finally {
2184                            closeSession(session);
2185                    }
2186            }
2187    
2188            /**
2189             * Returns the number of s c licenses where active = &#63; and recommended = &#63;.
2190             *
2191             * @param active the active
2192             * @param recommended the recommended
2193             * @return the number of matching s c licenses
2194             * @throws SystemException if a system exception occurred
2195             */
2196            public int countByA_R(boolean active, boolean recommended)
2197                    throws SystemException {
2198                    Object[] finderArgs = new Object[] { active, recommended };
2199    
2200                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_A_R,
2201                                    finderArgs, this);
2202    
2203                    if (count == null) {
2204                            StringBundler query = new StringBundler(3);
2205    
2206                            query.append(_SQL_COUNT_SCLICENSE_WHERE);
2207    
2208                            query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
2209    
2210                            query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
2211    
2212                            String sql = query.toString();
2213    
2214                            Session session = null;
2215    
2216                            try {
2217                                    session = openSession();
2218    
2219                                    Query q = session.createQuery(sql);
2220    
2221                                    QueryPos qPos = QueryPos.getInstance(q);
2222    
2223                                    qPos.add(active);
2224    
2225                                    qPos.add(recommended);
2226    
2227                                    count = (Long)q.uniqueResult();
2228                            }
2229                            catch (Exception e) {
2230                                    throw processException(e);
2231                            }
2232                            finally {
2233                                    if (count == null) {
2234                                            count = Long.valueOf(0);
2235                                    }
2236    
2237                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_A_R, finderArgs,
2238                                            count);
2239    
2240                                    closeSession(session);
2241                            }
2242                    }
2243    
2244                    return count.intValue();
2245            }
2246    
2247            /**
2248             * Returns the number of s c licenses that the user has permission to view where active = &#63; and recommended = &#63;.
2249             *
2250             * @param active the active
2251             * @param recommended the recommended
2252             * @return the number of matching s c licenses that the user has permission to view
2253             * @throws SystemException if a system exception occurred
2254             */
2255            public int filterCountByA_R(boolean active, boolean recommended)
2256                    throws SystemException {
2257                    if (!InlineSQLHelperUtil.isEnabled()) {
2258                            return countByA_R(active, recommended);
2259                    }
2260    
2261                    StringBundler query = new StringBundler(3);
2262    
2263                    query.append(_FILTER_SQL_COUNT_SCLICENSE_WHERE);
2264    
2265                    query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
2266    
2267                    query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
2268    
2269                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2270                                    SCLicense.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2271    
2272                    Session session = null;
2273    
2274                    try {
2275                            session = openSession();
2276    
2277                            SQLQuery q = session.createSQLQuery(sql);
2278    
2279                            q.addScalar(COUNT_COLUMN_NAME,
2280                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2281    
2282                            QueryPos qPos = QueryPos.getInstance(q);
2283    
2284                            qPos.add(active);
2285    
2286                            qPos.add(recommended);
2287    
2288                            Long count = (Long)q.uniqueResult();
2289    
2290                            return count.intValue();
2291                    }
2292                    catch (Exception e) {
2293                            throw processException(e);
2294                    }
2295                    finally {
2296                            closeSession(session);
2297                    }
2298            }
2299    
2300            /**
2301             * Returns the number of s c licenses.
2302             *
2303             * @return the number of s c licenses
2304             * @throws SystemException if a system exception occurred
2305             */
2306            public int countAll() throws SystemException {
2307                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2308                                    FINDER_ARGS_EMPTY, this);
2309    
2310                    if (count == null) {
2311                            Session session = null;
2312    
2313                            try {
2314                                    session = openSession();
2315    
2316                                    Query q = session.createQuery(_SQL_COUNT_SCLICENSE);
2317    
2318                                    count = (Long)q.uniqueResult();
2319                            }
2320                            catch (Exception e) {
2321                                    throw processException(e);
2322                            }
2323                            finally {
2324                                    if (count == null) {
2325                                            count = Long.valueOf(0);
2326                                    }
2327    
2328                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2329                                            FINDER_ARGS_EMPTY, count);
2330    
2331                                    closeSession(session);
2332                            }
2333                    }
2334    
2335                    return count.intValue();
2336            }
2337    
2338            /**
2339             * Returns all the s c product entries associated with the s c license.
2340             *
2341             * @param pk the primary key of the s c license
2342             * @return the s c product entries associated with the s c license
2343             * @throws SystemException if a system exception occurred
2344             */
2345            public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
2346                    long pk) throws SystemException {
2347                    return getSCProductEntries(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2348            }
2349    
2350            /**
2351             * Returns a range of all the s c product entries associated with the s c license.
2352             *
2353             * <p>
2354             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2355             * </p>
2356             *
2357             * @param pk the primary key of the s c license
2358             * @param start the lower bound of the range of s c licenses
2359             * @param end the upper bound of the range of s c licenses (not inclusive)
2360             * @return the range of s c product entries associated with the s c license
2361             * @throws SystemException if a system exception occurred
2362             */
2363            public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
2364                    long pk, int start, int end) throws SystemException {
2365                    return getSCProductEntries(pk, start, end, null);
2366            }
2367    
2368            public static final FinderPath FINDER_PATH_GET_SCPRODUCTENTRIES = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
2369                            SCLicenseModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
2370                            com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryImpl.class,
2371                            SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
2372                            "getSCProductEntries",
2373                            new String[] {
2374                                    Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
2375                                    "com.liferay.portal.kernel.util.OrderByComparator"
2376                            });
2377    
2378            static {
2379                    FINDER_PATH_GET_SCPRODUCTENTRIES.setCacheKeyGeneratorCacheName(null);
2380            }
2381    
2382            /**
2383             * Returns an ordered range of all the s c product entries associated with the s c license.
2384             *
2385             * <p>
2386             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2387             * </p>
2388             *
2389             * @param pk the primary key of the s c license
2390             * @param start the lower bound of the range of s c licenses
2391             * @param end the upper bound of the range of s c licenses (not inclusive)
2392             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2393             * @return the ordered range of s c product entries associated with the s c license
2394             * @throws SystemException if a system exception occurred
2395             */
2396            public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
2397                    long pk, int start, int end, OrderByComparator orderByComparator)
2398                    throws SystemException {
2399                    Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
2400    
2401                    List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> list = (List<com.liferay.portlet.softwarecatalog.model.SCProductEntry>)FinderCacheUtil.getResult(FINDER_PATH_GET_SCPRODUCTENTRIES,
2402                                    finderArgs, this);
2403    
2404                    if (list == null) {
2405                            Session session = null;
2406    
2407                            try {
2408                                    session = openSession();
2409    
2410                                    String sql = null;
2411    
2412                                    if (orderByComparator != null) {
2413                                            sql = _SQL_GETSCPRODUCTENTRIES.concat(ORDER_BY_CLAUSE)
2414                                                                                                      .concat(orderByComparator.getOrderBy());
2415                                    }
2416                                    else {
2417                                            sql = _SQL_GETSCPRODUCTENTRIES.concat(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ORDER_BY_SQL);
2418                                    }
2419    
2420                                    SQLQuery q = session.createSQLQuery(sql);
2421    
2422                                    q.addEntity("SCProductEntry",
2423                                            com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryImpl.class);
2424    
2425                                    QueryPos qPos = QueryPos.getInstance(q);
2426    
2427                                    qPos.add(pk);
2428    
2429                                    list = (List<com.liferay.portlet.softwarecatalog.model.SCProductEntry>)QueryUtil.list(q,
2430                                                    getDialect(), start, end);
2431                            }
2432                            catch (Exception e) {
2433                                    throw processException(e);
2434                            }
2435                            finally {
2436                                    if (list == null) {
2437                                            FinderCacheUtil.removeResult(FINDER_PATH_GET_SCPRODUCTENTRIES,
2438                                                    finderArgs);
2439                                    }
2440                                    else {
2441                                            scProductEntryPersistence.cacheResult(list);
2442    
2443                                            FinderCacheUtil.putResult(FINDER_PATH_GET_SCPRODUCTENTRIES,
2444                                                    finderArgs, list);
2445                                    }
2446    
2447                                    closeSession(session);
2448                            }
2449                    }
2450    
2451                    return list;
2452            }
2453    
2454            public static final FinderPath FINDER_PATH_GET_SCPRODUCTENTRIES_SIZE = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
2455                            SCLicenseModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
2456                            Long.class,
2457                            SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
2458                            "getSCProductEntriesSize", new String[] { Long.class.getName() });
2459    
2460            static {
2461                    FINDER_PATH_GET_SCPRODUCTENTRIES_SIZE.setCacheKeyGeneratorCacheName(null);
2462            }
2463    
2464            /**
2465             * Returns the number of s c product entries associated with the s c license.
2466             *
2467             * @param pk the primary key of the s c license
2468             * @return the number of s c product entries associated with the s c license
2469             * @throws SystemException if a system exception occurred
2470             */
2471            public int getSCProductEntriesSize(long pk) throws SystemException {
2472                    Object[] finderArgs = new Object[] { pk };
2473    
2474                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_SCPRODUCTENTRIES_SIZE,
2475                                    finderArgs, this);
2476    
2477                    if (count == null) {
2478                            Session session = null;
2479    
2480                            try {
2481                                    session = openSession();
2482    
2483                                    SQLQuery q = session.createSQLQuery(_SQL_GETSCPRODUCTENTRIESSIZE);
2484    
2485                                    q.addScalar(COUNT_COLUMN_NAME,
2486                                            com.liferay.portal.kernel.dao.orm.Type.LONG);
2487    
2488                                    QueryPos qPos = QueryPos.getInstance(q);
2489    
2490                                    qPos.add(pk);
2491    
2492                                    count = (Long)q.uniqueResult();
2493                            }
2494                            catch (Exception e) {
2495                                    throw processException(e);
2496                            }
2497                            finally {
2498                                    if (count == null) {
2499                                            count = Long.valueOf(0);
2500                                    }
2501    
2502                                    FinderCacheUtil.putResult(FINDER_PATH_GET_SCPRODUCTENTRIES_SIZE,
2503                                            finderArgs, count);
2504    
2505                                    closeSession(session);
2506                            }
2507                    }
2508    
2509                    return count.intValue();
2510            }
2511    
2512            public static final FinderPath FINDER_PATH_CONTAINS_SCPRODUCTENTRY = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
2513                            SCLicenseModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
2514                            Boolean.class,
2515                            SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
2516                            "containsSCProductEntry",
2517                            new String[] { Long.class.getName(), Long.class.getName() });
2518    
2519            /**
2520             * Returns <code>true</code> if the s c product entry is associated with the s c license.
2521             *
2522             * @param pk the primary key of the s c license
2523             * @param scProductEntryPK the primary key of the s c product entry
2524             * @return <code>true</code> if the s c product entry is associated with the s c license; <code>false</code> otherwise
2525             * @throws SystemException if a system exception occurred
2526             */
2527            public boolean containsSCProductEntry(long pk, long scProductEntryPK)
2528                    throws SystemException {
2529                    Object[] finderArgs = new Object[] { pk, scProductEntryPK };
2530    
2531                    Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_SCPRODUCTENTRY,
2532                                    finderArgs, this);
2533    
2534                    if (value == null) {
2535                            try {
2536                                    value = Boolean.valueOf(containsSCProductEntry.contains(pk,
2537                                                            scProductEntryPK));
2538                            }
2539                            catch (Exception e) {
2540                                    throw processException(e);
2541                            }
2542                            finally {
2543                                    if (value == null) {
2544                                            value = Boolean.FALSE;
2545                                    }
2546    
2547                                    FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_SCPRODUCTENTRY,
2548                                            finderArgs, value);
2549                            }
2550                    }
2551    
2552                    return value.booleanValue();
2553            }
2554    
2555            /**
2556             * Returns <code>true</code> if the s c license has any s c product entries associated with it.
2557             *
2558             * @param pk the primary key of the s c license to check for associations with s c product entries
2559             * @return <code>true</code> if the s c license has any s c product entries associated with it; <code>false</code> otherwise
2560             * @throws SystemException if a system exception occurred
2561             */
2562            public boolean containsSCProductEntries(long pk) throws SystemException {
2563                    if (getSCProductEntriesSize(pk) > 0) {
2564                            return true;
2565                    }
2566                    else {
2567                            return false;
2568                    }
2569            }
2570    
2571            /**
2572             * Adds an association between the s c license and the s c product entry. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2573             *
2574             * @param pk the primary key of the s c license
2575             * @param scProductEntryPK the primary key of the s c product entry
2576             * @throws SystemException if a system exception occurred
2577             */
2578            public void addSCProductEntry(long pk, long scProductEntryPK)
2579                    throws SystemException {
2580                    try {
2581                            addSCProductEntry.add(pk, scProductEntryPK);
2582                    }
2583                    catch (Exception e) {
2584                            throw processException(e);
2585                    }
2586                    finally {
2587                            FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2588                    }
2589            }
2590    
2591            /**
2592             * Adds an association between the s c license and the s c product entry. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2593             *
2594             * @param pk the primary key of the s c license
2595             * @param scProductEntry the s c product entry
2596             * @throws SystemException if a system exception occurred
2597             */
2598            public void addSCProductEntry(long pk,
2599                    com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry)
2600                    throws SystemException {
2601                    try {
2602                            addSCProductEntry.add(pk, scProductEntry.getPrimaryKey());
2603                    }
2604                    catch (Exception e) {
2605                            throw processException(e);
2606                    }
2607                    finally {
2608                            FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2609                    }
2610            }
2611    
2612            /**
2613             * Adds an association between the s c license and the s c product entries. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2614             *
2615             * @param pk the primary key of the s c license
2616             * @param scProductEntryPKs the primary keys of the s c product entries
2617             * @throws SystemException if a system exception occurred
2618             */
2619            public void addSCProductEntries(long pk, long[] scProductEntryPKs)
2620                    throws SystemException {
2621                    try {
2622                            for (long scProductEntryPK : scProductEntryPKs) {
2623                                    addSCProductEntry.add(pk, scProductEntryPK);
2624                            }
2625                    }
2626                    catch (Exception e) {
2627                            throw processException(e);
2628                    }
2629                    finally {
2630                            FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2631                    }
2632            }
2633    
2634            /**
2635             * Adds an association between the s c license and the s c product entries. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2636             *
2637             * @param pk the primary key of the s c license
2638             * @param scProductEntries the s c product entries
2639             * @throws SystemException if a system exception occurred
2640             */
2641            public void addSCProductEntries(long pk,
2642                    List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries)
2643                    throws SystemException {
2644                    try {
2645                            for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2646                                    addSCProductEntry.add(pk, scProductEntry.getPrimaryKey());
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            /**
2658             * Clears all associations between the s c license and its s c product entries. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2659             *
2660             * @param pk the primary key of the s c license to clear the associated s c product entries from
2661             * @throws SystemException if a system exception occurred
2662             */
2663            public void clearSCProductEntries(long pk) throws SystemException {
2664                    try {
2665                            clearSCProductEntries.clear(pk);
2666                    }
2667                    catch (Exception e) {
2668                            throw processException(e);
2669                    }
2670                    finally {
2671                            FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2672                    }
2673            }
2674    
2675            /**
2676             * Removes the association between the s c license and the s c product entry. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2677             *
2678             * @param pk the primary key of the s c license
2679             * @param scProductEntryPK the primary key of the s c product entry
2680             * @throws SystemException if a system exception occurred
2681             */
2682            public void removeSCProductEntry(long pk, long scProductEntryPK)
2683                    throws SystemException {
2684                    try {
2685                            removeSCProductEntry.remove(pk, scProductEntryPK);
2686                    }
2687                    catch (Exception e) {
2688                            throw processException(e);
2689                    }
2690                    finally {
2691                            FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2692                    }
2693            }
2694    
2695            /**
2696             * Removes the association between the s c license and the s c product entry. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2697             *
2698             * @param pk the primary key of the s c license
2699             * @param scProductEntry the s c product entry
2700             * @throws SystemException if a system exception occurred
2701             */
2702            public void removeSCProductEntry(long pk,
2703                    com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry)
2704                    throws SystemException {
2705                    try {
2706                            removeSCProductEntry.remove(pk, scProductEntry.getPrimaryKey());
2707                    }
2708                    catch (Exception e) {
2709                            throw processException(e);
2710                    }
2711                    finally {
2712                            FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2713                    }
2714            }
2715    
2716            /**
2717             * Removes the association between the s c license and the s c product entries. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2718             *
2719             * @param pk the primary key of the s c license
2720             * @param scProductEntryPKs the primary keys of the s c product entries
2721             * @throws SystemException if a system exception occurred
2722             */
2723            public void removeSCProductEntries(long pk, long[] scProductEntryPKs)
2724                    throws SystemException {
2725                    try {
2726                            for (long scProductEntryPK : scProductEntryPKs) {
2727                                    removeSCProductEntry.remove(pk, scProductEntryPK);
2728                            }
2729                    }
2730                    catch (Exception e) {
2731                            throw processException(e);
2732                    }
2733                    finally {
2734                            FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2735                    }
2736            }
2737    
2738            /**
2739             * Removes the association between the s c license and the s c product entries. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2740             *
2741             * @param pk the primary key of the s c license
2742             * @param scProductEntries the s c product entries
2743             * @throws SystemException if a system exception occurred
2744             */
2745            public void removeSCProductEntries(long pk,
2746                    List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries)
2747                    throws SystemException {
2748                    try {
2749                            for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2750                                    removeSCProductEntry.remove(pk, scProductEntry.getPrimaryKey());
2751                            }
2752                    }
2753                    catch (Exception e) {
2754                            throw processException(e);
2755                    }
2756                    finally {
2757                            FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2758                    }
2759            }
2760    
2761            /**
2762             * Sets the s c product entries associated with the s c license, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2763             *
2764             * @param pk the primary key of the s c license
2765             * @param scProductEntryPKs the primary keys of the s c product entries to be associated with the s c license
2766             * @throws SystemException if a system exception occurred
2767             */
2768            public void setSCProductEntries(long pk, long[] scProductEntryPKs)
2769                    throws SystemException {
2770                    try {
2771                            Set<Long> scProductEntryPKSet = SetUtil.fromArray(scProductEntryPKs);
2772    
2773                            List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries =
2774                                    getSCProductEntries(pk);
2775    
2776                            for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2777                                    if (!scProductEntryPKSet.remove(scProductEntry.getPrimaryKey())) {
2778                                            removeSCProductEntry.remove(pk,
2779                                                    scProductEntry.getPrimaryKey());
2780                                    }
2781                            }
2782    
2783                            for (Long scProductEntryPK : scProductEntryPKSet) {
2784                                    addSCProductEntry.add(pk, scProductEntryPK);
2785                            }
2786                    }
2787                    catch (Exception e) {
2788                            throw processException(e);
2789                    }
2790                    finally {
2791                            FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2792                    }
2793            }
2794    
2795            /**
2796             * Sets the s c product entries associated with the s c license, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2797             *
2798             * @param pk the primary key of the s c license
2799             * @param scProductEntries the s c product entries to be associated with the s c license
2800             * @throws SystemException if a system exception occurred
2801             */
2802            public void setSCProductEntries(long pk,
2803                    List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries)
2804                    throws SystemException {
2805                    try {
2806                            long[] scProductEntryPKs = new long[scProductEntries.size()];
2807    
2808                            for (int i = 0; i < scProductEntries.size(); i++) {
2809                                    com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry =
2810                                            scProductEntries.get(i);
2811    
2812                                    scProductEntryPKs[i] = scProductEntry.getPrimaryKey();
2813                            }
2814    
2815                            setSCProductEntries(pk, scProductEntryPKs);
2816                    }
2817                    catch (Exception e) {
2818                            throw processException(e);
2819                    }
2820                    finally {
2821                            FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2822                    }
2823            }
2824    
2825            /**
2826             * Initializes the s c license persistence.
2827             */
2828            public void afterPropertiesSet() {
2829                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2830                                            com.liferay.portal.util.PropsUtil.get(
2831                                                    "value.object.listener.com.liferay.portlet.softwarecatalog.model.SCLicense")));
2832    
2833                    if (listenerClassNames.length > 0) {
2834                            try {
2835                                    List<ModelListener<SCLicense>> listenersList = new ArrayList<ModelListener<SCLicense>>();
2836    
2837                                    for (String listenerClassName : listenerClassNames) {
2838                                            Class<?> clazz = getClass();
2839    
2840                                            listenersList.add((ModelListener<SCLicense>)InstanceFactory.newInstance(
2841                                                            clazz.getClassLoader(), listenerClassName));
2842                                    }
2843    
2844                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2845                            }
2846                            catch (Exception e) {
2847                                    _log.error(e);
2848                            }
2849                    }
2850    
2851                    containsSCProductEntry = new ContainsSCProductEntry();
2852    
2853                    addSCProductEntry = new AddSCProductEntry();
2854                    clearSCProductEntries = new ClearSCProductEntries();
2855                    removeSCProductEntry = new RemoveSCProductEntry();
2856            }
2857    
2858            public void destroy() {
2859                    EntityCacheUtil.removeCache(SCLicenseImpl.class.getName());
2860                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2861                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2862            }
2863    
2864            @BeanReference(type = SCFrameworkVersionPersistence.class)
2865            protected SCFrameworkVersionPersistence scFrameworkVersionPersistence;
2866            @BeanReference(type = SCLicensePersistence.class)
2867            protected SCLicensePersistence scLicensePersistence;
2868            @BeanReference(type = SCProductEntryPersistence.class)
2869            protected SCProductEntryPersistence scProductEntryPersistence;
2870            @BeanReference(type = SCProductScreenshotPersistence.class)
2871            protected SCProductScreenshotPersistence scProductScreenshotPersistence;
2872            @BeanReference(type = SCProductVersionPersistence.class)
2873            protected SCProductVersionPersistence scProductVersionPersistence;
2874            @BeanReference(type = ResourcePersistence.class)
2875            protected ResourcePersistence resourcePersistence;
2876            @BeanReference(type = UserPersistence.class)
2877            protected UserPersistence userPersistence;
2878            protected ContainsSCProductEntry containsSCProductEntry;
2879            protected AddSCProductEntry addSCProductEntry;
2880            protected ClearSCProductEntries clearSCProductEntries;
2881            protected RemoveSCProductEntry removeSCProductEntry;
2882    
2883            protected class ContainsSCProductEntry {
2884                    protected ContainsSCProductEntry() {
2885                            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2886                                            _SQL_CONTAINSSCPRODUCTENTRY,
2887                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
2888                                            RowMapper.COUNT);
2889                    }
2890    
2891                    protected boolean contains(long licenseId, long productEntryId) {
2892                            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2893                                                    new Long(licenseId), new Long(productEntryId)
2894                                            });
2895    
2896                            if (results.size() > 0) {
2897                                    Integer count = results.get(0);
2898    
2899                                    if (count.intValue() > 0) {
2900                                            return true;
2901                                    }
2902                            }
2903    
2904                            return false;
2905                    }
2906    
2907                    private MappingSqlQuery<Integer> _mappingSqlQuery;
2908            }
2909    
2910            protected class AddSCProductEntry {
2911                    protected AddSCProductEntry() {
2912                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2913                                            "INSERT INTO SCLicenses_SCProductEntries (licenseId, productEntryId) VALUES (?, ?)",
2914                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2915                    }
2916    
2917                    protected void add(long licenseId, long productEntryId)
2918                            throws SystemException {
2919                            if (!containsSCProductEntry.contains(licenseId, productEntryId)) {
2920                                    ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry>[] scProductEntryListeners =
2921                                            scProductEntryPersistence.getListeners();
2922    
2923                                    for (ModelListener<SCLicense> listener : listeners) {
2924                                            listener.onBeforeAddAssociation(licenseId,
2925                                                    com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2926                                                    productEntryId);
2927                                    }
2928    
2929                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2930                                            listener.onBeforeAddAssociation(productEntryId,
2931                                                    SCLicense.class.getName(), licenseId);
2932                                    }
2933    
2934                                    _sqlUpdate.update(new Object[] {
2935                                                    new Long(licenseId), new Long(productEntryId)
2936                                            });
2937    
2938                                    for (ModelListener<SCLicense> listener : listeners) {
2939                                            listener.onAfterAddAssociation(licenseId,
2940                                                    com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2941                                                    productEntryId);
2942                                    }
2943    
2944                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2945                                            listener.onAfterAddAssociation(productEntryId,
2946                                                    SCLicense.class.getName(), licenseId);
2947                                    }
2948                            }
2949                    }
2950    
2951                    private SqlUpdate _sqlUpdate;
2952            }
2953    
2954            protected class ClearSCProductEntries {
2955                    protected ClearSCProductEntries() {
2956                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2957                                            "DELETE FROM SCLicenses_SCProductEntries WHERE licenseId = ?",
2958                                            new int[] { java.sql.Types.BIGINT });
2959                    }
2960    
2961                    protected void clear(long licenseId) throws SystemException {
2962                            ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry>[] scProductEntryListeners =
2963                                    scProductEntryPersistence.getListeners();
2964    
2965                            List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries =
2966                                    null;
2967    
2968                            if ((listeners.length > 0) || (scProductEntryListeners.length > 0)) {
2969                                    scProductEntries = getSCProductEntries(licenseId);
2970    
2971                                    for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2972                                            for (ModelListener<SCLicense> listener : listeners) {
2973                                                    listener.onBeforeRemoveAssociation(licenseId,
2974                                                            com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2975                                                            scProductEntry.getPrimaryKey());
2976                                            }
2977    
2978                                            for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2979                                                    listener.onBeforeRemoveAssociation(scProductEntry.getPrimaryKey(),
2980                                                            SCLicense.class.getName(), licenseId);
2981                                            }
2982                                    }
2983                            }
2984    
2985                            _sqlUpdate.update(new Object[] { new Long(licenseId) });
2986    
2987                            if ((listeners.length > 0) || (scProductEntryListeners.length > 0)) {
2988                                    for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2989                                            for (ModelListener<SCLicense> listener : listeners) {
2990                                                    listener.onAfterRemoveAssociation(licenseId,
2991                                                            com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2992                                                            scProductEntry.getPrimaryKey());
2993                                            }
2994    
2995                                            for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2996                                                    listener.onAfterRemoveAssociation(scProductEntry.getPrimaryKey(),
2997                                                            SCLicense.class.getName(), licenseId);
2998                                            }
2999                                    }
3000                            }
3001                    }
3002    
3003                    private SqlUpdate _sqlUpdate;
3004            }
3005    
3006            protected class RemoveSCProductEntry {
3007                    protected RemoveSCProductEntry() {
3008                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3009                                            "DELETE FROM SCLicenses_SCProductEntries WHERE licenseId = ? AND productEntryId = ?",
3010                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3011                    }
3012    
3013                    protected void remove(long licenseId, long productEntryId)
3014                            throws SystemException {
3015                            if (containsSCProductEntry.contains(licenseId, productEntryId)) {
3016                                    ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry>[] scProductEntryListeners =
3017                                            scProductEntryPersistence.getListeners();
3018    
3019                                    for (ModelListener<SCLicense> listener : listeners) {
3020                                            listener.onBeforeRemoveAssociation(licenseId,
3021                                                    com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
3022                                                    productEntryId);
3023                                    }
3024    
3025                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
3026                                            listener.onBeforeRemoveAssociation(productEntryId,
3027                                                    SCLicense.class.getName(), licenseId);
3028                                    }
3029    
3030                                    _sqlUpdate.update(new Object[] {
3031                                                    new Long(licenseId), new Long(productEntryId)
3032                                            });
3033    
3034                                    for (ModelListener<SCLicense> listener : listeners) {
3035                                            listener.onAfterRemoveAssociation(licenseId,
3036                                                    com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
3037                                                    productEntryId);
3038                                    }
3039    
3040                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
3041                                            listener.onAfterRemoveAssociation(productEntryId,
3042                                                    SCLicense.class.getName(), licenseId);
3043                                    }
3044                            }
3045                    }
3046    
3047                    private SqlUpdate _sqlUpdate;
3048            }
3049    
3050            private static final String _SQL_SELECT_SCLICENSE = "SELECT scLicense FROM SCLicense scLicense";
3051            private static final String _SQL_SELECT_SCLICENSE_WHERE = "SELECT scLicense FROM SCLicense scLicense WHERE ";
3052            private static final String _SQL_COUNT_SCLICENSE = "SELECT COUNT(scLicense) FROM SCLicense scLicense";
3053            private static final String _SQL_COUNT_SCLICENSE_WHERE = "SELECT COUNT(scLicense) FROM SCLicense scLicense WHERE ";
3054            private static final String _SQL_GETSCPRODUCTENTRIES = "SELECT {SCProductEntry.*} FROM SCProductEntry INNER JOIN SCLicenses_SCProductEntries ON (SCLicenses_SCProductEntries.productEntryId = SCProductEntry.productEntryId) WHERE (SCLicenses_SCProductEntries.licenseId = ?)";
3055            private static final String _SQL_GETSCPRODUCTENTRIESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE licenseId = ?";
3056            private static final String _SQL_CONTAINSSCPRODUCTENTRY = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE licenseId = ? AND productEntryId = ?";
3057            private static final String _FINDER_COLUMN_ACTIVE_ACTIVE_2 = "scLicense.active = ?";
3058            private static final String _FINDER_COLUMN_A_R_ACTIVE_2 = "scLicense.active = ? AND ";
3059            private static final String _FINDER_COLUMN_A_R_RECOMMENDED_2 = "scLicense.recommended = ?";
3060            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "scLicense.licenseId";
3061            private static final String _FILTER_SQL_SELECT_SCLICENSE_WHERE = "SELECT DISTINCT {scLicense.*} FROM SCLicense scLicense WHERE ";
3062            private static final String _FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1 =
3063                    "SELECT {SCLicense.*} FROM (SELECT DISTINCT scLicense.licenseId FROM SCLicense scLicense WHERE ";
3064            private static final String _FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2 =
3065                    ") TEMP_TABLE INNER JOIN SCLicense ON TEMP_TABLE.licenseId = SCLicense.licenseId";
3066            private static final String _FILTER_SQL_COUNT_SCLICENSE_WHERE = "SELECT COUNT(DISTINCT scLicense.licenseId) AS COUNT_VALUE FROM SCLicense scLicense WHERE ";
3067            private static final String _FILTER_ENTITY_ALIAS = "scLicense";
3068            private static final String _FILTER_ENTITY_TABLE = "SCLicense";
3069            private static final String _ORDER_BY_ENTITY_ALIAS = "scLicense.";
3070            private static final String _ORDER_BY_ENTITY_TABLE = "SCLicense.";
3071            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SCLicense exists with the primary key ";
3072            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SCLicense exists with the key {";
3073            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3074            private static Log _log = LogFactoryUtil.getLog(SCLicensePersistenceImpl.class);
3075            private static SCLicense _nullSCLicense = new SCLicenseImpl() {
3076                            @Override
3077                            public Object clone() {
3078                                    return this;
3079                            }
3080    
3081                            @Override
3082                            public CacheModel<SCLicense> toCacheModel() {
3083                                    return _nullSCLicenseCacheModel;
3084                            }
3085                    };
3086    
3087            private static CacheModel<SCLicense> _nullSCLicenseCacheModel = new CacheModel<SCLicense>() {
3088                            public SCLicense toEntityModel() {
3089                                    return _nullSCLicense;
3090                            }
3091                    };
3092    }