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