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