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