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