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