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