001    /**
002     * Copyright (c) 2000-2011 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.annotation.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.ModelListener;
044    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
045    import com.liferay.portal.service.persistence.BatchSessionUtil;
046    import com.liferay.portal.service.persistence.ResourcePersistence;
047    import com.liferay.portal.service.persistence.UserPersistence;
048    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
049    
050    import com.liferay.portlet.softwarecatalog.NoSuchLicenseException;
051    import com.liferay.portlet.softwarecatalog.model.SCLicense;
052    import com.liferay.portlet.softwarecatalog.model.impl.SCLicenseImpl;
053    import com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl;
054    
055    import java.io.Serializable;
056    
057    import java.util.ArrayList;
058    import java.util.Collections;
059    import java.util.List;
060    import java.util.Set;
061    
062    /**
063     * The persistence implementation for the s c license service.
064     *
065     * <p>
066     * 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.
067     * </p>
068     *
069     * <p>
070     * Caching information and settings can be found in <code>portal.properties</code>
071     * </p>
072     *
073     * @author Brian Wing Shun Chan
074     * @see SCLicensePersistence
075     * @see SCLicenseUtil
076     * @generated
077     */
078    public class SCLicensePersistenceImpl extends BasePersistenceImpl<SCLicense>
079            implements SCLicensePersistence {
080            public static final String FINDER_CLASS_NAME_ENTITY = SCLicenseImpl.class.getName();
081            public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
082                    ".List";
083            public static final FinderPath FINDER_PATH_FIND_BY_ACTIVE = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
084                            SCLicenseModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
085                            "findByActive",
086                            new String[] {
087                                    Boolean.class.getName(),
088                                    
089                            "java.lang.Integer", "java.lang.Integer",
090                                    "com.liferay.portal.kernel.util.OrderByComparator"
091                            });
092            public static final FinderPath FINDER_PATH_COUNT_BY_ACTIVE = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
093                            SCLicenseModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
094                            "countByActive", new String[] { Boolean.class.getName() });
095            public static final FinderPath FINDER_PATH_FIND_BY_A_R = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
096                            SCLicenseModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
097                            "findByA_R",
098                            new String[] {
099                                    Boolean.class.getName(), Boolean.class.getName(),
100                                    
101                            "java.lang.Integer", "java.lang.Integer",
102                                    "com.liferay.portal.kernel.util.OrderByComparator"
103                            });
104            public static final FinderPath FINDER_PATH_COUNT_BY_A_R = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
105                            SCLicenseModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
106                            "countByA_R",
107                            new String[] { Boolean.class.getName(), Boolean.class.getName() });
108            public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
109                            SCLicenseModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
110                            "findAll", new String[0]);
111            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
112                            SCLicenseModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
113                            "countAll", new String[0]);
114    
115            /**
116             * Caches the s c license in the entity cache if it is enabled.
117             *
118             * @param scLicense the s c license to cache
119             */
120            public void cacheResult(SCLicense scLicense) {
121                    EntityCacheUtil.putResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
122                            SCLicenseImpl.class, scLicense.getPrimaryKey(), scLicense);
123            }
124    
125            /**
126             * Caches the s c licenses in the entity cache if it is enabled.
127             *
128             * @param scLicenses the s c licenses to cache
129             */
130            public void cacheResult(List<SCLicense> scLicenses) {
131                    for (SCLicense scLicense : scLicenses) {
132                            if (EntityCacheUtil.getResult(
133                                                    SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
134                                                    SCLicenseImpl.class, scLicense.getPrimaryKey(), this) == null) {
135                                    cacheResult(scLicense);
136                            }
137                    }
138            }
139    
140            /**
141             * Clears the cache for all s c licenses.
142             *
143             * <p>
144             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
145             * </p>
146             */
147            public void clearCache() {
148                    CacheRegistryUtil.clear(SCLicenseImpl.class.getName());
149                    EntityCacheUtil.clearCache(SCLicenseImpl.class.getName());
150                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
151                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
152            }
153    
154            /**
155             * Clears the cache for the s c license.
156             *
157             * <p>
158             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
159             * </p>
160             */
161            public void clearCache(SCLicense scLicense) {
162                    EntityCacheUtil.removeResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
163                            SCLicenseImpl.class, scLicense.getPrimaryKey());
164            }
165    
166            /**
167             * Creates a new s c license with the primary key. Does not add the s c license to the database.
168             *
169             * @param licenseId the primary key for the new s c license
170             * @return the new s c license
171             */
172            public SCLicense create(long licenseId) {
173                    SCLicense scLicense = new SCLicenseImpl();
174    
175                    scLicense.setNew(true);
176                    scLicense.setPrimaryKey(licenseId);
177    
178                    return scLicense;
179            }
180    
181            /**
182             * Removes the s c license with the primary key from the database. Also notifies the appropriate model listeners.
183             *
184             * @param primaryKey the primary key of the s c license to remove
185             * @return the s c license that was removed
186             * @throws com.liferay.portal.NoSuchModelException if a s c license with the primary key could not be found
187             * @throws SystemException if a system exception occurred
188             */
189            public SCLicense remove(Serializable primaryKey)
190                    throws NoSuchModelException, SystemException {
191                    return remove(((Long)primaryKey).longValue());
192            }
193    
194            /**
195             * Removes the s c license with the primary key from the database. Also notifies the appropriate model listeners.
196             *
197             * @param licenseId the primary key of the s c license to remove
198             * @return the s c license that was removed
199             * @throws com.liferay.portlet.softwarecatalog.NoSuchLicenseException if a s c license with the primary key could not be found
200             * @throws SystemException if a system exception occurred
201             */
202            public SCLicense remove(long licenseId)
203                    throws NoSuchLicenseException, SystemException {
204                    Session session = null;
205    
206                    try {
207                            session = openSession();
208    
209                            SCLicense scLicense = (SCLicense)session.get(SCLicenseImpl.class,
210                                            new Long(licenseId));
211    
212                            if (scLicense == null) {
213                                    if (_log.isWarnEnabled()) {
214                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + licenseId);
215                                    }
216    
217                                    throw new NoSuchLicenseException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
218                                            licenseId);
219                            }
220    
221                            return remove(scLicense);
222                    }
223                    catch (NoSuchLicenseException nsee) {
224                            throw nsee;
225                    }
226                    catch (Exception e) {
227                            throw processException(e);
228                    }
229                    finally {
230                            closeSession(session);
231                    }
232            }
233    
234            protected SCLicense removeImpl(SCLicense scLicense)
235                    throws SystemException {
236                    scLicense = toUnwrappedModel(scLicense);
237    
238                    try {
239                            clearSCProductEntries.clear(scLicense.getPrimaryKey());
240                    }
241                    catch (Exception e) {
242                            throw processException(e);
243                    }
244                    finally {
245                            FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
246                    }
247    
248                    Session session = null;
249    
250                    try {
251                            session = openSession();
252    
253                            BatchSessionUtil.delete(session, scLicense);
254                    }
255                    catch (Exception e) {
256                            throw processException(e);
257                    }
258                    finally {
259                            closeSession(session);
260                    }
261    
262                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
263    
264                    EntityCacheUtil.removeResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
265                            SCLicenseImpl.class, scLicense.getPrimaryKey());
266    
267                    return scLicense;
268            }
269    
270            public SCLicense updateImpl(
271                    com.liferay.portlet.softwarecatalog.model.SCLicense scLicense,
272                    boolean merge) throws SystemException {
273                    scLicense = toUnwrappedModel(scLicense);
274    
275                    Session session = null;
276    
277                    try {
278                            session = openSession();
279    
280                            BatchSessionUtil.update(session, scLicense, merge);
281    
282                            scLicense.setNew(false);
283                    }
284                    catch (Exception e) {
285                            throw processException(e);
286                    }
287                    finally {
288                            closeSession(session);
289                    }
290    
291                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
292    
293                    EntityCacheUtil.putResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
294                            SCLicenseImpl.class, scLicense.getPrimaryKey(), scLicense);
295    
296                    return scLicense;
297            }
298    
299            protected SCLicense toUnwrappedModel(SCLicense scLicense) {
300                    if (scLicense instanceof SCLicenseImpl) {
301                            return scLicense;
302                    }
303    
304                    SCLicenseImpl scLicenseImpl = new SCLicenseImpl();
305    
306                    scLicenseImpl.setNew(scLicense.isNew());
307                    scLicenseImpl.setPrimaryKey(scLicense.getPrimaryKey());
308    
309                    scLicenseImpl.setLicenseId(scLicense.getLicenseId());
310                    scLicenseImpl.setName(scLicense.getName());
311                    scLicenseImpl.setUrl(scLicense.getUrl());
312                    scLicenseImpl.setOpenSource(scLicense.isOpenSource());
313                    scLicenseImpl.setActive(scLicense.isActive());
314                    scLicenseImpl.setRecommended(scLicense.isRecommended());
315    
316                    return scLicenseImpl;
317            }
318    
319            /**
320             * Finds the s c license with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
321             *
322             * @param primaryKey the primary key of the s c license to find
323             * @return the s c license
324             * @throws com.liferay.portal.NoSuchModelException if a s c license with the primary key could not be found
325             * @throws SystemException if a system exception occurred
326             */
327            public SCLicense findByPrimaryKey(Serializable primaryKey)
328                    throws NoSuchModelException, SystemException {
329                    return findByPrimaryKey(((Long)primaryKey).longValue());
330            }
331    
332            /**
333             * Finds the s c license with the primary key or throws a {@link com.liferay.portlet.softwarecatalog.NoSuchLicenseException} if it could not be found.
334             *
335             * @param licenseId the primary key of the s c license to find
336             * @return the s c license
337             * @throws com.liferay.portlet.softwarecatalog.NoSuchLicenseException if a s c license with the primary key could not be found
338             * @throws SystemException if a system exception occurred
339             */
340            public SCLicense findByPrimaryKey(long licenseId)
341                    throws NoSuchLicenseException, SystemException {
342                    SCLicense scLicense = fetchByPrimaryKey(licenseId);
343    
344                    if (scLicense == null) {
345                            if (_log.isWarnEnabled()) {
346                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + licenseId);
347                            }
348    
349                            throw new NoSuchLicenseException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
350                                    licenseId);
351                    }
352    
353                    return scLicense;
354            }
355    
356            /**
357             * Finds the s c license with the primary key or returns <code>null</code> if it could not be found.
358             *
359             * @param primaryKey the primary key of the s c license to find
360             * @return the s c license, or <code>null</code> if a s c license with the primary key could not be found
361             * @throws SystemException if a system exception occurred
362             */
363            public SCLicense fetchByPrimaryKey(Serializable primaryKey)
364                    throws SystemException {
365                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
366            }
367    
368            /**
369             * Finds the s c license with the primary key or returns <code>null</code> if it could not be found.
370             *
371             * @param licenseId the primary key of the s c license to find
372             * @return the s c license, or <code>null</code> if a s c license with the primary key could not be found
373             * @throws SystemException if a system exception occurred
374             */
375            public SCLicense fetchByPrimaryKey(long licenseId)
376                    throws SystemException {
377                    SCLicense scLicense = (SCLicense)EntityCacheUtil.getResult(SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
378                                    SCLicenseImpl.class, licenseId, this);
379    
380                    if (scLicense == null) {
381                            Session session = null;
382    
383                            try {
384                                    session = openSession();
385    
386                                    scLicense = (SCLicense)session.get(SCLicenseImpl.class,
387                                                    new Long(licenseId));
388                            }
389                            catch (Exception e) {
390                                    throw processException(e);
391                            }
392                            finally {
393                                    if (scLicense != null) {
394                                            cacheResult(scLicense);
395                                    }
396    
397                                    closeSession(session);
398                            }
399                    }
400    
401                    return scLicense;
402            }
403    
404            /**
405             * Finds all the s c licenses where active = &#63;.
406             *
407             * @param active the active to search with
408             * @return the matching s c licenses
409             * @throws SystemException if a system exception occurred
410             */
411            public List<SCLicense> findByActive(boolean active)
412                    throws SystemException {
413                    return findByActive(active, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
414            }
415    
416            /**
417             * Finds a range of all the s c licenses where active = &#63;.
418             *
419             * <p>
420             * 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.
421             * </p>
422             *
423             * @param active the active to search with
424             * @param start the lower bound of the range of s c licenses to return
425             * @param end the upper bound of the range of s c licenses to return (not inclusive)
426             * @return the range of matching s c licenses
427             * @throws SystemException if a system exception occurred
428             */
429            public List<SCLicense> findByActive(boolean active, int start, int end)
430                    throws SystemException {
431                    return findByActive(active, start, end, null);
432            }
433    
434            /**
435             * Finds an ordered range of all the s c licenses where active = &#63;.
436             *
437             * <p>
438             * 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.
439             * </p>
440             *
441             * @param active the active to search with
442             * @param start the lower bound of the range of s c licenses to return
443             * @param end the upper bound of the range of s c licenses to return (not inclusive)
444             * @param orderByComparator the comparator to order the results by
445             * @return the ordered range of matching s c licenses
446             * @throws SystemException if a system exception occurred
447             */
448            public List<SCLicense> findByActive(boolean active, int start, int end,
449                    OrderByComparator orderByComparator) throws SystemException {
450                    Object[] finderArgs = new Object[] {
451                                    active,
452                                    
453                                    String.valueOf(start), String.valueOf(end),
454                                    String.valueOf(orderByComparator)
455                            };
456    
457                    List<SCLicense> list = (List<SCLicense>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_ACTIVE,
458                                    finderArgs, this);
459    
460                    if (list == null) {
461                            StringBundler query = null;
462    
463                            if (orderByComparator != null) {
464                                    query = new StringBundler(3 +
465                                                    (orderByComparator.getOrderByFields().length * 3));
466                            }
467                            else {
468                                    query = new StringBundler(3);
469                            }
470    
471                            query.append(_SQL_SELECT_SCLICENSE_WHERE);
472    
473                            query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
474    
475                            if (orderByComparator != null) {
476                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
477                                            orderByComparator);
478                            }
479    
480                            else {
481                                    query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
482                            }
483    
484                            String sql = query.toString();
485    
486                            Session session = null;
487    
488                            try {
489                                    session = openSession();
490    
491                                    Query q = session.createQuery(sql);
492    
493                                    QueryPos qPos = QueryPos.getInstance(q);
494    
495                                    qPos.add(active);
496    
497                                    list = (List<SCLicense>)QueryUtil.list(q, getDialect(), start,
498                                                    end);
499                            }
500                            catch (Exception e) {
501                                    throw processException(e);
502                            }
503                            finally {
504                                    if (list == null) {
505                                            FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_ACTIVE,
506                                                    finderArgs);
507                                    }
508                                    else {
509                                            cacheResult(list);
510    
511                                            FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_ACTIVE,
512                                                    finderArgs, list);
513                                    }
514    
515                                    closeSession(session);
516                            }
517                    }
518    
519                    return list;
520            }
521    
522            /**
523             * Finds the first s c license in the ordered set where active = &#63;.
524             *
525             * <p>
526             * 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.
527             * </p>
528             *
529             * @param active the active to search with
530             * @param orderByComparator the comparator to order the set by
531             * @return the first matching s c license
532             * @throws com.liferay.portlet.softwarecatalog.NoSuchLicenseException if a matching s c license could not be found
533             * @throws SystemException if a system exception occurred
534             */
535            public SCLicense findByActive_First(boolean active,
536                    OrderByComparator orderByComparator)
537                    throws NoSuchLicenseException, SystemException {
538                    List<SCLicense> list = findByActive(active, 0, 1, orderByComparator);
539    
540                    if (list.isEmpty()) {
541                            StringBundler msg = new StringBundler(4);
542    
543                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
544    
545                            msg.append("active=");
546                            msg.append(active);
547    
548                            msg.append(StringPool.CLOSE_CURLY_BRACE);
549    
550                            throw new NoSuchLicenseException(msg.toString());
551                    }
552                    else {
553                            return list.get(0);
554                    }
555            }
556    
557            /**
558             * Finds the last s c license in the ordered set where active = &#63;.
559             *
560             * <p>
561             * 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.
562             * </p>
563             *
564             * @param active the active to search with
565             * @param orderByComparator the comparator to order the set by
566             * @return the last matching s c license
567             * @throws com.liferay.portlet.softwarecatalog.NoSuchLicenseException if a matching s c license could not be found
568             * @throws SystemException if a system exception occurred
569             */
570            public SCLicense findByActive_Last(boolean active,
571                    OrderByComparator orderByComparator)
572                    throws NoSuchLicenseException, SystemException {
573                    int count = countByActive(active);
574    
575                    List<SCLicense> list = findByActive(active, count - 1, count,
576                                    orderByComparator);
577    
578                    if (list.isEmpty()) {
579                            StringBundler msg = new StringBundler(4);
580    
581                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
582    
583                            msg.append("active=");
584                            msg.append(active);
585    
586                            msg.append(StringPool.CLOSE_CURLY_BRACE);
587    
588                            throw new NoSuchLicenseException(msg.toString());
589                    }
590                    else {
591                            return list.get(0);
592                    }
593            }
594    
595            /**
596             * Finds the s c licenses before and after the current s c license in the ordered set where active = &#63;.
597             *
598             * <p>
599             * 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.
600             * </p>
601             *
602             * @param licenseId the primary key of the current s c license
603             * @param active the active to search with
604             * @param orderByComparator the comparator to order the set by
605             * @return the previous, current, and next s c license
606             * @throws com.liferay.portlet.softwarecatalog.NoSuchLicenseException if a s c license with the primary key could not be found
607             * @throws SystemException if a system exception occurred
608             */
609            public SCLicense[] findByActive_PrevAndNext(long licenseId, boolean active,
610                    OrderByComparator orderByComparator)
611                    throws NoSuchLicenseException, SystemException {
612                    SCLicense scLicense = findByPrimaryKey(licenseId);
613    
614                    Session session = null;
615    
616                    try {
617                            session = openSession();
618    
619                            SCLicense[] array = new SCLicenseImpl[3];
620    
621                            array[0] = getByActive_PrevAndNext(session, scLicense, active,
622                                            orderByComparator, true);
623    
624                            array[1] = scLicense;
625    
626                            array[2] = getByActive_PrevAndNext(session, scLicense, active,
627                                            orderByComparator, false);
628    
629                            return array;
630                    }
631                    catch (Exception e) {
632                            throw processException(e);
633                    }
634                    finally {
635                            closeSession(session);
636                    }
637            }
638    
639            protected SCLicense getByActive_PrevAndNext(Session session,
640                    SCLicense scLicense, boolean active,
641                    OrderByComparator orderByComparator, boolean previous) {
642                    StringBundler query = null;
643    
644                    if (orderByComparator != null) {
645                            query = new StringBundler(6 +
646                                            (orderByComparator.getOrderByFields().length * 6));
647                    }
648                    else {
649                            query = new StringBundler(3);
650                    }
651    
652                    query.append(_SQL_SELECT_SCLICENSE_WHERE);
653    
654                    query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
655    
656                    if (orderByComparator != null) {
657                            String[] orderByFields = orderByComparator.getOrderByFields();
658    
659                            if (orderByFields.length > 0) {
660                                    query.append(WHERE_AND);
661                            }
662    
663                            for (int i = 0; i < orderByFields.length; i++) {
664                                    query.append(_ORDER_BY_ENTITY_ALIAS);
665                                    query.append(orderByFields[i]);
666    
667                                    if ((i + 1) < orderByFields.length) {
668                                            if (orderByComparator.isAscending() ^ previous) {
669                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
670                                            }
671                                            else {
672                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
673                                            }
674                                    }
675                                    else {
676                                            if (orderByComparator.isAscending() ^ previous) {
677                                                    query.append(WHERE_GREATER_THAN);
678                                            }
679                                            else {
680                                                    query.append(WHERE_LESSER_THAN);
681                                            }
682                                    }
683                            }
684    
685                            query.append(ORDER_BY_CLAUSE);
686    
687                            for (int i = 0; i < orderByFields.length; i++) {
688                                    query.append(_ORDER_BY_ENTITY_ALIAS);
689                                    query.append(orderByFields[i]);
690    
691                                    if ((i + 1) < orderByFields.length) {
692                                            if (orderByComparator.isAscending() ^ previous) {
693                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
694                                            }
695                                            else {
696                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
697                                            }
698                                    }
699                                    else {
700                                            if (orderByComparator.isAscending() ^ previous) {
701                                                    query.append(ORDER_BY_ASC);
702                                            }
703                                            else {
704                                                    query.append(ORDER_BY_DESC);
705                                            }
706                                    }
707                            }
708                    }
709    
710                    else {
711                            query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
712                    }
713    
714                    String sql = query.toString();
715    
716                    Query q = session.createQuery(sql);
717    
718                    q.setFirstResult(0);
719                    q.setMaxResults(2);
720    
721                    QueryPos qPos = QueryPos.getInstance(q);
722    
723                    qPos.add(active);
724    
725                    if (orderByComparator != null) {
726                            Object[] values = orderByComparator.getOrderByValues(scLicense);
727    
728                            for (Object value : values) {
729                                    qPos.add(value);
730                            }
731                    }
732    
733                    List<SCLicense> list = q.list();
734    
735                    if (list.size() == 2) {
736                            return list.get(1);
737                    }
738                    else {
739                            return null;
740                    }
741            }
742    
743            /**
744             * Filters by the user's permissions and finds all the s c licenses where active = &#63;.
745             *
746             * @param active the active to search with
747             * @return the matching s c licenses that the user has permission to view
748             * @throws SystemException if a system exception occurred
749             */
750            public List<SCLicense> filterFindByActive(boolean active)
751                    throws SystemException {
752                    return filterFindByActive(active, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
753                            null);
754            }
755    
756            /**
757             * Filters by the user's permissions and finds a range of all the s c licenses where active = &#63;.
758             *
759             * <p>
760             * 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.
761             * </p>
762             *
763             * @param active the active to search with
764             * @param start the lower bound of the range of s c licenses to return
765             * @param end the upper bound of the range of s c licenses to return (not inclusive)
766             * @return the range of matching s c licenses that the user has permission to view
767             * @throws SystemException if a system exception occurred
768             */
769            public List<SCLicense> filterFindByActive(boolean active, int start, int end)
770                    throws SystemException {
771                    return filterFindByActive(active, start, end, null);
772            }
773    
774            /**
775             * Filters by the user's permissions and finds an ordered range of all the s c licenses where active = &#63;.
776             *
777             * <p>
778             * 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.
779             * </p>
780             *
781             * @param active the active to search with
782             * @param start the lower bound of the range of s c licenses to return
783             * @param end the upper bound of the range of s c licenses to return (not inclusive)
784             * @param orderByComparator the comparator to order the results by
785             * @return the ordered range of matching s c licenses that the user has permission to view
786             * @throws SystemException if a system exception occurred
787             */
788            public List<SCLicense> filterFindByActive(boolean active, int start,
789                    int end, OrderByComparator orderByComparator) throws SystemException {
790                    if (!InlineSQLHelperUtil.isEnabled()) {
791                            return findByActive(active, start, end, orderByComparator);
792                    }
793    
794                    StringBundler query = null;
795    
796                    if (orderByComparator != null) {
797                            query = new StringBundler(3 +
798                                            (orderByComparator.getOrderByFields().length * 3));
799                    }
800                    else {
801                            query = new StringBundler(3);
802                    }
803    
804                    if (getDB().isSupportsInlineDistinct()) {
805                            query.append(_FILTER_SQL_SELECT_SCLICENSE_WHERE);
806                    }
807                    else {
808                            query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1);
809                    }
810    
811                    query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
812    
813                    if (!getDB().isSupportsInlineDistinct()) {
814                            query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2);
815                    }
816    
817                    if (orderByComparator != null) {
818                            if (getDB().isSupportsInlineDistinct()) {
819                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
820                                            orderByComparator);
821                            }
822                            else {
823                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
824                                            orderByComparator);
825                            }
826                    }
827    
828                    else {
829                            if (getDB().isSupportsInlineDistinct()) {
830                                    query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
831                            }
832                            else {
833                                    query.append(SCLicenseModelImpl.ORDER_BY_SQL);
834                            }
835                    }
836    
837                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
838                                    SCLicense.class.getName(), _FILTER_COLUMN_PK,
839                                    _FILTER_COLUMN_USERID);
840    
841                    Session session = null;
842    
843                    try {
844                            session = openSession();
845    
846                            SQLQuery q = session.createSQLQuery(sql);
847    
848                            if (getDB().isSupportsInlineDistinct()) {
849                                    q.addEntity(_FILTER_ENTITY_ALIAS, SCLicenseImpl.class);
850                            }
851                            else {
852                                    q.addEntity(_FILTER_ENTITY_TABLE, SCLicenseImpl.class);
853                            }
854    
855                            QueryPos qPos = QueryPos.getInstance(q);
856    
857                            qPos.add(active);
858    
859                            return (List<SCLicense>)QueryUtil.list(q, getDialect(), start, end);
860                    }
861                    catch (Exception e) {
862                            throw processException(e);
863                    }
864                    finally {
865                            closeSession(session);
866                    }
867            }
868    
869            /**
870             * Finds all the s c licenses where active = &#63; and recommended = &#63;.
871             *
872             * @param active the active to search with
873             * @param recommended the recommended to search with
874             * @return the matching s c licenses
875             * @throws SystemException if a system exception occurred
876             */
877            public List<SCLicense> findByA_R(boolean active, boolean recommended)
878                    throws SystemException {
879                    return findByA_R(active, recommended, QueryUtil.ALL_POS,
880                            QueryUtil.ALL_POS, null);
881            }
882    
883            /**
884             * Finds a range of all the s c licenses where active = &#63; and recommended = &#63;.
885             *
886             * <p>
887             * 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.
888             * </p>
889             *
890             * @param active the active to search with
891             * @param recommended the recommended to search with
892             * @param start the lower bound of the range of s c licenses to return
893             * @param end the upper bound of the range of s c licenses to return (not inclusive)
894             * @return the range of matching s c licenses
895             * @throws SystemException if a system exception occurred
896             */
897            public List<SCLicense> findByA_R(boolean active, boolean recommended,
898                    int start, int end) throws SystemException {
899                    return findByA_R(active, recommended, start, end, null);
900            }
901    
902            /**
903             * Finds an ordered range of all the s c licenses where active = &#63; and recommended = &#63;.
904             *
905             * <p>
906             * 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.
907             * </p>
908             *
909             * @param active the active to search with
910             * @param recommended the recommended to search with
911             * @param start the lower bound of the range of s c licenses to return
912             * @param end the upper bound of the range of s c licenses to return (not inclusive)
913             * @param orderByComparator the comparator to order the results by
914             * @return the ordered range of matching s c licenses
915             * @throws SystemException if a system exception occurred
916             */
917            public List<SCLicense> findByA_R(boolean active, boolean recommended,
918                    int start, int end, OrderByComparator orderByComparator)
919                    throws SystemException {
920                    Object[] finderArgs = new Object[] {
921                                    active, recommended,
922                                    
923                                    String.valueOf(start), String.valueOf(end),
924                                    String.valueOf(orderByComparator)
925                            };
926    
927                    List<SCLicense> list = (List<SCLicense>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_A_R,
928                                    finderArgs, this);
929    
930                    if (list == null) {
931                            StringBundler query = null;
932    
933                            if (orderByComparator != null) {
934                                    query = new StringBundler(4 +
935                                                    (orderByComparator.getOrderByFields().length * 3));
936                            }
937                            else {
938                                    query = new StringBundler(4);
939                            }
940    
941                            query.append(_SQL_SELECT_SCLICENSE_WHERE);
942    
943                            query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
944    
945                            query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
946    
947                            if (orderByComparator != null) {
948                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
949                                            orderByComparator);
950                            }
951    
952                            else {
953                                    query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
954                            }
955    
956                            String sql = query.toString();
957    
958                            Session session = null;
959    
960                            try {
961                                    session = openSession();
962    
963                                    Query q = session.createQuery(sql);
964    
965                                    QueryPos qPos = QueryPos.getInstance(q);
966    
967                                    qPos.add(active);
968    
969                                    qPos.add(recommended);
970    
971                                    list = (List<SCLicense>)QueryUtil.list(q, getDialect(), start,
972                                                    end);
973                            }
974                            catch (Exception e) {
975                                    throw processException(e);
976                            }
977                            finally {
978                                    if (list == null) {
979                                            FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_A_R,
980                                                    finderArgs);
981                                    }
982                                    else {
983                                            cacheResult(list);
984    
985                                            FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_A_R,
986                                                    finderArgs, list);
987                                    }
988    
989                                    closeSession(session);
990                            }
991                    }
992    
993                    return list;
994            }
995    
996            /**
997             * Finds the first s c license in the ordered set where active = &#63; and recommended = &#63;.
998             *
999             * <p>
1000             * 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.
1001             * </p>
1002             *
1003             * @param active the active to search with
1004             * @param recommended the recommended to search with
1005             * @param orderByComparator the comparator to order the set by
1006             * @return the first matching s c license
1007             * @throws com.liferay.portlet.softwarecatalog.NoSuchLicenseException if a matching s c license could not be found
1008             * @throws SystemException if a system exception occurred
1009             */
1010            public SCLicense findByA_R_First(boolean active, boolean recommended,
1011                    OrderByComparator orderByComparator)
1012                    throws NoSuchLicenseException, SystemException {
1013                    List<SCLicense> list = findByA_R(active, recommended, 0, 1,
1014                                    orderByComparator);
1015    
1016                    if (list.isEmpty()) {
1017                            StringBundler msg = new StringBundler(6);
1018    
1019                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1020    
1021                            msg.append("active=");
1022                            msg.append(active);
1023    
1024                            msg.append(", recommended=");
1025                            msg.append(recommended);
1026    
1027                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1028    
1029                            throw new NoSuchLicenseException(msg.toString());
1030                    }
1031                    else {
1032                            return list.get(0);
1033                    }
1034            }
1035    
1036            /**
1037             * Finds the last s c license in the ordered set where active = &#63; and recommended = &#63;.
1038             *
1039             * <p>
1040             * 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.
1041             * </p>
1042             *
1043             * @param active the active to search with
1044             * @param recommended the recommended to search with
1045             * @param orderByComparator the comparator to order the set by
1046             * @return the last matching s c license
1047             * @throws com.liferay.portlet.softwarecatalog.NoSuchLicenseException if a matching s c license could not be found
1048             * @throws SystemException if a system exception occurred
1049             */
1050            public SCLicense findByA_R_Last(boolean active, boolean recommended,
1051                    OrderByComparator orderByComparator)
1052                    throws NoSuchLicenseException, SystemException {
1053                    int count = countByA_R(active, recommended);
1054    
1055                    List<SCLicense> list = findByA_R(active, recommended, count - 1, count,
1056                                    orderByComparator);
1057    
1058                    if (list.isEmpty()) {
1059                            StringBundler msg = new StringBundler(6);
1060    
1061                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1062    
1063                            msg.append("active=");
1064                            msg.append(active);
1065    
1066                            msg.append(", recommended=");
1067                            msg.append(recommended);
1068    
1069                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1070    
1071                            throw new NoSuchLicenseException(msg.toString());
1072                    }
1073                    else {
1074                            return list.get(0);
1075                    }
1076            }
1077    
1078            /**
1079             * Finds the s c licenses before and after the current s c license in the ordered set where active = &#63; and recommended = &#63;.
1080             *
1081             * <p>
1082             * 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.
1083             * </p>
1084             *
1085             * @param licenseId the primary key of the current s c license
1086             * @param active the active to search with
1087             * @param recommended the recommended to search with
1088             * @param orderByComparator the comparator to order the set by
1089             * @return the previous, current, and next s c license
1090             * @throws com.liferay.portlet.softwarecatalog.NoSuchLicenseException if a s c license with the primary key could not be found
1091             * @throws SystemException if a system exception occurred
1092             */
1093            public SCLicense[] findByA_R_PrevAndNext(long licenseId, boolean active,
1094                    boolean recommended, OrderByComparator orderByComparator)
1095                    throws NoSuchLicenseException, SystemException {
1096                    SCLicense scLicense = findByPrimaryKey(licenseId);
1097    
1098                    Session session = null;
1099    
1100                    try {
1101                            session = openSession();
1102    
1103                            SCLicense[] array = new SCLicenseImpl[3];
1104    
1105                            array[0] = getByA_R_PrevAndNext(session, scLicense, active,
1106                                            recommended, orderByComparator, true);
1107    
1108                            array[1] = scLicense;
1109    
1110                            array[2] = getByA_R_PrevAndNext(session, scLicense, active,
1111                                            recommended, orderByComparator, false);
1112    
1113                            return array;
1114                    }
1115                    catch (Exception e) {
1116                            throw processException(e);
1117                    }
1118                    finally {
1119                            closeSession(session);
1120                    }
1121            }
1122    
1123            protected SCLicense getByA_R_PrevAndNext(Session session,
1124                    SCLicense scLicense, boolean active, boolean recommended,
1125                    OrderByComparator orderByComparator, boolean previous) {
1126                    StringBundler query = null;
1127    
1128                    if (orderByComparator != null) {
1129                            query = new StringBundler(6 +
1130                                            (orderByComparator.getOrderByFields().length * 6));
1131                    }
1132                    else {
1133                            query = new StringBundler(3);
1134                    }
1135    
1136                    query.append(_SQL_SELECT_SCLICENSE_WHERE);
1137    
1138                    query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1139    
1140                    query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1141    
1142                    if (orderByComparator != null) {
1143                            String[] orderByFields = orderByComparator.getOrderByFields();
1144    
1145                            if (orderByFields.length > 0) {
1146                                    query.append(WHERE_AND);
1147                            }
1148    
1149                            for (int i = 0; i < orderByFields.length; i++) {
1150                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1151                                    query.append(orderByFields[i]);
1152    
1153                                    if ((i + 1) < orderByFields.length) {
1154                                            if (orderByComparator.isAscending() ^ previous) {
1155                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1156                                            }
1157                                            else {
1158                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1159                                            }
1160                                    }
1161                                    else {
1162                                            if (orderByComparator.isAscending() ^ previous) {
1163                                                    query.append(WHERE_GREATER_THAN);
1164                                            }
1165                                            else {
1166                                                    query.append(WHERE_LESSER_THAN);
1167                                            }
1168                                    }
1169                            }
1170    
1171                            query.append(ORDER_BY_CLAUSE);
1172    
1173                            for (int i = 0; i < orderByFields.length; i++) {
1174                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1175                                    query.append(orderByFields[i]);
1176    
1177                                    if ((i + 1) < orderByFields.length) {
1178                                            if (orderByComparator.isAscending() ^ previous) {
1179                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1180                                            }
1181                                            else {
1182                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1183                                            }
1184                                    }
1185                                    else {
1186                                            if (orderByComparator.isAscending() ^ previous) {
1187                                                    query.append(ORDER_BY_ASC);
1188                                            }
1189                                            else {
1190                                                    query.append(ORDER_BY_DESC);
1191                                            }
1192                                    }
1193                            }
1194                    }
1195    
1196                    else {
1197                            query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1198                    }
1199    
1200                    String sql = query.toString();
1201    
1202                    Query q = session.createQuery(sql);
1203    
1204                    q.setFirstResult(0);
1205                    q.setMaxResults(2);
1206    
1207                    QueryPos qPos = QueryPos.getInstance(q);
1208    
1209                    qPos.add(active);
1210    
1211                    qPos.add(recommended);
1212    
1213                    if (orderByComparator != null) {
1214                            Object[] values = orderByComparator.getOrderByValues(scLicense);
1215    
1216                            for (Object value : values) {
1217                                    qPos.add(value);
1218                            }
1219                    }
1220    
1221                    List<SCLicense> list = q.list();
1222    
1223                    if (list.size() == 2) {
1224                            return list.get(1);
1225                    }
1226                    else {
1227                            return null;
1228                    }
1229            }
1230    
1231            /**
1232             * Filters by the user's permissions and finds all the s c licenses where active = &#63; and recommended = &#63;.
1233             *
1234             * @param active the active to search with
1235             * @param recommended the recommended to search with
1236             * @return the matching s c licenses that the user has permission to view
1237             * @throws SystemException if a system exception occurred
1238             */
1239            public List<SCLicense> filterFindByA_R(boolean active, boolean recommended)
1240                    throws SystemException {
1241                    return filterFindByA_R(active, recommended, QueryUtil.ALL_POS,
1242                            QueryUtil.ALL_POS, null);
1243            }
1244    
1245            /**
1246             * Filters by the user's permissions and finds a range of all the s c licenses where active = &#63; and recommended = &#63;.
1247             *
1248             * <p>
1249             * 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.
1250             * </p>
1251             *
1252             * @param active the active to search with
1253             * @param recommended the recommended to search with
1254             * @param start the lower bound of the range of s c licenses to return
1255             * @param end the upper bound of the range of s c licenses to return (not inclusive)
1256             * @return the range of matching s c licenses that the user has permission to view
1257             * @throws SystemException if a system exception occurred
1258             */
1259            public List<SCLicense> filterFindByA_R(boolean active, boolean recommended,
1260                    int start, int end) throws SystemException {
1261                    return filterFindByA_R(active, recommended, start, end, null);
1262            }
1263    
1264            /**
1265             * Filters by the user's permissions and finds an ordered range of all the s c licenses where active = &#63; and recommended = &#63;.
1266             *
1267             * <p>
1268             * 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.
1269             * </p>
1270             *
1271             * @param active the active to search with
1272             * @param recommended the recommended to search with
1273             * @param start the lower bound of the range of s c licenses to return
1274             * @param end the upper bound of the range of s c licenses to return (not inclusive)
1275             * @param orderByComparator the comparator to order the results by
1276             * @return the ordered range of matching s c licenses that the user has permission to view
1277             * @throws SystemException if a system exception occurred
1278             */
1279            public List<SCLicense> filterFindByA_R(boolean active, boolean recommended,
1280                    int start, int end, OrderByComparator orderByComparator)
1281                    throws SystemException {
1282                    if (!InlineSQLHelperUtil.isEnabled()) {
1283                            return findByA_R(active, recommended, start, end, orderByComparator);
1284                    }
1285    
1286                    StringBundler query = null;
1287    
1288                    if (orderByComparator != null) {
1289                            query = new StringBundler(4 +
1290                                            (orderByComparator.getOrderByFields().length * 3));
1291                    }
1292                    else {
1293                            query = new StringBundler(4);
1294                    }
1295    
1296                    if (getDB().isSupportsInlineDistinct()) {
1297                            query.append(_FILTER_SQL_SELECT_SCLICENSE_WHERE);
1298                    }
1299                    else {
1300                            query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1);
1301                    }
1302    
1303                    query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1304    
1305                    query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1306    
1307                    if (!getDB().isSupportsInlineDistinct()) {
1308                            query.append(_FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2);
1309                    }
1310    
1311                    if (orderByComparator != null) {
1312                            if (getDB().isSupportsInlineDistinct()) {
1313                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1314                                            orderByComparator);
1315                            }
1316                            else {
1317                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1318                                            orderByComparator);
1319                            }
1320                    }
1321    
1322                    else {
1323                            if (getDB().isSupportsInlineDistinct()) {
1324                                    query.append(SCLicenseModelImpl.ORDER_BY_JPQL);
1325                            }
1326                            else {
1327                                    query.append(SCLicenseModelImpl.ORDER_BY_SQL);
1328                            }
1329                    }
1330    
1331                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1332                                    SCLicense.class.getName(), _FILTER_COLUMN_PK,
1333                                    _FILTER_COLUMN_USERID);
1334    
1335                    Session session = null;
1336    
1337                    try {
1338                            session = openSession();
1339    
1340                            SQLQuery q = session.createSQLQuery(sql);
1341    
1342                            if (getDB().isSupportsInlineDistinct()) {
1343                                    q.addEntity(_FILTER_ENTITY_ALIAS, SCLicenseImpl.class);
1344                            }
1345                            else {
1346                                    q.addEntity(_FILTER_ENTITY_TABLE, SCLicenseImpl.class);
1347                            }
1348    
1349                            QueryPos qPos = QueryPos.getInstance(q);
1350    
1351                            qPos.add(active);
1352    
1353                            qPos.add(recommended);
1354    
1355                            return (List<SCLicense>)QueryUtil.list(q, getDialect(), start, end);
1356                    }
1357                    catch (Exception e) {
1358                            throw processException(e);
1359                    }
1360                    finally {
1361                            closeSession(session);
1362                    }
1363            }
1364    
1365            /**
1366             * Finds all the s c licenses.
1367             *
1368             * @return the s c licenses
1369             * @throws SystemException if a system exception occurred
1370             */
1371            public List<SCLicense> findAll() throws SystemException {
1372                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1373            }
1374    
1375            /**
1376             * Finds a range of all the s c licenses.
1377             *
1378             * <p>
1379             * 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.
1380             * </p>
1381             *
1382             * @param start the lower bound of the range of s c licenses to return
1383             * @param end the upper bound of the range of s c licenses to return (not inclusive)
1384             * @return the range of s c licenses
1385             * @throws SystemException if a system exception occurred
1386             */
1387            public List<SCLicense> findAll(int start, int end)
1388                    throws SystemException {
1389                    return findAll(start, end, null);
1390            }
1391    
1392            /**
1393             * Finds an ordered range of all the s c licenses.
1394             *
1395             * <p>
1396             * 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.
1397             * </p>
1398             *
1399             * @param start the lower bound of the range of s c licenses to return
1400             * @param end the upper bound of the range of s c licenses to return (not inclusive)
1401             * @param orderByComparator the comparator to order the results by
1402             * @return the ordered range of s c licenses
1403             * @throws SystemException if a system exception occurred
1404             */
1405            public List<SCLicense> findAll(int start, int end,
1406                    OrderByComparator orderByComparator) throws SystemException {
1407                    Object[] finderArgs = new Object[] {
1408                                    String.valueOf(start), String.valueOf(end),
1409                                    String.valueOf(orderByComparator)
1410                            };
1411    
1412                    List<SCLicense> list = (List<SCLicense>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1413                                    finderArgs, this);
1414    
1415                    if (list == null) {
1416                            StringBundler query = null;
1417                            String sql = null;
1418    
1419                            if (orderByComparator != null) {
1420                                    query = new StringBundler(2 +
1421                                                    (orderByComparator.getOrderByFields().length * 3));
1422    
1423                                    query.append(_SQL_SELECT_SCLICENSE);
1424    
1425                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1426                                            orderByComparator);
1427    
1428                                    sql = query.toString();
1429                            }
1430                            else {
1431                                    sql = _SQL_SELECT_SCLICENSE.concat(SCLicenseModelImpl.ORDER_BY_JPQL);
1432                            }
1433    
1434                            Session session = null;
1435    
1436                            try {
1437                                    session = openSession();
1438    
1439                                    Query q = session.createQuery(sql);
1440    
1441                                    if (orderByComparator == null) {
1442                                            list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
1443                                                            start, end, false);
1444    
1445                                            Collections.sort(list);
1446                                    }
1447                                    else {
1448                                            list = (List<SCLicense>)QueryUtil.list(q, getDialect(),
1449                                                            start, end);
1450                                    }
1451                            }
1452                            catch (Exception e) {
1453                                    throw processException(e);
1454                            }
1455                            finally {
1456                                    if (list == null) {
1457                                            FinderCacheUtil.removeResult(FINDER_PATH_FIND_ALL,
1458                                                    finderArgs);
1459                                    }
1460                                    else {
1461                                            cacheResult(list);
1462    
1463                                            FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs,
1464                                                    list);
1465                                    }
1466    
1467                                    closeSession(session);
1468                            }
1469                    }
1470    
1471                    return list;
1472            }
1473    
1474            /**
1475             * Removes all the s c licenses where active = &#63; from the database.
1476             *
1477             * @param active the active to search with
1478             * @throws SystemException if a system exception occurred
1479             */
1480            public void removeByActive(boolean active) throws SystemException {
1481                    for (SCLicense scLicense : findByActive(active)) {
1482                            remove(scLicense);
1483                    }
1484            }
1485    
1486            /**
1487             * Removes all the s c licenses where active = &#63; and recommended = &#63; from the database.
1488             *
1489             * @param active the active to search with
1490             * @param recommended the recommended to search with
1491             * @throws SystemException if a system exception occurred
1492             */
1493            public void removeByA_R(boolean active, boolean recommended)
1494                    throws SystemException {
1495                    for (SCLicense scLicense : findByA_R(active, recommended)) {
1496                            remove(scLicense);
1497                    }
1498            }
1499    
1500            /**
1501             * Removes all the s c licenses from the database.
1502             *
1503             * @throws SystemException if a system exception occurred
1504             */
1505            public void removeAll() throws SystemException {
1506                    for (SCLicense scLicense : findAll()) {
1507                            remove(scLicense);
1508                    }
1509            }
1510    
1511            /**
1512             * Counts all the s c licenses where active = &#63;.
1513             *
1514             * @param active the active to search with
1515             * @return the number of matching s c licenses
1516             * @throws SystemException if a system exception occurred
1517             */
1518            public int countByActive(boolean active) throws SystemException {
1519                    Object[] finderArgs = new Object[] { active };
1520    
1521                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ACTIVE,
1522                                    finderArgs, this);
1523    
1524                    if (count == null) {
1525                            StringBundler query = new StringBundler(2);
1526    
1527                            query.append(_SQL_COUNT_SCLICENSE_WHERE);
1528    
1529                            query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
1530    
1531                            String sql = query.toString();
1532    
1533                            Session session = null;
1534    
1535                            try {
1536                                    session = openSession();
1537    
1538                                    Query q = session.createQuery(sql);
1539    
1540                                    QueryPos qPos = QueryPos.getInstance(q);
1541    
1542                                    qPos.add(active);
1543    
1544                                    count = (Long)q.uniqueResult();
1545                            }
1546                            catch (Exception e) {
1547                                    throw processException(e);
1548                            }
1549                            finally {
1550                                    if (count == null) {
1551                                            count = Long.valueOf(0);
1552                                    }
1553    
1554                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ACTIVE,
1555                                            finderArgs, count);
1556    
1557                                    closeSession(session);
1558                            }
1559                    }
1560    
1561                    return count.intValue();
1562            }
1563    
1564            /**
1565             * Filters by the user's permissions and counts all the s c licenses where active = &#63;.
1566             *
1567             * @param active the active to search with
1568             * @return the number of matching s c licenses that the user has permission to view
1569             * @throws SystemException if a system exception occurred
1570             */
1571            public int filterCountByActive(boolean active) throws SystemException {
1572                    if (!InlineSQLHelperUtil.isEnabled()) {
1573                            return countByActive(active);
1574                    }
1575    
1576                    StringBundler query = new StringBundler(2);
1577    
1578                    query.append(_FILTER_SQL_COUNT_SCLICENSE_WHERE);
1579    
1580                    query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
1581    
1582                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1583                                    SCLicense.class.getName(), _FILTER_COLUMN_PK,
1584                                    _FILTER_COLUMN_USERID);
1585    
1586                    Session session = null;
1587    
1588                    try {
1589                            session = openSession();
1590    
1591                            SQLQuery q = session.createSQLQuery(sql);
1592    
1593                            q.addScalar(COUNT_COLUMN_NAME,
1594                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
1595    
1596                            QueryPos qPos = QueryPos.getInstance(q);
1597    
1598                            qPos.add(active);
1599    
1600                            Long count = (Long)q.uniqueResult();
1601    
1602                            return count.intValue();
1603                    }
1604                    catch (Exception e) {
1605                            throw processException(e);
1606                    }
1607                    finally {
1608                            closeSession(session);
1609                    }
1610            }
1611    
1612            /**
1613             * Counts all the s c licenses where active = &#63; and recommended = &#63;.
1614             *
1615             * @param active the active to search with
1616             * @param recommended the recommended to search with
1617             * @return the number of matching s c licenses
1618             * @throws SystemException if a system exception occurred
1619             */
1620            public int countByA_R(boolean active, boolean recommended)
1621                    throws SystemException {
1622                    Object[] finderArgs = new Object[] { active, recommended };
1623    
1624                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_A_R,
1625                                    finderArgs, this);
1626    
1627                    if (count == null) {
1628                            StringBundler query = new StringBundler(3);
1629    
1630                            query.append(_SQL_COUNT_SCLICENSE_WHERE);
1631    
1632                            query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1633    
1634                            query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1635    
1636                            String sql = query.toString();
1637    
1638                            Session session = null;
1639    
1640                            try {
1641                                    session = openSession();
1642    
1643                                    Query q = session.createQuery(sql);
1644    
1645                                    QueryPos qPos = QueryPos.getInstance(q);
1646    
1647                                    qPos.add(active);
1648    
1649                                    qPos.add(recommended);
1650    
1651                                    count = (Long)q.uniqueResult();
1652                            }
1653                            catch (Exception e) {
1654                                    throw processException(e);
1655                            }
1656                            finally {
1657                                    if (count == null) {
1658                                            count = Long.valueOf(0);
1659                                    }
1660    
1661                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_A_R, finderArgs,
1662                                            count);
1663    
1664                                    closeSession(session);
1665                            }
1666                    }
1667    
1668                    return count.intValue();
1669            }
1670    
1671            /**
1672             * Filters by the user's permissions and counts all the s c licenses where active = &#63; and recommended = &#63;.
1673             *
1674             * @param active the active to search with
1675             * @param recommended the recommended to search with
1676             * @return the number of matching s c licenses that the user has permission to view
1677             * @throws SystemException if a system exception occurred
1678             */
1679            public int filterCountByA_R(boolean active, boolean recommended)
1680                    throws SystemException {
1681                    if (!InlineSQLHelperUtil.isEnabled()) {
1682                            return countByA_R(active, recommended);
1683                    }
1684    
1685                    StringBundler query = new StringBundler(3);
1686    
1687                    query.append(_FILTER_SQL_COUNT_SCLICENSE_WHERE);
1688    
1689                    query.append(_FINDER_COLUMN_A_R_ACTIVE_2);
1690    
1691                    query.append(_FINDER_COLUMN_A_R_RECOMMENDED_2);
1692    
1693                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1694                                    SCLicense.class.getName(), _FILTER_COLUMN_PK,
1695                                    _FILTER_COLUMN_USERID);
1696    
1697                    Session session = null;
1698    
1699                    try {
1700                            session = openSession();
1701    
1702                            SQLQuery q = session.createSQLQuery(sql);
1703    
1704                            q.addScalar(COUNT_COLUMN_NAME,
1705                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
1706    
1707                            QueryPos qPos = QueryPos.getInstance(q);
1708    
1709                            qPos.add(active);
1710    
1711                            qPos.add(recommended);
1712    
1713                            Long count = (Long)q.uniqueResult();
1714    
1715                            return count.intValue();
1716                    }
1717                    catch (Exception e) {
1718                            throw processException(e);
1719                    }
1720                    finally {
1721                            closeSession(session);
1722                    }
1723            }
1724    
1725            /**
1726             * Counts all the s c licenses.
1727             *
1728             * @return the number of s c licenses
1729             * @throws SystemException if a system exception occurred
1730             */
1731            public int countAll() throws SystemException {
1732                    Object[] finderArgs = new Object[0];
1733    
1734                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1735                                    finderArgs, this);
1736    
1737                    if (count == null) {
1738                            Session session = null;
1739    
1740                            try {
1741                                    session = openSession();
1742    
1743                                    Query q = session.createQuery(_SQL_COUNT_SCLICENSE);
1744    
1745                                    count = (Long)q.uniqueResult();
1746                            }
1747                            catch (Exception e) {
1748                                    throw processException(e);
1749                            }
1750                            finally {
1751                                    if (count == null) {
1752                                            count = Long.valueOf(0);
1753                                    }
1754    
1755                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1756                                            count);
1757    
1758                                    closeSession(session);
1759                            }
1760                    }
1761    
1762                    return count.intValue();
1763            }
1764    
1765            /**
1766             * Gets all the s c product entries associated with the s c license.
1767             *
1768             * @param pk the primary key of the s c license to get the associated s c product entries for
1769             * @return the s c product entries associated with the s c license
1770             * @throws SystemException if a system exception occurred
1771             */
1772            public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
1773                    long pk) throws SystemException {
1774                    return getSCProductEntries(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1775            }
1776    
1777            /**
1778             * Gets a range of all the s c product entries associated with the s c license.
1779             *
1780             * <p>
1781             * 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.
1782             * </p>
1783             *
1784             * @param pk the primary key of the s c license to get the associated s c product entries for
1785             * @param start the lower bound of the range of s c licenses to return
1786             * @param end the upper bound of the range of s c licenses to return (not inclusive)
1787             * @return the range of s c product entries associated with the s c license
1788             * @throws SystemException if a system exception occurred
1789             */
1790            public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
1791                    long pk, int start, int end) throws SystemException {
1792                    return getSCProductEntries(pk, start, end, null);
1793            }
1794    
1795            public static final FinderPath FINDER_PATH_GET_SCPRODUCTENTRIES = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
1796                            SCLicenseModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
1797                            SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
1798                            "getSCProductEntries",
1799                            new String[] {
1800                                    Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1801                                    "com.liferay.portal.kernel.util.OrderByComparator"
1802                            });
1803    
1804            /**
1805             * Gets an ordered range of all the s c product entries associated with the s c license.
1806             *
1807             * <p>
1808             * 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.
1809             * </p>
1810             *
1811             * @param pk the primary key of the s c license to get the associated s c product entries for
1812             * @param start the lower bound of the range of s c licenses to return
1813             * @param end the upper bound of the range of s c licenses to return (not inclusive)
1814             * @param orderByComparator the comparator to order the results by
1815             * @return the ordered range of s c product entries associated with the s c license
1816             * @throws SystemException if a system exception occurred
1817             */
1818            public List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> getSCProductEntries(
1819                    long pk, int start, int end, OrderByComparator orderByComparator)
1820                    throws SystemException {
1821                    Object[] finderArgs = new Object[] {
1822                                    pk, String.valueOf(start), String.valueOf(end),
1823                                    String.valueOf(orderByComparator)
1824                            };
1825    
1826                    List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> list = (List<com.liferay.portlet.softwarecatalog.model.SCProductEntry>)FinderCacheUtil.getResult(FINDER_PATH_GET_SCPRODUCTENTRIES,
1827                                    finderArgs, this);
1828    
1829                    if (list == null) {
1830                            Session session = null;
1831    
1832                            try {
1833                                    session = openSession();
1834    
1835                                    String sql = null;
1836    
1837                                    if (orderByComparator != null) {
1838                                            sql = _SQL_GETSCPRODUCTENTRIES.concat(ORDER_BY_CLAUSE)
1839                                                                                                      .concat(orderByComparator.getOrderBy());
1840                                    }
1841                                    else {
1842                                            sql = _SQL_GETSCPRODUCTENTRIES.concat(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ORDER_BY_SQL);
1843                                    }
1844    
1845                                    SQLQuery q = session.createSQLQuery(sql);
1846    
1847                                    q.addEntity("SCProductEntry",
1848                                            com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryImpl.class);
1849    
1850                                    QueryPos qPos = QueryPos.getInstance(q);
1851    
1852                                    qPos.add(pk);
1853    
1854                                    list = (List<com.liferay.portlet.softwarecatalog.model.SCProductEntry>)QueryUtil.list(q,
1855                                                    getDialect(), start, end);
1856                            }
1857                            catch (Exception e) {
1858                                    throw processException(e);
1859                            }
1860                            finally {
1861                                    if (list == null) {
1862                                            FinderCacheUtil.removeResult(FINDER_PATH_GET_SCPRODUCTENTRIES,
1863                                                    finderArgs);
1864                                    }
1865                                    else {
1866                                            scProductEntryPersistence.cacheResult(list);
1867    
1868                                            FinderCacheUtil.putResult(FINDER_PATH_GET_SCPRODUCTENTRIES,
1869                                                    finderArgs, list);
1870                                    }
1871    
1872                                    closeSession(session);
1873                            }
1874                    }
1875    
1876                    return list;
1877            }
1878    
1879            public static final FinderPath FINDER_PATH_GET_SCPRODUCTENTRIES_SIZE = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
1880                            SCLicenseModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
1881                            SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
1882                            "getSCProductEntriesSize", new String[] { Long.class.getName() });
1883    
1884            /**
1885             * Gets the number of s c product entries associated with the s c license.
1886             *
1887             * @param pk the primary key of the s c license to get the number of associated s c product entries for
1888             * @return the number of s c product entries associated with the s c license
1889             * @throws SystemException if a system exception occurred
1890             */
1891            public int getSCProductEntriesSize(long pk) throws SystemException {
1892                    Object[] finderArgs = new Object[] { pk };
1893    
1894                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_SCPRODUCTENTRIES_SIZE,
1895                                    finderArgs, this);
1896    
1897                    if (count == null) {
1898                            Session session = null;
1899    
1900                            try {
1901                                    session = openSession();
1902    
1903                                    SQLQuery q = session.createSQLQuery(_SQL_GETSCPRODUCTENTRIESSIZE);
1904    
1905                                    q.addScalar(COUNT_COLUMN_NAME,
1906                                            com.liferay.portal.kernel.dao.orm.Type.LONG);
1907    
1908                                    QueryPos qPos = QueryPos.getInstance(q);
1909    
1910                                    qPos.add(pk);
1911    
1912                                    count = (Long)q.uniqueResult();
1913                            }
1914                            catch (Exception e) {
1915                                    throw processException(e);
1916                            }
1917                            finally {
1918                                    if (count == null) {
1919                                            count = Long.valueOf(0);
1920                                    }
1921    
1922                                    FinderCacheUtil.putResult(FINDER_PATH_GET_SCPRODUCTENTRIES_SIZE,
1923                                            finderArgs, count);
1924    
1925                                    closeSession(session);
1926                            }
1927                    }
1928    
1929                    return count.intValue();
1930            }
1931    
1932            public static final FinderPath FINDER_PATH_CONTAINS_SCPRODUCTENTRY = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
1933                            SCLicenseModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
1934                            SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
1935                            "containsSCProductEntry",
1936                            new String[] { Long.class.getName(), Long.class.getName() });
1937    
1938            /**
1939             * Determines if the s c product entry is associated with the s c license.
1940             *
1941             * @param pk the primary key of the s c license
1942             * @param scProductEntryPK the primary key of the s c product entry
1943             * @return <code>true</code> if the s c product entry is associated with the s c license; <code>false</code> otherwise
1944             * @throws SystemException if a system exception occurred
1945             */
1946            public boolean containsSCProductEntry(long pk, long scProductEntryPK)
1947                    throws SystemException {
1948                    Object[] finderArgs = new Object[] { pk, scProductEntryPK };
1949    
1950                    Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_SCPRODUCTENTRY,
1951                                    finderArgs, this);
1952    
1953                    if (value == null) {
1954                            try {
1955                                    value = Boolean.valueOf(containsSCProductEntry.contains(pk,
1956                                                            scProductEntryPK));
1957                            }
1958                            catch (Exception e) {
1959                                    throw processException(e);
1960                            }
1961                            finally {
1962                                    if (value == null) {
1963                                            value = Boolean.FALSE;
1964                                    }
1965    
1966                                    FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_SCPRODUCTENTRY,
1967                                            finderArgs, value);
1968                            }
1969                    }
1970    
1971                    return value.booleanValue();
1972            }
1973    
1974            /**
1975             * Determines if the s c license has any s c product entries associated with it.
1976             *
1977             * @param pk the primary key of the s c license to check for associations with s c product entries
1978             * @return <code>true</code> if the s c license has any s c product entries associated with it; <code>false</code> otherwise
1979             * @throws SystemException if a system exception occurred
1980             */
1981            public boolean containsSCProductEntries(long pk) throws SystemException {
1982                    if (getSCProductEntriesSize(pk) > 0) {
1983                            return true;
1984                    }
1985                    else {
1986                            return false;
1987                    }
1988            }
1989    
1990            /**
1991             * 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.
1992             *
1993             * @param pk the primary key of the s c license
1994             * @param scProductEntryPK the primary key of the s c product entry
1995             * @throws SystemException if a system exception occurred
1996             */
1997            public void addSCProductEntry(long pk, long scProductEntryPK)
1998                    throws SystemException {
1999                    try {
2000                            addSCProductEntry.add(pk, scProductEntryPK);
2001                    }
2002                    catch (Exception e) {
2003                            throw processException(e);
2004                    }
2005                    finally {
2006                            FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2007                    }
2008            }
2009    
2010            /**
2011             * 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.
2012             *
2013             * @param pk the primary key of the s c license
2014             * @param scProductEntry the s c product entry
2015             * @throws SystemException if a system exception occurred
2016             */
2017            public void addSCProductEntry(long pk,
2018                    com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry)
2019                    throws SystemException {
2020                    try {
2021                            addSCProductEntry.add(pk, scProductEntry.getPrimaryKey());
2022                    }
2023                    catch (Exception e) {
2024                            throw processException(e);
2025                    }
2026                    finally {
2027                            FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2028                    }
2029            }
2030    
2031            /**
2032             * 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.
2033             *
2034             * @param pk the primary key of the s c license
2035             * @param scProductEntryPKs the primary keys of the s c product entries
2036             * @throws SystemException if a system exception occurred
2037             */
2038            public void addSCProductEntries(long pk, long[] scProductEntryPKs)
2039                    throws SystemException {
2040                    try {
2041                            for (long scProductEntryPK : scProductEntryPKs) {
2042                                    addSCProductEntry.add(pk, scProductEntryPK);
2043                            }
2044                    }
2045                    catch (Exception e) {
2046                            throw processException(e);
2047                    }
2048                    finally {
2049                            FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2050                    }
2051            }
2052    
2053            /**
2054             * 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.
2055             *
2056             * @param pk the primary key of the s c license
2057             * @param scProductEntries the s c product entries
2058             * @throws SystemException if a system exception occurred
2059             */
2060            public void addSCProductEntries(long pk,
2061                    List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries)
2062                    throws SystemException {
2063                    try {
2064                            for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2065                                    addSCProductEntry.add(pk, scProductEntry.getPrimaryKey());
2066                            }
2067                    }
2068                    catch (Exception e) {
2069                            throw processException(e);
2070                    }
2071                    finally {
2072                            FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2073                    }
2074            }
2075    
2076            /**
2077             * 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.
2078             *
2079             * @param pk the primary key of the s c license to clear the associated s c product entries from
2080             * @throws SystemException if a system exception occurred
2081             */
2082            public void clearSCProductEntries(long pk) throws SystemException {
2083                    try {
2084                            clearSCProductEntries.clear(pk);
2085                    }
2086                    catch (Exception e) {
2087                            throw processException(e);
2088                    }
2089                    finally {
2090                            FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2091                    }
2092            }
2093    
2094            /**
2095             * 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.
2096             *
2097             * @param pk the primary key of the s c license
2098             * @param scProductEntryPK the primary key of the s c product entry
2099             * @throws SystemException if a system exception occurred
2100             */
2101            public void removeSCProductEntry(long pk, long scProductEntryPK)
2102                    throws SystemException {
2103                    try {
2104                            removeSCProductEntry.remove(pk, scProductEntryPK);
2105                    }
2106                    catch (Exception e) {
2107                            throw processException(e);
2108                    }
2109                    finally {
2110                            FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2111                    }
2112            }
2113    
2114            /**
2115             * 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.
2116             *
2117             * @param pk the primary key of the s c license
2118             * @param scProductEntry the s c product entry
2119             * @throws SystemException if a system exception occurred
2120             */
2121            public void removeSCProductEntry(long pk,
2122                    com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry)
2123                    throws SystemException {
2124                    try {
2125                            removeSCProductEntry.remove(pk, scProductEntry.getPrimaryKey());
2126                    }
2127                    catch (Exception e) {
2128                            throw processException(e);
2129                    }
2130                    finally {
2131                            FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2132                    }
2133            }
2134    
2135            /**
2136             * 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.
2137             *
2138             * @param pk the primary key of the s c license
2139             * @param scProductEntryPKs the primary keys of the s c product entries
2140             * @throws SystemException if a system exception occurred
2141             */
2142            public void removeSCProductEntries(long pk, long[] scProductEntryPKs)
2143                    throws SystemException {
2144                    try {
2145                            for (long scProductEntryPK : scProductEntryPKs) {
2146                                    removeSCProductEntry.remove(pk, scProductEntryPK);
2147                            }
2148                    }
2149                    catch (Exception e) {
2150                            throw processException(e);
2151                    }
2152                    finally {
2153                            FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2154                    }
2155            }
2156    
2157            /**
2158             * 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.
2159             *
2160             * @param pk the primary key of the s c license
2161             * @param scProductEntries the s c product entries
2162             * @throws SystemException if a system exception occurred
2163             */
2164            public void removeSCProductEntries(long pk,
2165                    List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries)
2166                    throws SystemException {
2167                    try {
2168                            for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2169                                    removeSCProductEntry.remove(pk, scProductEntry.getPrimaryKey());
2170                            }
2171                    }
2172                    catch (Exception e) {
2173                            throw processException(e);
2174                    }
2175                    finally {
2176                            FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2177                    }
2178            }
2179    
2180            /**
2181             * 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.
2182             *
2183             * @param pk the primary key of the s c license to set the associations for
2184             * @param scProductEntryPKs the primary keys of the s c product entries to be associated with the s c license
2185             * @throws SystemException if a system exception occurred
2186             */
2187            public void setSCProductEntries(long pk, long[] scProductEntryPKs)
2188                    throws SystemException {
2189                    try {
2190                            Set<Long> scProductEntryPKSet = SetUtil.fromArray(scProductEntryPKs);
2191    
2192                            List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries =
2193                                    getSCProductEntries(pk);
2194    
2195                            for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2196                                    if (!scProductEntryPKSet.remove(scProductEntry.getPrimaryKey())) {
2197                                            removeSCProductEntry.remove(pk,
2198                                                    scProductEntry.getPrimaryKey());
2199                                    }
2200                            }
2201    
2202                            for (Long scProductEntryPK : scProductEntryPKSet) {
2203                                    addSCProductEntry.add(pk, scProductEntryPK);
2204                            }
2205                    }
2206                    catch (Exception e) {
2207                            throw processException(e);
2208                    }
2209                    finally {
2210                            FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2211                    }
2212            }
2213    
2214            /**
2215             * 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.
2216             *
2217             * @param pk the primary key of the s c license to set the associations for
2218             * @param scProductEntries the s c product entries to be associated with the s c license
2219             * @throws SystemException if a system exception occurred
2220             */
2221            public void setSCProductEntries(long pk,
2222                    List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries)
2223                    throws SystemException {
2224                    try {
2225                            long[] scProductEntryPKs = new long[scProductEntries.size()];
2226    
2227                            for (int i = 0; i < scProductEntries.size(); i++) {
2228                                    com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry =
2229                                            scProductEntries.get(i);
2230    
2231                                    scProductEntryPKs[i] = scProductEntry.getPrimaryKey();
2232                            }
2233    
2234                            setSCProductEntries(pk, scProductEntryPKs);
2235                    }
2236                    catch (Exception e) {
2237                            throw processException(e);
2238                    }
2239                    finally {
2240                            FinderCacheUtil.clearCache(SCLicenseModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2241                    }
2242            }
2243    
2244            /**
2245             * Initializes the s c license persistence.
2246             */
2247            public void afterPropertiesSet() {
2248                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2249                                            com.liferay.portal.util.PropsUtil.get(
2250                                                    "value.object.listener.com.liferay.portlet.softwarecatalog.model.SCLicense")));
2251    
2252                    if (listenerClassNames.length > 0) {
2253                            try {
2254                                    List<ModelListener<SCLicense>> listenersList = new ArrayList<ModelListener<SCLicense>>();
2255    
2256                                    for (String listenerClassName : listenerClassNames) {
2257                                            listenersList.add((ModelListener<SCLicense>)InstanceFactory.newInstance(
2258                                                            listenerClassName));
2259                                    }
2260    
2261                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2262                            }
2263                            catch (Exception e) {
2264                                    _log.error(e);
2265                            }
2266                    }
2267    
2268                    containsSCProductEntry = new ContainsSCProductEntry(this);
2269    
2270                    addSCProductEntry = new AddSCProductEntry(this);
2271                    clearSCProductEntries = new ClearSCProductEntries(this);
2272                    removeSCProductEntry = new RemoveSCProductEntry(this);
2273            }
2274    
2275            public void destroy() {
2276                    EntityCacheUtil.removeCache(SCLicenseImpl.class.getName());
2277                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2278                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
2279            }
2280    
2281            @BeanReference(type = SCLicensePersistence.class)
2282            protected SCLicensePersistence scLicensePersistence;
2283            @BeanReference(type = SCFrameworkVersionPersistence.class)
2284            protected SCFrameworkVersionPersistence scFrameworkVersionPersistence;
2285            @BeanReference(type = SCProductEntryPersistence.class)
2286            protected SCProductEntryPersistence scProductEntryPersistence;
2287            @BeanReference(type = SCProductScreenshotPersistence.class)
2288            protected SCProductScreenshotPersistence scProductScreenshotPersistence;
2289            @BeanReference(type = SCProductVersionPersistence.class)
2290            protected SCProductVersionPersistence scProductVersionPersistence;
2291            @BeanReference(type = ResourcePersistence.class)
2292            protected ResourcePersistence resourcePersistence;
2293            @BeanReference(type = UserPersistence.class)
2294            protected UserPersistence userPersistence;
2295            protected ContainsSCProductEntry containsSCProductEntry;
2296            protected AddSCProductEntry addSCProductEntry;
2297            protected ClearSCProductEntries clearSCProductEntries;
2298            protected RemoveSCProductEntry removeSCProductEntry;
2299    
2300            protected class ContainsSCProductEntry {
2301                    protected ContainsSCProductEntry(
2302                            SCLicensePersistenceImpl persistenceImpl) {
2303                            super();
2304    
2305                            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2306                                            _SQL_CONTAINSSCPRODUCTENTRY,
2307                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
2308                                            RowMapper.COUNT);
2309                    }
2310    
2311                    protected boolean contains(long licenseId, long productEntryId) {
2312                            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2313                                                    new Long(licenseId), new Long(productEntryId)
2314                                            });
2315    
2316                            if (results.size() > 0) {
2317                                    Integer count = results.get(0);
2318    
2319                                    if (count.intValue() > 0) {
2320                                            return true;
2321                                    }
2322                            }
2323    
2324                            return false;
2325                    }
2326    
2327                    private MappingSqlQuery<Integer> _mappingSqlQuery;
2328            }
2329    
2330            protected class AddSCProductEntry {
2331                    protected AddSCProductEntry(SCLicensePersistenceImpl persistenceImpl) {
2332                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2333                                            "INSERT INTO SCLicenses_SCProductEntries (licenseId, productEntryId) VALUES (?, ?)",
2334                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2335                            _persistenceImpl = persistenceImpl;
2336                    }
2337    
2338                    protected void add(long licenseId, long productEntryId)
2339                            throws SystemException {
2340                            if (!_persistenceImpl.containsSCProductEntry.contains(licenseId,
2341                                                    productEntryId)) {
2342                                    ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry>[] scProductEntryListeners =
2343                                            scProductEntryPersistence.getListeners();
2344    
2345                                    for (ModelListener<SCLicense> listener : listeners) {
2346                                            listener.onBeforeAddAssociation(licenseId,
2347                                                    com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2348                                                    productEntryId);
2349                                    }
2350    
2351                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2352                                            listener.onBeforeAddAssociation(productEntryId,
2353                                                    SCLicense.class.getName(), licenseId);
2354                                    }
2355    
2356                                    _sqlUpdate.update(new Object[] {
2357                                                    new Long(licenseId), new Long(productEntryId)
2358                                            });
2359    
2360                                    for (ModelListener<SCLicense> listener : listeners) {
2361                                            listener.onAfterAddAssociation(licenseId,
2362                                                    com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2363                                                    productEntryId);
2364                                    }
2365    
2366                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2367                                            listener.onAfterAddAssociation(productEntryId,
2368                                                    SCLicense.class.getName(), licenseId);
2369                                    }
2370                            }
2371                    }
2372    
2373                    private SqlUpdate _sqlUpdate;
2374                    private SCLicensePersistenceImpl _persistenceImpl;
2375            }
2376    
2377            protected class ClearSCProductEntries {
2378                    protected ClearSCProductEntries(
2379                            SCLicensePersistenceImpl persistenceImpl) {
2380                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2381                                            "DELETE FROM SCLicenses_SCProductEntries WHERE licenseId = ?",
2382                                            new int[] { java.sql.Types.BIGINT });
2383                    }
2384    
2385                    protected void clear(long licenseId) throws SystemException {
2386                            ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry>[] scProductEntryListeners =
2387                                    scProductEntryPersistence.getListeners();
2388    
2389                            List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> scProductEntries =
2390                                    null;
2391    
2392                            if ((listeners.length > 0) || (scProductEntryListeners.length > 0)) {
2393                                    scProductEntries = getSCProductEntries(licenseId);
2394    
2395                                    for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2396                                            for (ModelListener<SCLicense> listener : listeners) {
2397                                                    listener.onBeforeRemoveAssociation(licenseId,
2398                                                            com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2399                                                            scProductEntry.getPrimaryKey());
2400                                            }
2401    
2402                                            for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2403                                                    listener.onBeforeRemoveAssociation(scProductEntry.getPrimaryKey(),
2404                                                            SCLicense.class.getName(), licenseId);
2405                                            }
2406                                    }
2407                            }
2408    
2409                            _sqlUpdate.update(new Object[] { new Long(licenseId) });
2410    
2411                            if ((listeners.length > 0) || (scProductEntryListeners.length > 0)) {
2412                                    for (com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry : scProductEntries) {
2413                                            for (ModelListener<SCLicense> listener : listeners) {
2414                                                    listener.onAfterRemoveAssociation(licenseId,
2415                                                            com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2416                                                            scProductEntry.getPrimaryKey());
2417                                            }
2418    
2419                                            for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2420                                                    listener.onAfterRemoveAssociation(scProductEntry.getPrimaryKey(),
2421                                                            SCLicense.class.getName(), licenseId);
2422                                            }
2423                                    }
2424                            }
2425                    }
2426    
2427                    private SqlUpdate _sqlUpdate;
2428            }
2429    
2430            protected class RemoveSCProductEntry {
2431                    protected RemoveSCProductEntry(SCLicensePersistenceImpl persistenceImpl) {
2432                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2433                                            "DELETE FROM SCLicenses_SCProductEntries WHERE licenseId = ? AND productEntryId = ?",
2434                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2435                            _persistenceImpl = persistenceImpl;
2436                    }
2437    
2438                    protected void remove(long licenseId, long productEntryId)
2439                            throws SystemException {
2440                            if (_persistenceImpl.containsSCProductEntry.contains(licenseId,
2441                                                    productEntryId)) {
2442                                    ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry>[] scProductEntryListeners =
2443                                            scProductEntryPersistence.getListeners();
2444    
2445                                    for (ModelListener<SCLicense> listener : listeners) {
2446                                            listener.onBeforeRemoveAssociation(licenseId,
2447                                                    com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2448                                                    productEntryId);
2449                                    }
2450    
2451                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2452                                            listener.onBeforeRemoveAssociation(productEntryId,
2453                                                    SCLicense.class.getName(), licenseId);
2454                                    }
2455    
2456                                    _sqlUpdate.update(new Object[] {
2457                                                    new Long(licenseId), new Long(productEntryId)
2458                                            });
2459    
2460                                    for (ModelListener<SCLicense> listener : listeners) {
2461                                            listener.onAfterRemoveAssociation(licenseId,
2462                                                    com.liferay.portlet.softwarecatalog.model.SCProductEntry.class.getName(),
2463                                                    productEntryId);
2464                                    }
2465    
2466                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductEntry> listener : scProductEntryListeners) {
2467                                            listener.onAfterRemoveAssociation(productEntryId,
2468                                                    SCLicense.class.getName(), licenseId);
2469                                    }
2470                            }
2471                    }
2472    
2473                    private SqlUpdate _sqlUpdate;
2474                    private SCLicensePersistenceImpl _persistenceImpl;
2475            }
2476    
2477            private static final String _SQL_SELECT_SCLICENSE = "SELECT scLicense FROM SCLicense scLicense";
2478            private static final String _SQL_SELECT_SCLICENSE_WHERE = "SELECT scLicense FROM SCLicense scLicense WHERE ";
2479            private static final String _SQL_COUNT_SCLICENSE = "SELECT COUNT(scLicense) FROM SCLicense scLicense";
2480            private static final String _SQL_COUNT_SCLICENSE_WHERE = "SELECT COUNT(scLicense) FROM SCLicense scLicense WHERE ";
2481            private static final String _SQL_GETSCPRODUCTENTRIES = "SELECT {SCProductEntry.*} FROM SCProductEntry INNER JOIN SCLicenses_SCProductEntries ON (SCLicenses_SCProductEntries.productEntryId = SCProductEntry.productEntryId) WHERE (SCLicenses_SCProductEntries.licenseId = ?)";
2482            private static final String _SQL_GETSCPRODUCTENTRIESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE licenseId = ?";
2483            private static final String _SQL_CONTAINSSCPRODUCTENTRY = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE licenseId = ? AND productEntryId = ?";
2484            private static final String _FINDER_COLUMN_ACTIVE_ACTIVE_2 = "scLicense.active = ?";
2485            private static final String _FINDER_COLUMN_A_R_ACTIVE_2 = "scLicense.active = ? AND ";
2486            private static final String _FINDER_COLUMN_A_R_RECOMMENDED_2 = "scLicense.recommended = ?";
2487            private static final String _FILTER_SQL_SELECT_SCLICENSE_WHERE = "SELECT DISTINCT {scLicense.*} FROM SCLicense scLicense WHERE ";
2488            private static final String _FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_1 =
2489                    "SELECT {SCLicense.*} FROM (SELECT DISTINCT scLicense.licenseId FROM SCLicense scLicense WHERE ";
2490            private static final String _FILTER_SQL_SELECT_SCLICENSE_NO_INLINE_DISTINCT_WHERE_2 =
2491                    ") TEMP_TABLE INNER JOIN SCLicense ON TEMP_TABLE.licenseId = SCLicense.licenseId";
2492            private static final String _FILTER_SQL_COUNT_SCLICENSE_WHERE = "SELECT COUNT(DISTINCT scLicense.licenseId) AS COUNT_VALUE FROM SCLicense scLicense WHERE ";
2493            private static final String _FILTER_COLUMN_PK = "scLicense.licenseId";
2494            private static final String _FILTER_COLUMN_USERID = null;
2495            private static final String _FILTER_ENTITY_ALIAS = "scLicense";
2496            private static final String _FILTER_ENTITY_TABLE = "SCLicense";
2497            private static final String _ORDER_BY_ENTITY_ALIAS = "scLicense.";
2498            private static final String _ORDER_BY_ENTITY_TABLE = "SCLicense.";
2499            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SCLicense exists with the primary key ";
2500            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SCLicense exists with the key {";
2501            private static Log _log = LogFactoryUtil.getLog(SCLicensePersistenceImpl.class);
2502    }