001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet.softwarecatalog.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.bean.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
021    import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
022    import com.liferay.portal.kernel.dao.jdbc.RowMapper;
023    import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
024    import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
025    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
026    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
027    import com.liferay.portal.kernel.dao.orm.FinderPath;
028    import com.liferay.portal.kernel.dao.orm.Query;
029    import com.liferay.portal.kernel.dao.orm.QueryPos;
030    import com.liferay.portal.kernel.dao.orm.QueryUtil;
031    import com.liferay.portal.kernel.dao.orm.SQLQuery;
032    import com.liferay.portal.kernel.dao.orm.Session;
033    import com.liferay.portal.kernel.exception.SystemException;
034    import com.liferay.portal.kernel.log.Log;
035    import com.liferay.portal.kernel.log.LogFactoryUtil;
036    import com.liferay.portal.kernel.util.GetterUtil;
037    import com.liferay.portal.kernel.util.InstanceFactory;
038    import com.liferay.portal.kernel.util.OrderByComparator;
039    import com.liferay.portal.kernel.util.SetUtil;
040    import com.liferay.portal.kernel.util.StringBundler;
041    import com.liferay.portal.kernel.util.StringPool;
042    import com.liferay.portal.kernel.util.StringUtil;
043    import com.liferay.portal.model.CacheModel;
044    import com.liferay.portal.model.ModelListener;
045    import com.liferay.portal.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.NoSuchProductVersionException;
051    import com.liferay.portlet.softwarecatalog.model.SCProductVersion;
052    import com.liferay.portlet.softwarecatalog.model.impl.SCProductVersionImpl;
053    import com.liferay.portlet.softwarecatalog.model.impl.SCProductVersionModelImpl;
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 product version service.
064     *
065     * <p>
066     * Caching information and settings can be found in <code>portal.properties</code>
067     * </p>
068     *
069     * @author Brian Wing Shun Chan
070     * @see SCProductVersionPersistence
071     * @see SCProductVersionUtil
072     * @generated
073     */
074    public class SCProductVersionPersistenceImpl extends BasePersistenceImpl<SCProductVersion>
075            implements SCProductVersionPersistence {
076            /*
077             * NOTE FOR DEVELOPERS:
078             *
079             * Never modify or reference this class directly. Always use {@link SCProductVersionUtil} to access the s c product version persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
080             */
081            public static final String FINDER_CLASS_NAME_ENTITY = SCProductVersionImpl.class.getName();
082            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
083                    ".List1";
084            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
085                    ".List2";
086            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_PRODUCTENTRYID =
087                    new FinderPath(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
088                            SCProductVersionModelImpl.FINDER_CACHE_ENABLED,
089                            SCProductVersionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
090                            "findByProductEntryId",
091                            new String[] {
092                                    Long.class.getName(),
093                                    
094                            "java.lang.Integer", "java.lang.Integer",
095                                    "com.liferay.portal.kernel.util.OrderByComparator"
096                            });
097            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PRODUCTENTRYID =
098                    new FinderPath(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
099                            SCProductVersionModelImpl.FINDER_CACHE_ENABLED,
100                            SCProductVersionImpl.class,
101                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByProductEntryId",
102                            new String[] { Long.class.getName() },
103                            SCProductVersionModelImpl.PRODUCTENTRYID_COLUMN_BITMASK);
104            public static final FinderPath FINDER_PATH_COUNT_BY_PRODUCTENTRYID = new FinderPath(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
105                            SCProductVersionModelImpl.FINDER_CACHE_ENABLED, Long.class,
106                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByProductEntryId",
107                            new String[] { Long.class.getName() });
108            public static final FinderPath FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL = new FinderPath(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
109                            SCProductVersionModelImpl.FINDER_CACHE_ENABLED,
110                            SCProductVersionImpl.class, FINDER_CLASS_NAME_ENTITY,
111                            "fetchByDirectDownloadURL",
112                            new String[] { String.class.getName() },
113                            SCProductVersionModelImpl.DIRECTDOWNLOADURL_COLUMN_BITMASK);
114            public static final FinderPath FINDER_PATH_COUNT_BY_DIRECTDOWNLOADURL = new FinderPath(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
115                            SCProductVersionModelImpl.FINDER_CACHE_ENABLED, Long.class,
116                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
117                            "countByDirectDownloadURL", new String[] { String.class.getName() });
118            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
119                            SCProductVersionModelImpl.FINDER_CACHE_ENABLED,
120                            SCProductVersionImpl.class,
121                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
122            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
123                            SCProductVersionModelImpl.FINDER_CACHE_ENABLED,
124                            SCProductVersionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
125                            "findAll", new String[0]);
126            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
127                            SCProductVersionModelImpl.FINDER_CACHE_ENABLED, Long.class,
128                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
129    
130            /**
131             * Caches the s c product version in the entity cache if it is enabled.
132             *
133             * @param scProductVersion the s c product version
134             */
135            public void cacheResult(SCProductVersion scProductVersion) {
136                    EntityCacheUtil.putResult(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
137                            SCProductVersionImpl.class, scProductVersion.getPrimaryKey(),
138                            scProductVersion);
139    
140                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
141                            new Object[] { scProductVersion.getDirectDownloadURL() },
142                            scProductVersion);
143    
144                    scProductVersion.resetOriginalValues();
145            }
146    
147            /**
148             * Caches the s c product versions in the entity cache if it is enabled.
149             *
150             * @param scProductVersions the s c product versions
151             */
152            public void cacheResult(List<SCProductVersion> scProductVersions) {
153                    for (SCProductVersion scProductVersion : scProductVersions) {
154                            if (EntityCacheUtil.getResult(
155                                                    SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
156                                                    SCProductVersionImpl.class,
157                                                    scProductVersion.getPrimaryKey()) == null) {
158                                    cacheResult(scProductVersion);
159                            }
160                            else {
161                                    scProductVersion.resetOriginalValues();
162                            }
163                    }
164            }
165    
166            /**
167             * Clears the cache for all s c product versions.
168             *
169             * <p>
170             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
171             * </p>
172             */
173            @Override
174            public void clearCache() {
175                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
176                            CacheRegistryUtil.clear(SCProductVersionImpl.class.getName());
177                    }
178    
179                    EntityCacheUtil.clearCache(SCProductVersionImpl.class.getName());
180    
181                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
182                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
183                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
184            }
185    
186            /**
187             * Clears the cache for the s c product version.
188             *
189             * <p>
190             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
191             * </p>
192             */
193            @Override
194            public void clearCache(SCProductVersion scProductVersion) {
195                    EntityCacheUtil.removeResult(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
196                            SCProductVersionImpl.class, scProductVersion.getPrimaryKey());
197    
198                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
199                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
200    
201                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
202                            new Object[] { scProductVersion.getDirectDownloadURL() });
203            }
204    
205            /**
206             * Creates a new s c product version with the primary key. Does not add the s c product version to the database.
207             *
208             * @param productVersionId the primary key for the new s c product version
209             * @return the new s c product version
210             */
211            public SCProductVersion create(long productVersionId) {
212                    SCProductVersion scProductVersion = new SCProductVersionImpl();
213    
214                    scProductVersion.setNew(true);
215                    scProductVersion.setPrimaryKey(productVersionId);
216    
217                    return scProductVersion;
218            }
219    
220            /**
221             * Removes the s c product version with the primary key from the database. Also notifies the appropriate model listeners.
222             *
223             * @param primaryKey the primary key of the s c product version
224             * @return the s c product version that was removed
225             * @throws com.liferay.portal.NoSuchModelException if a s c product version with the primary key could not be found
226             * @throws SystemException if a system exception occurred
227             */
228            @Override
229            public SCProductVersion remove(Serializable primaryKey)
230                    throws NoSuchModelException, SystemException {
231                    return remove(((Long)primaryKey).longValue());
232            }
233    
234            /**
235             * Removes the s c product version with the primary key from the database. Also notifies the appropriate model listeners.
236             *
237             * @param productVersionId the primary key of the s c product version
238             * @return the s c product version that was removed
239             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductVersionException if a s c product version with the primary key could not be found
240             * @throws SystemException if a system exception occurred
241             */
242            public SCProductVersion remove(long productVersionId)
243                    throws NoSuchProductVersionException, SystemException {
244                    Session session = null;
245    
246                    try {
247                            session = openSession();
248    
249                            SCProductVersion scProductVersion = (SCProductVersion)session.get(SCProductVersionImpl.class,
250                                            Long.valueOf(productVersionId));
251    
252                            if (scProductVersion == null) {
253                                    if (_log.isWarnEnabled()) {
254                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
255                                                    productVersionId);
256                                    }
257    
258                                    throw new NoSuchProductVersionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
259                                            productVersionId);
260                            }
261    
262                            return scProductVersionPersistence.remove(scProductVersion);
263                    }
264                    catch (NoSuchProductVersionException nsee) {
265                            throw nsee;
266                    }
267                    catch (Exception e) {
268                            throw processException(e);
269                    }
270                    finally {
271                            closeSession(session);
272                    }
273            }
274    
275            /**
276             * Removes the s c product version from the database. Also notifies the appropriate model listeners.
277             *
278             * @param scProductVersion the s c product version
279             * @return the s c product version that was removed
280             * @throws SystemException if a system exception occurred
281             */
282            @Override
283            public SCProductVersion remove(SCProductVersion scProductVersion)
284                    throws SystemException {
285                    return super.remove(scProductVersion);
286            }
287    
288            @Override
289            protected SCProductVersion removeImpl(SCProductVersion scProductVersion)
290                    throws SystemException {
291                    scProductVersion = toUnwrappedModel(scProductVersion);
292    
293                    try {
294                            clearSCFrameworkVersions.clear(scProductVersion.getPrimaryKey());
295                    }
296                    catch (Exception e) {
297                            throw processException(e);
298                    }
299                    finally {
300                            FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
301                    }
302    
303                    Session session = null;
304    
305                    try {
306                            session = openSession();
307    
308                            BatchSessionUtil.delete(session, scProductVersion);
309                    }
310                    catch (Exception e) {
311                            throw processException(e);
312                    }
313                    finally {
314                            closeSession(session);
315                    }
316    
317                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
318                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
319    
320                    SCProductVersionModelImpl scProductVersionModelImpl = (SCProductVersionModelImpl)scProductVersion;
321    
322                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
323                            new Object[] { scProductVersionModelImpl.getDirectDownloadURL() });
324    
325                    EntityCacheUtil.removeResult(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
326                            SCProductVersionImpl.class, scProductVersion.getPrimaryKey());
327    
328                    return scProductVersion;
329            }
330    
331            @Override
332            public SCProductVersion updateImpl(
333                    com.liferay.portlet.softwarecatalog.model.SCProductVersion scProductVersion,
334                    boolean merge) throws SystemException {
335                    scProductVersion = toUnwrappedModel(scProductVersion);
336    
337                    boolean isNew = scProductVersion.isNew();
338    
339                    SCProductVersionModelImpl scProductVersionModelImpl = (SCProductVersionModelImpl)scProductVersion;
340    
341                    Session session = null;
342    
343                    try {
344                            session = openSession();
345    
346                            BatchSessionUtil.update(session, scProductVersion, merge);
347    
348                            scProductVersion.setNew(false);
349                    }
350                    catch (Exception e) {
351                            throw processException(e);
352                    }
353                    finally {
354                            closeSession(session);
355                    }
356    
357                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
358    
359                    if (isNew || !SCProductVersionModelImpl.COLUMN_BITMASK_ENABLED) {
360                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
361                    }
362    
363                    else {
364                            if ((scProductVersionModelImpl.getColumnBitmask() &
365                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PRODUCTENTRYID.getColumnBitmask()) != 0) {
366                                    Object[] args = new Object[] {
367                                                    Long.valueOf(scProductVersionModelImpl.getOriginalProductEntryId())
368                                            };
369    
370                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PRODUCTENTRYID,
371                                            args);
372                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PRODUCTENTRYID,
373                                            args);
374    
375                                    args = new Object[] {
376                                                    Long.valueOf(scProductVersionModelImpl.getProductEntryId())
377                                            };
378    
379                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PRODUCTENTRYID,
380                                            args);
381                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PRODUCTENTRYID,
382                                            args);
383                            }
384                    }
385    
386                    EntityCacheUtil.putResult(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
387                            SCProductVersionImpl.class, scProductVersion.getPrimaryKey(),
388                            scProductVersion);
389    
390                    if (isNew) {
391                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
392                                    new Object[] { scProductVersion.getDirectDownloadURL() },
393                                    scProductVersion);
394                    }
395                    else {
396                            if ((scProductVersionModelImpl.getColumnBitmask() &
397                                            FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL.getColumnBitmask()) != 0) {
398                                    Object[] args = new Object[] {
399                                                    scProductVersionModelImpl.getOriginalDirectDownloadURL()
400                                            };
401    
402                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_DIRECTDOWNLOADURL,
403                                            args);
404                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
405                                            args);
406    
407                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
408                                            new Object[] { scProductVersion.getDirectDownloadURL() },
409                                            scProductVersion);
410                            }
411                    }
412    
413                    return scProductVersion;
414            }
415    
416            protected SCProductVersion toUnwrappedModel(
417                    SCProductVersion scProductVersion) {
418                    if (scProductVersion instanceof SCProductVersionImpl) {
419                            return scProductVersion;
420                    }
421    
422                    SCProductVersionImpl scProductVersionImpl = new SCProductVersionImpl();
423    
424                    scProductVersionImpl.setNew(scProductVersion.isNew());
425                    scProductVersionImpl.setPrimaryKey(scProductVersion.getPrimaryKey());
426    
427                    scProductVersionImpl.setProductVersionId(scProductVersion.getProductVersionId());
428                    scProductVersionImpl.setCompanyId(scProductVersion.getCompanyId());
429                    scProductVersionImpl.setUserId(scProductVersion.getUserId());
430                    scProductVersionImpl.setUserName(scProductVersion.getUserName());
431                    scProductVersionImpl.setCreateDate(scProductVersion.getCreateDate());
432                    scProductVersionImpl.setModifiedDate(scProductVersion.getModifiedDate());
433                    scProductVersionImpl.setProductEntryId(scProductVersion.getProductEntryId());
434                    scProductVersionImpl.setVersion(scProductVersion.getVersion());
435                    scProductVersionImpl.setChangeLog(scProductVersion.getChangeLog());
436                    scProductVersionImpl.setDownloadPageURL(scProductVersion.getDownloadPageURL());
437                    scProductVersionImpl.setDirectDownloadURL(scProductVersion.getDirectDownloadURL());
438                    scProductVersionImpl.setRepoStoreArtifact(scProductVersion.isRepoStoreArtifact());
439    
440                    return scProductVersionImpl;
441            }
442    
443            /**
444             * Returns the s c product version with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
445             *
446             * @param primaryKey the primary key of the s c product version
447             * @return the s c product version
448             * @throws com.liferay.portal.NoSuchModelException if a s c product version with the primary key could not be found
449             * @throws SystemException if a system exception occurred
450             */
451            @Override
452            public SCProductVersion findByPrimaryKey(Serializable primaryKey)
453                    throws NoSuchModelException, SystemException {
454                    return findByPrimaryKey(((Long)primaryKey).longValue());
455            }
456    
457            /**
458             * Returns the s c product version with the primary key or throws a {@link com.liferay.portlet.softwarecatalog.NoSuchProductVersionException} if it could not be found.
459             *
460             * @param productVersionId the primary key of the s c product version
461             * @return the s c product version
462             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductVersionException if a s c product version with the primary key could not be found
463             * @throws SystemException if a system exception occurred
464             */
465            public SCProductVersion findByPrimaryKey(long productVersionId)
466                    throws NoSuchProductVersionException, SystemException {
467                    SCProductVersion scProductVersion = fetchByPrimaryKey(productVersionId);
468    
469                    if (scProductVersion == null) {
470                            if (_log.isWarnEnabled()) {
471                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + productVersionId);
472                            }
473    
474                            throw new NoSuchProductVersionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
475                                    productVersionId);
476                    }
477    
478                    return scProductVersion;
479            }
480    
481            /**
482             * Returns the s c product version with the primary key or returns <code>null</code> if it could not be found.
483             *
484             * @param primaryKey the primary key of the s c product version
485             * @return the s c product version, or <code>null</code> if a s c product version with the primary key could not be found
486             * @throws SystemException if a system exception occurred
487             */
488            @Override
489            public SCProductVersion fetchByPrimaryKey(Serializable primaryKey)
490                    throws SystemException {
491                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
492            }
493    
494            /**
495             * Returns the s c product version with the primary key or returns <code>null</code> if it could not be found.
496             *
497             * @param productVersionId the primary key of the s c product version
498             * @return the s c product version, or <code>null</code> if a s c product version with the primary key could not be found
499             * @throws SystemException if a system exception occurred
500             */
501            public SCProductVersion fetchByPrimaryKey(long productVersionId)
502                    throws SystemException {
503                    SCProductVersion scProductVersion = (SCProductVersion)EntityCacheUtil.getResult(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
504                                    SCProductVersionImpl.class, productVersionId);
505    
506                    if (scProductVersion == _nullSCProductVersion) {
507                            return null;
508                    }
509    
510                    if (scProductVersion == null) {
511                            Session session = null;
512    
513                            boolean hasException = false;
514    
515                            try {
516                                    session = openSession();
517    
518                                    scProductVersion = (SCProductVersion)session.get(SCProductVersionImpl.class,
519                                                    Long.valueOf(productVersionId));
520                            }
521                            catch (Exception e) {
522                                    hasException = true;
523    
524                                    throw processException(e);
525                            }
526                            finally {
527                                    if (scProductVersion != null) {
528                                            cacheResult(scProductVersion);
529                                    }
530                                    else if (!hasException) {
531                                            EntityCacheUtil.putResult(SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
532                                                    SCProductVersionImpl.class, productVersionId,
533                                                    _nullSCProductVersion);
534                                    }
535    
536                                    closeSession(session);
537                            }
538                    }
539    
540                    return scProductVersion;
541            }
542    
543            /**
544             * Returns all the s c product versions where productEntryId = &#63;.
545             *
546             * @param productEntryId the product entry ID
547             * @return the matching s c product versions
548             * @throws SystemException if a system exception occurred
549             */
550            public List<SCProductVersion> findByProductEntryId(long productEntryId)
551                    throws SystemException {
552                    return findByProductEntryId(productEntryId, QueryUtil.ALL_POS,
553                            QueryUtil.ALL_POS, null);
554            }
555    
556            /**
557             * Returns a range of all the s c product versions where productEntryId = &#63;.
558             *
559             * <p>
560             * 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.
561             * </p>
562             *
563             * @param productEntryId the product entry ID
564             * @param start the lower bound of the range of s c product versions
565             * @param end the upper bound of the range of s c product versions (not inclusive)
566             * @return the range of matching s c product versions
567             * @throws SystemException if a system exception occurred
568             */
569            public List<SCProductVersion> findByProductEntryId(long productEntryId,
570                    int start, int end) throws SystemException {
571                    return findByProductEntryId(productEntryId, start, end, null);
572            }
573    
574            /**
575             * Returns an ordered range of all the s c product versions where productEntryId = &#63;.
576             *
577             * <p>
578             * 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.
579             * </p>
580             *
581             * @param productEntryId the product entry ID
582             * @param start the lower bound of the range of s c product versions
583             * @param end the upper bound of the range of s c product versions (not inclusive)
584             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
585             * @return the ordered range of matching s c product versions
586             * @throws SystemException if a system exception occurred
587             */
588            public List<SCProductVersion> findByProductEntryId(long productEntryId,
589                    int start, int end, OrderByComparator orderByComparator)
590                    throws SystemException {
591                    FinderPath finderPath = null;
592                    Object[] finderArgs = null;
593    
594                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
595                                    (orderByComparator == null)) {
596                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PRODUCTENTRYID;
597                            finderArgs = new Object[] { productEntryId };
598                    }
599                    else {
600                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PRODUCTENTRYID;
601                            finderArgs = new Object[] {
602                                            productEntryId,
603                                            
604                                            start, end, orderByComparator
605                                    };
606                    }
607    
608                    List<SCProductVersion> list = (List<SCProductVersion>)FinderCacheUtil.getResult(finderPath,
609                                    finderArgs, this);
610    
611                    if (list == null) {
612                            StringBundler query = null;
613    
614                            if (orderByComparator != null) {
615                                    query = new StringBundler(3 +
616                                                    (orderByComparator.getOrderByFields().length * 3));
617                            }
618                            else {
619                                    query = new StringBundler(3);
620                            }
621    
622                            query.append(_SQL_SELECT_SCPRODUCTVERSION_WHERE);
623    
624                            query.append(_FINDER_COLUMN_PRODUCTENTRYID_PRODUCTENTRYID_2);
625    
626                            if (orderByComparator != null) {
627                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
628                                            orderByComparator);
629                            }
630    
631                            else {
632                                    query.append(SCProductVersionModelImpl.ORDER_BY_JPQL);
633                            }
634    
635                            String sql = query.toString();
636    
637                            Session session = null;
638    
639                            try {
640                                    session = openSession();
641    
642                                    Query q = session.createQuery(sql);
643    
644                                    QueryPos qPos = QueryPos.getInstance(q);
645    
646                                    qPos.add(productEntryId);
647    
648                                    list = (List<SCProductVersion>)QueryUtil.list(q, getDialect(),
649                                                    start, end);
650                            }
651                            catch (Exception e) {
652                                    throw processException(e);
653                            }
654                            finally {
655                                    if (list == null) {
656                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
657                                    }
658                                    else {
659                                            cacheResult(list);
660    
661                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
662                                    }
663    
664                                    closeSession(session);
665                            }
666                    }
667    
668                    return list;
669            }
670    
671            /**
672             * Returns the first s c product version in the ordered set where productEntryId = &#63;.
673             *
674             * <p>
675             * 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.
676             * </p>
677             *
678             * @param productEntryId the product entry ID
679             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
680             * @return the first matching s c product version
681             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductVersionException if a matching s c product version could not be found
682             * @throws SystemException if a system exception occurred
683             */
684            public SCProductVersion findByProductEntryId_First(long productEntryId,
685                    OrderByComparator orderByComparator)
686                    throws NoSuchProductVersionException, SystemException {
687                    List<SCProductVersion> list = findByProductEntryId(productEntryId, 0,
688                                    1, orderByComparator);
689    
690                    if (list.isEmpty()) {
691                            StringBundler msg = new StringBundler(4);
692    
693                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
694    
695                            msg.append("productEntryId=");
696                            msg.append(productEntryId);
697    
698                            msg.append(StringPool.CLOSE_CURLY_BRACE);
699    
700                            throw new NoSuchProductVersionException(msg.toString());
701                    }
702                    else {
703                            return list.get(0);
704                    }
705            }
706    
707            /**
708             * Returns the last s c product version in the ordered set where productEntryId = &#63;.
709             *
710             * <p>
711             * 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.
712             * </p>
713             *
714             * @param productEntryId the product entry ID
715             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
716             * @return the last matching s c product version
717             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductVersionException if a matching s c product version could not be found
718             * @throws SystemException if a system exception occurred
719             */
720            public SCProductVersion findByProductEntryId_Last(long productEntryId,
721                    OrderByComparator orderByComparator)
722                    throws NoSuchProductVersionException, SystemException {
723                    int count = countByProductEntryId(productEntryId);
724    
725                    List<SCProductVersion> list = findByProductEntryId(productEntryId,
726                                    count - 1, count, orderByComparator);
727    
728                    if (list.isEmpty()) {
729                            StringBundler msg = new StringBundler(4);
730    
731                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
732    
733                            msg.append("productEntryId=");
734                            msg.append(productEntryId);
735    
736                            msg.append(StringPool.CLOSE_CURLY_BRACE);
737    
738                            throw new NoSuchProductVersionException(msg.toString());
739                    }
740                    else {
741                            return list.get(0);
742                    }
743            }
744    
745            /**
746             * Returns the s c product versions before and after the current s c product version in the ordered set where productEntryId = &#63;.
747             *
748             * <p>
749             * 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.
750             * </p>
751             *
752             * @param productVersionId the primary key of the current s c product version
753             * @param productEntryId the product entry ID
754             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
755             * @return the previous, current, and next s c product version
756             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductVersionException if a s c product version with the primary key could not be found
757             * @throws SystemException if a system exception occurred
758             */
759            public SCProductVersion[] findByProductEntryId_PrevAndNext(
760                    long productVersionId, long productEntryId,
761                    OrderByComparator orderByComparator)
762                    throws NoSuchProductVersionException, SystemException {
763                    SCProductVersion scProductVersion = findByPrimaryKey(productVersionId);
764    
765                    Session session = null;
766    
767                    try {
768                            session = openSession();
769    
770                            SCProductVersion[] array = new SCProductVersionImpl[3];
771    
772                            array[0] = getByProductEntryId_PrevAndNext(session,
773                                            scProductVersion, productEntryId, orderByComparator, true);
774    
775                            array[1] = scProductVersion;
776    
777                            array[2] = getByProductEntryId_PrevAndNext(session,
778                                            scProductVersion, productEntryId, orderByComparator, false);
779    
780                            return array;
781                    }
782                    catch (Exception e) {
783                            throw processException(e);
784                    }
785                    finally {
786                            closeSession(session);
787                    }
788            }
789    
790            protected SCProductVersion getByProductEntryId_PrevAndNext(
791                    Session session, SCProductVersion scProductVersion,
792                    long productEntryId, OrderByComparator orderByComparator,
793                    boolean previous) {
794                    StringBundler query = null;
795    
796                    if (orderByComparator != null) {
797                            query = new StringBundler(6 +
798                                            (orderByComparator.getOrderByFields().length * 6));
799                    }
800                    else {
801                            query = new StringBundler(3);
802                    }
803    
804                    query.append(_SQL_SELECT_SCPRODUCTVERSION_WHERE);
805    
806                    query.append(_FINDER_COLUMN_PRODUCTENTRYID_PRODUCTENTRYID_2);
807    
808                    if (orderByComparator != null) {
809                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
810    
811                            if (orderByConditionFields.length > 0) {
812                                    query.append(WHERE_AND);
813                            }
814    
815                            for (int i = 0; i < orderByConditionFields.length; i++) {
816                                    query.append(_ORDER_BY_ENTITY_ALIAS);
817                                    query.append(orderByConditionFields[i]);
818    
819                                    if ((i + 1) < orderByConditionFields.length) {
820                                            if (orderByComparator.isAscending() ^ previous) {
821                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
822                                            }
823                                            else {
824                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
825                                            }
826                                    }
827                                    else {
828                                            if (orderByComparator.isAscending() ^ previous) {
829                                                    query.append(WHERE_GREATER_THAN);
830                                            }
831                                            else {
832                                                    query.append(WHERE_LESSER_THAN);
833                                            }
834                                    }
835                            }
836    
837                            query.append(ORDER_BY_CLAUSE);
838    
839                            String[] orderByFields = orderByComparator.getOrderByFields();
840    
841                            for (int i = 0; i < orderByFields.length; i++) {
842                                    query.append(_ORDER_BY_ENTITY_ALIAS);
843                                    query.append(orderByFields[i]);
844    
845                                    if ((i + 1) < orderByFields.length) {
846                                            if (orderByComparator.isAscending() ^ previous) {
847                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
848                                            }
849                                            else {
850                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
851                                            }
852                                    }
853                                    else {
854                                            if (orderByComparator.isAscending() ^ previous) {
855                                                    query.append(ORDER_BY_ASC);
856                                            }
857                                            else {
858                                                    query.append(ORDER_BY_DESC);
859                                            }
860                                    }
861                            }
862                    }
863    
864                    else {
865                            query.append(SCProductVersionModelImpl.ORDER_BY_JPQL);
866                    }
867    
868                    String sql = query.toString();
869    
870                    Query q = session.createQuery(sql);
871    
872                    q.setFirstResult(0);
873                    q.setMaxResults(2);
874    
875                    QueryPos qPos = QueryPos.getInstance(q);
876    
877                    qPos.add(productEntryId);
878    
879                    if (orderByComparator != null) {
880                            Object[] values = orderByComparator.getOrderByConditionValues(scProductVersion);
881    
882                            for (Object value : values) {
883                                    qPos.add(value);
884                            }
885                    }
886    
887                    List<SCProductVersion> list = q.list();
888    
889                    if (list.size() == 2) {
890                            return list.get(1);
891                    }
892                    else {
893                            return null;
894                    }
895            }
896    
897            /**
898             * Returns the s c product version where directDownloadURL = &#63; or throws a {@link com.liferay.portlet.softwarecatalog.NoSuchProductVersionException} if it could not be found.
899             *
900             * @param directDownloadURL the direct download u r l
901             * @return the matching s c product version
902             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductVersionException if a matching s c product version could not be found
903             * @throws SystemException if a system exception occurred
904             */
905            public SCProductVersion findByDirectDownloadURL(String directDownloadURL)
906                    throws NoSuchProductVersionException, SystemException {
907                    SCProductVersion scProductVersion = fetchByDirectDownloadURL(directDownloadURL);
908    
909                    if (scProductVersion == null) {
910                            StringBundler msg = new StringBundler(4);
911    
912                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
913    
914                            msg.append("directDownloadURL=");
915                            msg.append(directDownloadURL);
916    
917                            msg.append(StringPool.CLOSE_CURLY_BRACE);
918    
919                            if (_log.isWarnEnabled()) {
920                                    _log.warn(msg.toString());
921                            }
922    
923                            throw new NoSuchProductVersionException(msg.toString());
924                    }
925    
926                    return scProductVersion;
927            }
928    
929            /**
930             * Returns the s c product version where directDownloadURL = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
931             *
932             * @param directDownloadURL the direct download u r l
933             * @return the matching s c product version, or <code>null</code> if a matching s c product version could not be found
934             * @throws SystemException if a system exception occurred
935             */
936            public SCProductVersion fetchByDirectDownloadURL(String directDownloadURL)
937                    throws SystemException {
938                    return fetchByDirectDownloadURL(directDownloadURL, true);
939            }
940    
941            /**
942             * Returns the s c product version where directDownloadURL = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
943             *
944             * @param directDownloadURL the direct download u r l
945             * @param retrieveFromCache whether to use the finder cache
946             * @return the matching s c product version, or <code>null</code> if a matching s c product version could not be found
947             * @throws SystemException if a system exception occurred
948             */
949            public SCProductVersion fetchByDirectDownloadURL(String directDownloadURL,
950                    boolean retrieveFromCache) throws SystemException {
951                    Object[] finderArgs = new Object[] { directDownloadURL };
952    
953                    Object result = null;
954    
955                    if (retrieveFromCache) {
956                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
957                                            finderArgs, this);
958                    }
959    
960                    if (result == null) {
961                            StringBundler query = new StringBundler(3);
962    
963                            query.append(_SQL_SELECT_SCPRODUCTVERSION_WHERE);
964    
965                            if (directDownloadURL == null) {
966                                    query.append(_FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_1);
967                            }
968                            else {
969                                    if (directDownloadURL.equals(StringPool.BLANK)) {
970                                            query.append(_FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_3);
971                                    }
972                                    else {
973                                            query.append(_FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_2);
974                                    }
975                            }
976    
977                            query.append(SCProductVersionModelImpl.ORDER_BY_JPQL);
978    
979                            String sql = query.toString();
980    
981                            Session session = null;
982    
983                            try {
984                                    session = openSession();
985    
986                                    Query q = session.createQuery(sql);
987    
988                                    QueryPos qPos = QueryPos.getInstance(q);
989    
990                                    if (directDownloadURL != null) {
991                                            qPos.add(directDownloadURL);
992                                    }
993    
994                                    List<SCProductVersion> list = q.list();
995    
996                                    result = list;
997    
998                                    SCProductVersion scProductVersion = null;
999    
1000                                    if (list.isEmpty()) {
1001                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
1002                                                    finderArgs, list);
1003                                    }
1004                                    else {
1005                                            scProductVersion = list.get(0);
1006    
1007                                            cacheResult(scProductVersion);
1008    
1009                                            if ((scProductVersion.getDirectDownloadURL() == null) ||
1010                                                            !scProductVersion.getDirectDownloadURL()
1011                                                                                                     .equals(directDownloadURL)) {
1012                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
1013                                                            finderArgs, scProductVersion);
1014                                            }
1015                                    }
1016    
1017                                    return scProductVersion;
1018                            }
1019                            catch (Exception e) {
1020                                    throw processException(e);
1021                            }
1022                            finally {
1023                                    if (result == null) {
1024                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_DIRECTDOWNLOADURL,
1025                                                    finderArgs);
1026                                    }
1027    
1028                                    closeSession(session);
1029                            }
1030                    }
1031                    else {
1032                            if (result instanceof List<?>) {
1033                                    return null;
1034                            }
1035                            else {
1036                                    return (SCProductVersion)result;
1037                            }
1038                    }
1039            }
1040    
1041            /**
1042             * Returns all the s c product versions.
1043             *
1044             * @return the s c product versions
1045             * @throws SystemException if a system exception occurred
1046             */
1047            public List<SCProductVersion> findAll() throws SystemException {
1048                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1049            }
1050    
1051            /**
1052             * Returns a range of all the s c product versions.
1053             *
1054             * <p>
1055             * 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.
1056             * </p>
1057             *
1058             * @param start the lower bound of the range of s c product versions
1059             * @param end the upper bound of the range of s c product versions (not inclusive)
1060             * @return the range of s c product versions
1061             * @throws SystemException if a system exception occurred
1062             */
1063            public List<SCProductVersion> findAll(int start, int end)
1064                    throws SystemException {
1065                    return findAll(start, end, null);
1066            }
1067    
1068            /**
1069             * Returns an ordered range of all the s c product versions.
1070             *
1071             * <p>
1072             * 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.
1073             * </p>
1074             *
1075             * @param start the lower bound of the range of s c product versions
1076             * @param end the upper bound of the range of s c product versions (not inclusive)
1077             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1078             * @return the ordered range of s c product versions
1079             * @throws SystemException if a system exception occurred
1080             */
1081            public List<SCProductVersion> findAll(int start, int end,
1082                    OrderByComparator orderByComparator) throws SystemException {
1083                    FinderPath finderPath = null;
1084                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
1085    
1086                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1087                                    (orderByComparator == null)) {
1088                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1089                            finderArgs = FINDER_ARGS_EMPTY;
1090                    }
1091                    else {
1092                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1093                            finderArgs = new Object[] { start, end, orderByComparator };
1094                    }
1095    
1096                    List<SCProductVersion> list = (List<SCProductVersion>)FinderCacheUtil.getResult(finderPath,
1097                                    finderArgs, this);
1098    
1099                    if (list == null) {
1100                            StringBundler query = null;
1101                            String sql = null;
1102    
1103                            if (orderByComparator != null) {
1104                                    query = new StringBundler(2 +
1105                                                    (orderByComparator.getOrderByFields().length * 3));
1106    
1107                                    query.append(_SQL_SELECT_SCPRODUCTVERSION);
1108    
1109                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1110                                            orderByComparator);
1111    
1112                                    sql = query.toString();
1113                            }
1114                            else {
1115                                    sql = _SQL_SELECT_SCPRODUCTVERSION.concat(SCProductVersionModelImpl.ORDER_BY_JPQL);
1116                            }
1117    
1118                            Session session = null;
1119    
1120                            try {
1121                                    session = openSession();
1122    
1123                                    Query q = session.createQuery(sql);
1124    
1125                                    if (orderByComparator == null) {
1126                                            list = (List<SCProductVersion>)QueryUtil.list(q,
1127                                                            getDialect(), start, end, false);
1128    
1129                                            Collections.sort(list);
1130                                    }
1131                                    else {
1132                                            list = (List<SCProductVersion>)QueryUtil.list(q,
1133                                                            getDialect(), start, end);
1134                                    }
1135                            }
1136                            catch (Exception e) {
1137                                    throw processException(e);
1138                            }
1139                            finally {
1140                                    if (list == null) {
1141                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1142                                    }
1143                                    else {
1144                                            cacheResult(list);
1145    
1146                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1147                                    }
1148    
1149                                    closeSession(session);
1150                            }
1151                    }
1152    
1153                    return list;
1154            }
1155    
1156            /**
1157             * Removes all the s c product versions where productEntryId = &#63; from the database.
1158             *
1159             * @param productEntryId the product entry ID
1160             * @throws SystemException if a system exception occurred
1161             */
1162            public void removeByProductEntryId(long productEntryId)
1163                    throws SystemException {
1164                    for (SCProductVersion scProductVersion : findByProductEntryId(
1165                                    productEntryId)) {
1166                            scProductVersionPersistence.remove(scProductVersion);
1167                    }
1168            }
1169    
1170            /**
1171             * Removes the s c product version where directDownloadURL = &#63; from the database.
1172             *
1173             * @param directDownloadURL the direct download u r l
1174             * @throws SystemException if a system exception occurred
1175             */
1176            public void removeByDirectDownloadURL(String directDownloadURL)
1177                    throws NoSuchProductVersionException, SystemException {
1178                    SCProductVersion scProductVersion = findByDirectDownloadURL(directDownloadURL);
1179    
1180                    scProductVersionPersistence.remove(scProductVersion);
1181            }
1182    
1183            /**
1184             * Removes all the s c product versions from the database.
1185             *
1186             * @throws SystemException if a system exception occurred
1187             */
1188            public void removeAll() throws SystemException {
1189                    for (SCProductVersion scProductVersion : findAll()) {
1190                            scProductVersionPersistence.remove(scProductVersion);
1191                    }
1192            }
1193    
1194            /**
1195             * Returns the number of s c product versions where productEntryId = &#63;.
1196             *
1197             * @param productEntryId the product entry ID
1198             * @return the number of matching s c product versions
1199             * @throws SystemException if a system exception occurred
1200             */
1201            public int countByProductEntryId(long productEntryId)
1202                    throws SystemException {
1203                    Object[] finderArgs = new Object[] { productEntryId };
1204    
1205                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PRODUCTENTRYID,
1206                                    finderArgs, this);
1207    
1208                    if (count == null) {
1209                            StringBundler query = new StringBundler(2);
1210    
1211                            query.append(_SQL_COUNT_SCPRODUCTVERSION_WHERE);
1212    
1213                            query.append(_FINDER_COLUMN_PRODUCTENTRYID_PRODUCTENTRYID_2);
1214    
1215                            String sql = query.toString();
1216    
1217                            Session session = null;
1218    
1219                            try {
1220                                    session = openSession();
1221    
1222                                    Query q = session.createQuery(sql);
1223    
1224                                    QueryPos qPos = QueryPos.getInstance(q);
1225    
1226                                    qPos.add(productEntryId);
1227    
1228                                    count = (Long)q.uniqueResult();
1229                            }
1230                            catch (Exception e) {
1231                                    throw processException(e);
1232                            }
1233                            finally {
1234                                    if (count == null) {
1235                                            count = Long.valueOf(0);
1236                                    }
1237    
1238                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PRODUCTENTRYID,
1239                                            finderArgs, count);
1240    
1241                                    closeSession(session);
1242                            }
1243                    }
1244    
1245                    return count.intValue();
1246            }
1247    
1248            /**
1249             * Returns the number of s c product versions where directDownloadURL = &#63;.
1250             *
1251             * @param directDownloadURL the direct download u r l
1252             * @return the number of matching s c product versions
1253             * @throws SystemException if a system exception occurred
1254             */
1255            public int countByDirectDownloadURL(String directDownloadURL)
1256                    throws SystemException {
1257                    Object[] finderArgs = new Object[] { directDownloadURL };
1258    
1259                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_DIRECTDOWNLOADURL,
1260                                    finderArgs, this);
1261    
1262                    if (count == null) {
1263                            StringBundler query = new StringBundler(2);
1264    
1265                            query.append(_SQL_COUNT_SCPRODUCTVERSION_WHERE);
1266    
1267                            if (directDownloadURL == null) {
1268                                    query.append(_FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_1);
1269                            }
1270                            else {
1271                                    if (directDownloadURL.equals(StringPool.BLANK)) {
1272                                            query.append(_FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_3);
1273                                    }
1274                                    else {
1275                                            query.append(_FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_2);
1276                                    }
1277                            }
1278    
1279                            String sql = query.toString();
1280    
1281                            Session session = null;
1282    
1283                            try {
1284                                    session = openSession();
1285    
1286                                    Query q = session.createQuery(sql);
1287    
1288                                    QueryPos qPos = QueryPos.getInstance(q);
1289    
1290                                    if (directDownloadURL != null) {
1291                                            qPos.add(directDownloadURL);
1292                                    }
1293    
1294                                    count = (Long)q.uniqueResult();
1295                            }
1296                            catch (Exception e) {
1297                                    throw processException(e);
1298                            }
1299                            finally {
1300                                    if (count == null) {
1301                                            count = Long.valueOf(0);
1302                                    }
1303    
1304                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_DIRECTDOWNLOADURL,
1305                                            finderArgs, count);
1306    
1307                                    closeSession(session);
1308                            }
1309                    }
1310    
1311                    return count.intValue();
1312            }
1313    
1314            /**
1315             * Returns the number of s c product versions.
1316             *
1317             * @return the number of s c product versions
1318             * @throws SystemException if a system exception occurred
1319             */
1320            public int countAll() throws SystemException {
1321                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1322                                    FINDER_ARGS_EMPTY, this);
1323    
1324                    if (count == null) {
1325                            Session session = null;
1326    
1327                            try {
1328                                    session = openSession();
1329    
1330                                    Query q = session.createQuery(_SQL_COUNT_SCPRODUCTVERSION);
1331    
1332                                    count = (Long)q.uniqueResult();
1333                            }
1334                            catch (Exception e) {
1335                                    throw processException(e);
1336                            }
1337                            finally {
1338                                    if (count == null) {
1339                                            count = Long.valueOf(0);
1340                                    }
1341    
1342                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1343                                            FINDER_ARGS_EMPTY, count);
1344    
1345                                    closeSession(session);
1346                            }
1347                    }
1348    
1349                    return count.intValue();
1350            }
1351    
1352            /**
1353             * Returns all the s c framework versions associated with the s c product version.
1354             *
1355             * @param pk the primary key of the s c product version
1356             * @return the s c framework versions associated with the s c product version
1357             * @throws SystemException if a system exception occurred
1358             */
1359            public List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> getSCFrameworkVersions(
1360                    long pk) throws SystemException {
1361                    return getSCFrameworkVersions(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1362            }
1363    
1364            /**
1365             * Returns a range of all the s c framework versions associated with the s c product version.
1366             *
1367             * <p>
1368             * 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.
1369             * </p>
1370             *
1371             * @param pk the primary key of the s c product version
1372             * @param start the lower bound of the range of s c product versions
1373             * @param end the upper bound of the range of s c product versions (not inclusive)
1374             * @return the range of s c framework versions associated with the s c product version
1375             * @throws SystemException if a system exception occurred
1376             */
1377            public List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> getSCFrameworkVersions(
1378                    long pk, int start, int end) throws SystemException {
1379                    return getSCFrameworkVersions(pk, start, end, null);
1380            }
1381    
1382            public static final FinderPath FINDER_PATH_GET_SCFRAMEWORKVERSIONS = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
1383                            SCProductVersionModelImpl.FINDER_CACHE_ENABLED_SCFRAMEWORKVERSI_SCPRODUCTVERS,
1384                            com.liferay.portlet.softwarecatalog.model.impl.SCFrameworkVersionImpl.class,
1385                            SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME,
1386                            "getSCFrameworkVersions",
1387                            new String[] {
1388                                    Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1389                                    "com.liferay.portal.kernel.util.OrderByComparator"
1390                            });
1391    
1392            /**
1393             * Returns an ordered range of all the s c framework versions associated with the s c product version.
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 pk the primary key of the s c product version
1400             * @param start the lower bound of the range of s c product versions
1401             * @param end the upper bound of the range of s c product versions (not inclusive)
1402             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1403             * @return the ordered range of s c framework versions associated with the s c product version
1404             * @throws SystemException if a system exception occurred
1405             */
1406            public List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> getSCFrameworkVersions(
1407                    long pk, int start, int end, OrderByComparator orderByComparator)
1408                    throws SystemException {
1409                    Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
1410    
1411                    List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> list = (List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion>)FinderCacheUtil.getResult(FINDER_PATH_GET_SCFRAMEWORKVERSIONS,
1412                                    finderArgs, this);
1413    
1414                    if (list == null) {
1415                            Session session = null;
1416    
1417                            try {
1418                                    session = openSession();
1419    
1420                                    String sql = null;
1421    
1422                                    if (orderByComparator != null) {
1423                                            sql = _SQL_GETSCFRAMEWORKVERSIONS.concat(ORDER_BY_CLAUSE)
1424                                                                                                             .concat(orderByComparator.getOrderBy());
1425                                    }
1426                                    else {
1427                                            sql = _SQL_GETSCFRAMEWORKVERSIONS.concat(com.liferay.portlet.softwarecatalog.model.impl.SCFrameworkVersionModelImpl.ORDER_BY_SQL);
1428                                    }
1429    
1430                                    SQLQuery q = session.createSQLQuery(sql);
1431    
1432                                    q.addEntity("SCFrameworkVersion",
1433                                            com.liferay.portlet.softwarecatalog.model.impl.SCFrameworkVersionImpl.class);
1434    
1435                                    QueryPos qPos = QueryPos.getInstance(q);
1436    
1437                                    qPos.add(pk);
1438    
1439                                    list = (List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion>)QueryUtil.list(q,
1440                                                    getDialect(), start, end);
1441                            }
1442                            catch (Exception e) {
1443                                    throw processException(e);
1444                            }
1445                            finally {
1446                                    if (list == null) {
1447                                            FinderCacheUtil.removeResult(FINDER_PATH_GET_SCFRAMEWORKVERSIONS,
1448                                                    finderArgs);
1449                                    }
1450                                    else {
1451                                            scFrameworkVersionPersistence.cacheResult(list);
1452    
1453                                            FinderCacheUtil.putResult(FINDER_PATH_GET_SCFRAMEWORKVERSIONS,
1454                                                    finderArgs, list);
1455                                    }
1456    
1457                                    closeSession(session);
1458                            }
1459                    }
1460    
1461                    return list;
1462            }
1463    
1464            public static final FinderPath FINDER_PATH_GET_SCFRAMEWORKVERSIONS_SIZE = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
1465                            SCProductVersionModelImpl.FINDER_CACHE_ENABLED_SCFRAMEWORKVERSI_SCPRODUCTVERS,
1466                            Long.class,
1467                            SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME,
1468                            "getSCFrameworkVersionsSize", new String[] { Long.class.getName() });
1469    
1470            /**
1471             * Returns the number of s c framework versions associated with the s c product version.
1472             *
1473             * @param pk the primary key of the s c product version
1474             * @return the number of s c framework versions associated with the s c product version
1475             * @throws SystemException if a system exception occurred
1476             */
1477            public int getSCFrameworkVersionsSize(long pk) throws SystemException {
1478                    Object[] finderArgs = new Object[] { pk };
1479    
1480                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_SCFRAMEWORKVERSIONS_SIZE,
1481                                    finderArgs, this);
1482    
1483                    if (count == null) {
1484                            Session session = null;
1485    
1486                            try {
1487                                    session = openSession();
1488    
1489                                    SQLQuery q = session.createSQLQuery(_SQL_GETSCFRAMEWORKVERSIONSSIZE);
1490    
1491                                    q.addScalar(COUNT_COLUMN_NAME,
1492                                            com.liferay.portal.kernel.dao.orm.Type.LONG);
1493    
1494                                    QueryPos qPos = QueryPos.getInstance(q);
1495    
1496                                    qPos.add(pk);
1497    
1498                                    count = (Long)q.uniqueResult();
1499                            }
1500                            catch (Exception e) {
1501                                    throw processException(e);
1502                            }
1503                            finally {
1504                                    if (count == null) {
1505                                            count = Long.valueOf(0);
1506                                    }
1507    
1508                                    FinderCacheUtil.putResult(FINDER_PATH_GET_SCFRAMEWORKVERSIONS_SIZE,
1509                                            finderArgs, count);
1510    
1511                                    closeSession(session);
1512                            }
1513                    }
1514    
1515                    return count.intValue();
1516            }
1517    
1518            public static final FinderPath FINDER_PATH_CONTAINS_SCFRAMEWORKVERSION = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
1519                            SCProductVersionModelImpl.FINDER_CACHE_ENABLED_SCFRAMEWORKVERSI_SCPRODUCTVERS,
1520                            Boolean.class,
1521                            SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME,
1522                            "containsSCFrameworkVersion",
1523                            new String[] { Long.class.getName(), Long.class.getName() });
1524    
1525            /**
1526             * Returns <code>true</code> if the s c framework version is associated with the s c product version.
1527             *
1528             * @param pk the primary key of the s c product version
1529             * @param scFrameworkVersionPK the primary key of the s c framework version
1530             * @return <code>true</code> if the s c framework version is associated with the s c product version; <code>false</code> otherwise
1531             * @throws SystemException if a system exception occurred
1532             */
1533            public boolean containsSCFrameworkVersion(long pk, long scFrameworkVersionPK)
1534                    throws SystemException {
1535                    Object[] finderArgs = new Object[] { pk, scFrameworkVersionPK };
1536    
1537                    Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_SCFRAMEWORKVERSION,
1538                                    finderArgs, this);
1539    
1540                    if (value == null) {
1541                            try {
1542                                    value = Boolean.valueOf(containsSCFrameworkVersion.contains(
1543                                                            pk, scFrameworkVersionPK));
1544                            }
1545                            catch (Exception e) {
1546                                    throw processException(e);
1547                            }
1548                            finally {
1549                                    if (value == null) {
1550                                            value = Boolean.FALSE;
1551                                    }
1552    
1553                                    FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_SCFRAMEWORKVERSION,
1554                                            finderArgs, value);
1555                            }
1556                    }
1557    
1558                    return value.booleanValue();
1559            }
1560    
1561            /**
1562             * Returns <code>true</code> if the s c product version has any s c framework versions associated with it.
1563             *
1564             * @param pk the primary key of the s c product version to check for associations with s c framework versions
1565             * @return <code>true</code> if the s c product version has any s c framework versions associated with it; <code>false</code> otherwise
1566             * @throws SystemException if a system exception occurred
1567             */
1568            public boolean containsSCFrameworkVersions(long pk)
1569                    throws SystemException {
1570                    if (getSCFrameworkVersionsSize(pk) > 0) {
1571                            return true;
1572                    }
1573                    else {
1574                            return false;
1575                    }
1576            }
1577    
1578            /**
1579             * Adds an association between the s c product version and the s c framework version. Also notifies the appropriate model listeners and clears the mapping table finder cache.
1580             *
1581             * @param pk the primary key of the s c product version
1582             * @param scFrameworkVersionPK the primary key of the s c framework version
1583             * @throws SystemException if a system exception occurred
1584             */
1585            public void addSCFrameworkVersion(long pk, long scFrameworkVersionPK)
1586                    throws SystemException {
1587                    try {
1588                            addSCFrameworkVersion.add(pk, scFrameworkVersionPK);
1589                    }
1590                    catch (Exception e) {
1591                            throw processException(e);
1592                    }
1593                    finally {
1594                            FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1595                    }
1596            }
1597    
1598            /**
1599             * Adds an association between the s c product version and the s c framework version. Also notifies the appropriate model listeners and clears the mapping table finder cache.
1600             *
1601             * @param pk the primary key of the s c product version
1602             * @param scFrameworkVersion the s c framework version
1603             * @throws SystemException if a system exception occurred
1604             */
1605            public void addSCFrameworkVersion(long pk,
1606                    com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion)
1607                    throws SystemException {
1608                    try {
1609                            addSCFrameworkVersion.add(pk, scFrameworkVersion.getPrimaryKey());
1610                    }
1611                    catch (Exception e) {
1612                            throw processException(e);
1613                    }
1614                    finally {
1615                            FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1616                    }
1617            }
1618    
1619            /**
1620             * Adds an association between the s c product version and the s c framework versions. Also notifies the appropriate model listeners and clears the mapping table finder cache.
1621             *
1622             * @param pk the primary key of the s c product version
1623             * @param scFrameworkVersionPKs the primary keys of the s c framework versions
1624             * @throws SystemException if a system exception occurred
1625             */
1626            public void addSCFrameworkVersions(long pk, long[] scFrameworkVersionPKs)
1627                    throws SystemException {
1628                    try {
1629                            for (long scFrameworkVersionPK : scFrameworkVersionPKs) {
1630                                    addSCFrameworkVersion.add(pk, scFrameworkVersionPK);
1631                            }
1632                    }
1633                    catch (Exception e) {
1634                            throw processException(e);
1635                    }
1636                    finally {
1637                            FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1638                    }
1639            }
1640    
1641            /**
1642             * Adds an association between the s c product version and the s c framework versions. Also notifies the appropriate model listeners and clears the mapping table finder cache.
1643             *
1644             * @param pk the primary key of the s c product version
1645             * @param scFrameworkVersions the s c framework versions
1646             * @throws SystemException if a system exception occurred
1647             */
1648            public void addSCFrameworkVersions(long pk,
1649                    List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> scFrameworkVersions)
1650                    throws SystemException {
1651                    try {
1652                            for (com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion : scFrameworkVersions) {
1653                                    addSCFrameworkVersion.add(pk, scFrameworkVersion.getPrimaryKey());
1654                            }
1655                    }
1656                    catch (Exception e) {
1657                            throw processException(e);
1658                    }
1659                    finally {
1660                            FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1661                    }
1662            }
1663    
1664            /**
1665             * Clears all associations between the s c product version and its s c framework versions. Also notifies the appropriate model listeners and clears the mapping table finder cache.
1666             *
1667             * @param pk the primary key of the s c product version to clear the associated s c framework versions from
1668             * @throws SystemException if a system exception occurred
1669             */
1670            public void clearSCFrameworkVersions(long pk) throws SystemException {
1671                    try {
1672                            clearSCFrameworkVersions.clear(pk);
1673                    }
1674                    catch (Exception e) {
1675                            throw processException(e);
1676                    }
1677                    finally {
1678                            FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1679                    }
1680            }
1681    
1682            /**
1683             * Removes the association between the s c product version and the s c framework version. Also notifies the appropriate model listeners and clears the mapping table finder cache.
1684             *
1685             * @param pk the primary key of the s c product version
1686             * @param scFrameworkVersionPK the primary key of the s c framework version
1687             * @throws SystemException if a system exception occurred
1688             */
1689            public void removeSCFrameworkVersion(long pk, long scFrameworkVersionPK)
1690                    throws SystemException {
1691                    try {
1692                            removeSCFrameworkVersion.remove(pk, scFrameworkVersionPK);
1693                    }
1694                    catch (Exception e) {
1695                            throw processException(e);
1696                    }
1697                    finally {
1698                            FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1699                    }
1700            }
1701    
1702            /**
1703             * Removes the association between the s c product version and the s c framework version. Also notifies the appropriate model listeners and clears the mapping table finder cache.
1704             *
1705             * @param pk the primary key of the s c product version
1706             * @param scFrameworkVersion the s c framework version
1707             * @throws SystemException if a system exception occurred
1708             */
1709            public void removeSCFrameworkVersion(long pk,
1710                    com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion)
1711                    throws SystemException {
1712                    try {
1713                            removeSCFrameworkVersion.remove(pk,
1714                                    scFrameworkVersion.getPrimaryKey());
1715                    }
1716                    catch (Exception e) {
1717                            throw processException(e);
1718                    }
1719                    finally {
1720                            FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1721                    }
1722            }
1723    
1724            /**
1725             * Removes the association between the s c product version and the s c framework versions. Also notifies the appropriate model listeners and clears the mapping table finder cache.
1726             *
1727             * @param pk the primary key of the s c product version
1728             * @param scFrameworkVersionPKs the primary keys of the s c framework versions
1729             * @throws SystemException if a system exception occurred
1730             */
1731            public void removeSCFrameworkVersions(long pk, long[] scFrameworkVersionPKs)
1732                    throws SystemException {
1733                    try {
1734                            for (long scFrameworkVersionPK : scFrameworkVersionPKs) {
1735                                    removeSCFrameworkVersion.remove(pk, scFrameworkVersionPK);
1736                            }
1737                    }
1738                    catch (Exception e) {
1739                            throw processException(e);
1740                    }
1741                    finally {
1742                            FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1743                    }
1744            }
1745    
1746            /**
1747             * Removes the association between the s c product version and the s c framework versions. Also notifies the appropriate model listeners and clears the mapping table finder cache.
1748             *
1749             * @param pk the primary key of the s c product version
1750             * @param scFrameworkVersions the s c framework versions
1751             * @throws SystemException if a system exception occurred
1752             */
1753            public void removeSCFrameworkVersions(long pk,
1754                    List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> scFrameworkVersions)
1755                    throws SystemException {
1756                    try {
1757                            for (com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion : scFrameworkVersions) {
1758                                    removeSCFrameworkVersion.remove(pk,
1759                                            scFrameworkVersion.getPrimaryKey());
1760                            }
1761                    }
1762                    catch (Exception e) {
1763                            throw processException(e);
1764                    }
1765                    finally {
1766                            FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1767                    }
1768            }
1769    
1770            /**
1771             * Sets the s c framework versions associated with the s c product version, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
1772             *
1773             * @param pk the primary key of the s c product version
1774             * @param scFrameworkVersionPKs the primary keys of the s c framework versions to be associated with the s c product version
1775             * @throws SystemException if a system exception occurred
1776             */
1777            public void setSCFrameworkVersions(long pk, long[] scFrameworkVersionPKs)
1778                    throws SystemException {
1779                    try {
1780                            Set<Long> scFrameworkVersionPKSet = SetUtil.fromArray(scFrameworkVersionPKs);
1781    
1782                            List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> scFrameworkVersions =
1783                                    getSCFrameworkVersions(pk);
1784    
1785                            for (com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion : scFrameworkVersions) {
1786                                    if (!scFrameworkVersionPKSet.remove(
1787                                                            scFrameworkVersion.getPrimaryKey())) {
1788                                            removeSCFrameworkVersion.remove(pk,
1789                                                    scFrameworkVersion.getPrimaryKey());
1790                                    }
1791                            }
1792    
1793                            for (Long scFrameworkVersionPK : scFrameworkVersionPKSet) {
1794                                    addSCFrameworkVersion.add(pk, scFrameworkVersionPK);
1795                            }
1796                    }
1797                    catch (Exception e) {
1798                            throw processException(e);
1799                    }
1800                    finally {
1801                            FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1802                    }
1803            }
1804    
1805            /**
1806             * Sets the s c framework versions associated with the s c product version, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
1807             *
1808             * @param pk the primary key of the s c product version
1809             * @param scFrameworkVersions the s c framework versions to be associated with the s c product version
1810             * @throws SystemException if a system exception occurred
1811             */
1812            public void setSCFrameworkVersions(long pk,
1813                    List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> scFrameworkVersions)
1814                    throws SystemException {
1815                    try {
1816                            long[] scFrameworkVersionPKs = new long[scFrameworkVersions.size()];
1817    
1818                            for (int i = 0; i < scFrameworkVersions.size(); i++) {
1819                                    com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion =
1820                                            scFrameworkVersions.get(i);
1821    
1822                                    scFrameworkVersionPKs[i] = scFrameworkVersion.getPrimaryKey();
1823                            }
1824    
1825                            setSCFrameworkVersions(pk, scFrameworkVersionPKs);
1826                    }
1827                    catch (Exception e) {
1828                            throw processException(e);
1829                    }
1830                    finally {
1831                            FinderCacheUtil.clearCache(SCProductVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1832                    }
1833            }
1834    
1835            /**
1836             * Initializes the s c product version persistence.
1837             */
1838            public void afterPropertiesSet() {
1839                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1840                                            com.liferay.portal.util.PropsUtil.get(
1841                                                    "value.object.listener.com.liferay.portlet.softwarecatalog.model.SCProductVersion")));
1842    
1843                    if (listenerClassNames.length > 0) {
1844                            try {
1845                                    List<ModelListener<SCProductVersion>> listenersList = new ArrayList<ModelListener<SCProductVersion>>();
1846    
1847                                    for (String listenerClassName : listenerClassNames) {
1848                                            listenersList.add((ModelListener<SCProductVersion>)InstanceFactory.newInstance(
1849                                                            listenerClassName));
1850                                    }
1851    
1852                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1853                            }
1854                            catch (Exception e) {
1855                                    _log.error(e);
1856                            }
1857                    }
1858    
1859                    containsSCFrameworkVersion = new ContainsSCFrameworkVersion(this);
1860    
1861                    addSCFrameworkVersion = new AddSCFrameworkVersion(this);
1862                    clearSCFrameworkVersions = new ClearSCFrameworkVersions(this);
1863                    removeSCFrameworkVersion = new RemoveSCFrameworkVersion(this);
1864            }
1865    
1866            public void destroy() {
1867                    EntityCacheUtil.removeCache(SCProductVersionImpl.class.getName());
1868                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1869                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1870            }
1871    
1872            @BeanReference(type = SCFrameworkVersionPersistence.class)
1873            protected SCFrameworkVersionPersistence scFrameworkVersionPersistence;
1874            @BeanReference(type = SCLicensePersistence.class)
1875            protected SCLicensePersistence scLicensePersistence;
1876            @BeanReference(type = SCProductEntryPersistence.class)
1877            protected SCProductEntryPersistence scProductEntryPersistence;
1878            @BeanReference(type = SCProductScreenshotPersistence.class)
1879            protected SCProductScreenshotPersistence scProductScreenshotPersistence;
1880            @BeanReference(type = SCProductVersionPersistence.class)
1881            protected SCProductVersionPersistence scProductVersionPersistence;
1882            @BeanReference(type = ResourcePersistence.class)
1883            protected ResourcePersistence resourcePersistence;
1884            @BeanReference(type = UserPersistence.class)
1885            protected UserPersistence userPersistence;
1886            protected ContainsSCFrameworkVersion containsSCFrameworkVersion;
1887            protected AddSCFrameworkVersion addSCFrameworkVersion;
1888            protected ClearSCFrameworkVersions clearSCFrameworkVersions;
1889            protected RemoveSCFrameworkVersion removeSCFrameworkVersion;
1890    
1891            protected class ContainsSCFrameworkVersion {
1892                    protected ContainsSCFrameworkVersion(
1893                            SCProductVersionPersistenceImpl persistenceImpl) {
1894                            super();
1895    
1896                            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
1897                                            _SQL_CONTAINSSCFRAMEWORKVERSION,
1898                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
1899                                            RowMapper.COUNT);
1900                    }
1901    
1902                    protected boolean contains(long productVersionId,
1903                            long frameworkVersionId) {
1904                            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
1905                                                    new Long(productVersionId), new Long(frameworkVersionId)
1906                                            });
1907    
1908                            if (results.size() > 0) {
1909                                    Integer count = results.get(0);
1910    
1911                                    if (count.intValue() > 0) {
1912                                            return true;
1913                                    }
1914                            }
1915    
1916                            return false;
1917                    }
1918    
1919                    private MappingSqlQuery<Integer> _mappingSqlQuery;
1920            }
1921    
1922            protected class AddSCFrameworkVersion {
1923                    protected AddSCFrameworkVersion(
1924                            SCProductVersionPersistenceImpl persistenceImpl) {
1925                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
1926                                            "INSERT INTO SCFrameworkVersi_SCProductVers (productVersionId, frameworkVersionId) VALUES (?, ?)",
1927                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
1928                            _persistenceImpl = persistenceImpl;
1929                    }
1930    
1931                    protected void add(long productVersionId, long frameworkVersionId)
1932                            throws SystemException {
1933                            if (!_persistenceImpl.containsSCFrameworkVersion.contains(
1934                                                    productVersionId, frameworkVersionId)) {
1935                                    ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion>[] scFrameworkVersionListeners =
1936                                            scFrameworkVersionPersistence.getListeners();
1937    
1938                                    for (ModelListener<SCProductVersion> listener : listeners) {
1939                                            listener.onBeforeAddAssociation(productVersionId,
1940                                                    com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion.class.getName(),
1941                                                    frameworkVersionId);
1942                                    }
1943    
1944                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> listener : scFrameworkVersionListeners) {
1945                                            listener.onBeforeAddAssociation(frameworkVersionId,
1946                                                    SCProductVersion.class.getName(), productVersionId);
1947                                    }
1948    
1949                                    _sqlUpdate.update(new Object[] {
1950                                                    new Long(productVersionId), new Long(frameworkVersionId)
1951                                            });
1952    
1953                                    for (ModelListener<SCProductVersion> listener : listeners) {
1954                                            listener.onAfterAddAssociation(productVersionId,
1955                                                    com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion.class.getName(),
1956                                                    frameworkVersionId);
1957                                    }
1958    
1959                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> listener : scFrameworkVersionListeners) {
1960                                            listener.onAfterAddAssociation(frameworkVersionId,
1961                                                    SCProductVersion.class.getName(), productVersionId);
1962                                    }
1963                            }
1964                    }
1965    
1966                    private SqlUpdate _sqlUpdate;
1967                    private SCProductVersionPersistenceImpl _persistenceImpl;
1968            }
1969    
1970            protected class ClearSCFrameworkVersions {
1971                    protected ClearSCFrameworkVersions(
1972                            SCProductVersionPersistenceImpl persistenceImpl) {
1973                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
1974                                            "DELETE FROM SCFrameworkVersi_SCProductVers WHERE productVersionId = ?",
1975                                            new int[] { java.sql.Types.BIGINT });
1976                    }
1977    
1978                    protected void clear(long productVersionId) throws SystemException {
1979                            ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion>[] scFrameworkVersionListeners =
1980                                    scFrameworkVersionPersistence.getListeners();
1981    
1982                            List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> scFrameworkVersions =
1983                                    null;
1984    
1985                            if ((listeners.length > 0) ||
1986                                            (scFrameworkVersionListeners.length > 0)) {
1987                                    scFrameworkVersions = getSCFrameworkVersions(productVersionId);
1988    
1989                                    for (com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion : scFrameworkVersions) {
1990                                            for (ModelListener<SCProductVersion> listener : listeners) {
1991                                                    listener.onBeforeRemoveAssociation(productVersionId,
1992                                                            com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion.class.getName(),
1993                                                            scFrameworkVersion.getPrimaryKey());
1994                                            }
1995    
1996                                            for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> listener : scFrameworkVersionListeners) {
1997                                                    listener.onBeforeRemoveAssociation(scFrameworkVersion.getPrimaryKey(),
1998                                                            SCProductVersion.class.getName(), productVersionId);
1999                                            }
2000                                    }
2001                            }
2002    
2003                            _sqlUpdate.update(new Object[] { new Long(productVersionId) });
2004    
2005                            if ((listeners.length > 0) ||
2006                                            (scFrameworkVersionListeners.length > 0)) {
2007                                    for (com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion : scFrameworkVersions) {
2008                                            for (ModelListener<SCProductVersion> listener : listeners) {
2009                                                    listener.onAfterRemoveAssociation(productVersionId,
2010                                                            com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion.class.getName(),
2011                                                            scFrameworkVersion.getPrimaryKey());
2012                                            }
2013    
2014                                            for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> listener : scFrameworkVersionListeners) {
2015                                                    listener.onAfterRemoveAssociation(scFrameworkVersion.getPrimaryKey(),
2016                                                            SCProductVersion.class.getName(), productVersionId);
2017                                            }
2018                                    }
2019                            }
2020                    }
2021    
2022                    private SqlUpdate _sqlUpdate;
2023            }
2024    
2025            protected class RemoveSCFrameworkVersion {
2026                    protected RemoveSCFrameworkVersion(
2027                            SCProductVersionPersistenceImpl persistenceImpl) {
2028                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2029                                            "DELETE FROM SCFrameworkVersi_SCProductVers WHERE productVersionId = ? AND frameworkVersionId = ?",
2030                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2031                            _persistenceImpl = persistenceImpl;
2032                    }
2033    
2034                    protected void remove(long productVersionId, long frameworkVersionId)
2035                            throws SystemException {
2036                            if (_persistenceImpl.containsSCFrameworkVersion.contains(
2037                                                    productVersionId, frameworkVersionId)) {
2038                                    ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion>[] scFrameworkVersionListeners =
2039                                            scFrameworkVersionPersistence.getListeners();
2040    
2041                                    for (ModelListener<SCProductVersion> listener : listeners) {
2042                                            listener.onBeforeRemoveAssociation(productVersionId,
2043                                                    com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion.class.getName(),
2044                                                    frameworkVersionId);
2045                                    }
2046    
2047                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> listener : scFrameworkVersionListeners) {
2048                                            listener.onBeforeRemoveAssociation(frameworkVersionId,
2049                                                    SCProductVersion.class.getName(), productVersionId);
2050                                    }
2051    
2052                                    _sqlUpdate.update(new Object[] {
2053                                                    new Long(productVersionId), new Long(frameworkVersionId)
2054                                            });
2055    
2056                                    for (ModelListener<SCProductVersion> listener : listeners) {
2057                                            listener.onAfterRemoveAssociation(productVersionId,
2058                                                    com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion.class.getName(),
2059                                                    frameworkVersionId);
2060                                    }
2061    
2062                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> listener : scFrameworkVersionListeners) {
2063                                            listener.onAfterRemoveAssociation(frameworkVersionId,
2064                                                    SCProductVersion.class.getName(), productVersionId);
2065                                    }
2066                            }
2067                    }
2068    
2069                    private SqlUpdate _sqlUpdate;
2070                    private SCProductVersionPersistenceImpl _persistenceImpl;
2071            }
2072    
2073            private static final String _SQL_SELECT_SCPRODUCTVERSION = "SELECT scProductVersion FROM SCProductVersion scProductVersion";
2074            private static final String _SQL_SELECT_SCPRODUCTVERSION_WHERE = "SELECT scProductVersion FROM SCProductVersion scProductVersion WHERE ";
2075            private static final String _SQL_COUNT_SCPRODUCTVERSION = "SELECT COUNT(scProductVersion) FROM SCProductVersion scProductVersion";
2076            private static final String _SQL_COUNT_SCPRODUCTVERSION_WHERE = "SELECT COUNT(scProductVersion) FROM SCProductVersion scProductVersion WHERE ";
2077            private static final String _SQL_GETSCFRAMEWORKVERSIONS = "SELECT {SCFrameworkVersion.*} FROM SCFrameworkVersion INNER JOIN SCFrameworkVersi_SCProductVers ON (SCFrameworkVersi_SCProductVers.frameworkVersionId = SCFrameworkVersion.frameworkVersionId) WHERE (SCFrameworkVersi_SCProductVers.productVersionId = ?)";
2078            private static final String _SQL_GETSCFRAMEWORKVERSIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCFrameworkVersi_SCProductVers WHERE productVersionId = ?";
2079            private static final String _SQL_CONTAINSSCFRAMEWORKVERSION = "SELECT COUNT(*) AS COUNT_VALUE FROM SCFrameworkVersi_SCProductVers WHERE productVersionId = ? AND frameworkVersionId = ?";
2080            private static final String _FINDER_COLUMN_PRODUCTENTRYID_PRODUCTENTRYID_2 = "scProductVersion.productEntryId = ?";
2081            private static final String _FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_1 =
2082                    "scProductVersion.directDownloadURL IS NULL";
2083            private static final String _FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_2 =
2084                    "lower(scProductVersion.directDownloadURL) = lower(CAST_TEXT(?))";
2085            private static final String _FINDER_COLUMN_DIRECTDOWNLOADURL_DIRECTDOWNLOADURL_3 =
2086                    "(scProductVersion.directDownloadURL IS NULL OR lower(scProductVersion.directDownloadURL) = lower(CAST_TEXT(?)))";
2087            private static final String _ORDER_BY_ENTITY_ALIAS = "scProductVersion.";
2088            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SCProductVersion exists with the primary key ";
2089            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SCProductVersion exists with the key {";
2090            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2091            private static Log _log = LogFactoryUtil.getLog(SCProductVersionPersistenceImpl.class);
2092            private static SCProductVersion _nullSCProductVersion = new SCProductVersionImpl() {
2093                            @Override
2094                            public Object clone() {
2095                                    return this;
2096                            }
2097    
2098                            @Override
2099                            public CacheModel<SCProductVersion> toCacheModel() {
2100                                    return _nullSCProductVersionCacheModel;
2101                            }
2102                    };
2103    
2104            private static CacheModel<SCProductVersion> _nullSCProductVersionCacheModel = new CacheModel<SCProductVersion>() {
2105                            public SCProductVersion toEntityModel() {
2106                                    return _nullSCProductVersion;
2107                            }
2108                    };
2109    }