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.jdbc.MappingSqlQuery;
020    import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
021    import com.liferay.portal.kernel.dao.jdbc.RowMapper;
022    import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
023    import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
024    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
025    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
026    import com.liferay.portal.kernel.dao.orm.FinderPath;
027    import com.liferay.portal.kernel.dao.orm.Query;
028    import com.liferay.portal.kernel.dao.orm.QueryPos;
029    import com.liferay.portal.kernel.dao.orm.QueryUtil;
030    import com.liferay.portal.kernel.dao.orm.SQLQuery;
031    import com.liferay.portal.kernel.dao.orm.Session;
032    import com.liferay.portal.kernel.exception.SystemException;
033    import com.liferay.portal.kernel.log.Log;
034    import com.liferay.portal.kernel.log.LogFactoryUtil;
035    import com.liferay.portal.kernel.util.GetterUtil;
036    import com.liferay.portal.kernel.util.InstanceFactory;
037    import com.liferay.portal.kernel.util.OrderByComparator;
038    import com.liferay.portal.kernel.util.SetUtil;
039    import com.liferay.portal.kernel.util.StringBundler;
040    import com.liferay.portal.kernel.util.StringPool;
041    import com.liferay.portal.kernel.util.StringUtil;
042    import com.liferay.portal.kernel.util.UnmodifiableList;
043    import com.liferay.portal.model.CacheModel;
044    import com.liferay.portal.model.ModelListener;
045    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
046    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
047    
048    import com.liferay.portlet.softwarecatalog.NoSuchFrameworkVersionException;
049    import com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion;
050    import com.liferay.portlet.softwarecatalog.model.impl.SCFrameworkVersionImpl;
051    import com.liferay.portlet.softwarecatalog.model.impl.SCFrameworkVersionModelImpl;
052    
053    import java.io.Serializable;
054    
055    import java.util.ArrayList;
056    import java.util.Collections;
057    import java.util.List;
058    import java.util.Set;
059    
060    /**
061     * The persistence implementation for the s c framework version service.
062     *
063     * <p>
064     * Caching information and settings can be found in <code>portal.properties</code>
065     * </p>
066     *
067     * @author Brian Wing Shun Chan
068     * @see SCFrameworkVersionPersistence
069     * @see SCFrameworkVersionUtil
070     * @generated
071     */
072    public class SCFrameworkVersionPersistenceImpl extends BasePersistenceImpl<SCFrameworkVersion>
073            implements SCFrameworkVersionPersistence {
074            /*
075             * NOTE FOR DEVELOPERS:
076             *
077             * Never modify or reference this class directly. Always use {@link SCFrameworkVersionUtil} to access the s c framework version persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
078             */
079            public static final String FINDER_CLASS_NAME_ENTITY = SCFrameworkVersionImpl.class.getName();
080            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
081                    ".List1";
082            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
083                    ".List2";
084            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
085                            SCFrameworkVersionModelImpl.FINDER_CACHE_ENABLED,
086                            SCFrameworkVersionImpl.class,
087                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
088            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
089                            SCFrameworkVersionModelImpl.FINDER_CACHE_ENABLED,
090                            SCFrameworkVersionImpl.class,
091                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
092            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
093                            SCFrameworkVersionModelImpl.FINDER_CACHE_ENABLED, Long.class,
094                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
095            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
096                            SCFrameworkVersionModelImpl.FINDER_CACHE_ENABLED,
097                            SCFrameworkVersionImpl.class,
098                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
099                            new String[] {
100                                    Long.class.getName(),
101                                    
102                            Integer.class.getName(), Integer.class.getName(),
103                                    OrderByComparator.class.getName()
104                            });
105            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
106                    new FinderPath(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
107                            SCFrameworkVersionModelImpl.FINDER_CACHE_ENABLED,
108                            SCFrameworkVersionImpl.class,
109                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
110                            new String[] { Long.class.getName() },
111                            SCFrameworkVersionModelImpl.GROUPID_COLUMN_BITMASK |
112                            SCFrameworkVersionModelImpl.NAME_COLUMN_BITMASK);
113            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
114                            SCFrameworkVersionModelImpl.FINDER_CACHE_ENABLED, Long.class,
115                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
116                            new String[] { Long.class.getName() });
117    
118            /**
119             * Returns all the s c framework versions where groupId = &#63;.
120             *
121             * @param groupId the group ID
122             * @return the matching s c framework versions
123             * @throws SystemException if a system exception occurred
124             */
125            public List<SCFrameworkVersion> findByGroupId(long groupId)
126                    throws SystemException {
127                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
128            }
129    
130            /**
131             * Returns a range of all the s c framework versions where groupId = &#63;.
132             *
133             * <p>
134             * 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.SCFrameworkVersionModelImpl}. 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.
135             * </p>
136             *
137             * @param groupId the group ID
138             * @param start the lower bound of the range of s c framework versions
139             * @param end the upper bound of the range of s c framework versions (not inclusive)
140             * @return the range of matching s c framework versions
141             * @throws SystemException if a system exception occurred
142             */
143            public List<SCFrameworkVersion> findByGroupId(long groupId, int start,
144                    int end) throws SystemException {
145                    return findByGroupId(groupId, start, end, null);
146            }
147    
148            /**
149             * Returns an ordered range of all the s c framework versions where groupId = &#63;.
150             *
151             * <p>
152             * 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.SCFrameworkVersionModelImpl}. 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.
153             * </p>
154             *
155             * @param groupId the group ID
156             * @param start the lower bound of the range of s c framework versions
157             * @param end the upper bound of the range of s c framework versions (not inclusive)
158             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
159             * @return the ordered range of matching s c framework versions
160             * @throws SystemException if a system exception occurred
161             */
162            public List<SCFrameworkVersion> findByGroupId(long groupId, int start,
163                    int end, OrderByComparator orderByComparator) 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_GROUPID;
172                            finderArgs = new Object[] { groupId };
173                    }
174                    else {
175                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
176                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
177                    }
178    
179                    List<SCFrameworkVersion> list = (List<SCFrameworkVersion>)FinderCacheUtil.getResult(finderPath,
180                                    finderArgs, this);
181    
182                    if ((list != null) && !list.isEmpty()) {
183                            for (SCFrameworkVersion scFrameworkVersion : list) {
184                                    if ((groupId != scFrameworkVersion.getGroupId())) {
185                                            list = null;
186    
187                                            break;
188                                    }
189                            }
190                    }
191    
192                    if (list == null) {
193                            StringBundler query = null;
194    
195                            if (orderByComparator != null) {
196                                    query = new StringBundler(3 +
197                                                    (orderByComparator.getOrderByFields().length * 3));
198                            }
199                            else {
200                                    query = new StringBundler(3);
201                            }
202    
203                            query.append(_SQL_SELECT_SCFRAMEWORKVERSION_WHERE);
204    
205                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
206    
207                            if (orderByComparator != null) {
208                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
209                                            orderByComparator);
210                            }
211                            else
212                             if (pagination) {
213                                    query.append(SCFrameworkVersionModelImpl.ORDER_BY_JPQL);
214                            }
215    
216                            String sql = query.toString();
217    
218                            Session session = null;
219    
220                            try {
221                                    session = openSession();
222    
223                                    Query q = session.createQuery(sql);
224    
225                                    QueryPos qPos = QueryPos.getInstance(q);
226    
227                                    qPos.add(groupId);
228    
229                                    if (!pagination) {
230                                            list = (List<SCFrameworkVersion>)QueryUtil.list(q,
231                                                            getDialect(), start, end, false);
232    
233                                            Collections.sort(list);
234    
235                                            list = new UnmodifiableList<SCFrameworkVersion>(list);
236                                    }
237                                    else {
238                                            list = (List<SCFrameworkVersion>)QueryUtil.list(q,
239                                                            getDialect(), start, end);
240                                    }
241    
242                                    cacheResult(list);
243    
244                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
245                            }
246                            catch (Exception e) {
247                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
248    
249                                    throw processException(e);
250                            }
251                            finally {
252                                    closeSession(session);
253                            }
254                    }
255    
256                    return list;
257            }
258    
259            /**
260             * Returns the first s c framework version in the ordered set where groupId = &#63;.
261             *
262             * @param groupId the group ID
263             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
264             * @return the first matching s c framework version
265             * @throws com.liferay.portlet.softwarecatalog.NoSuchFrameworkVersionException if a matching s c framework version could not be found
266             * @throws SystemException if a system exception occurred
267             */
268            public SCFrameworkVersion findByGroupId_First(long groupId,
269                    OrderByComparator orderByComparator)
270                    throws NoSuchFrameworkVersionException, SystemException {
271                    SCFrameworkVersion scFrameworkVersion = fetchByGroupId_First(groupId,
272                                    orderByComparator);
273    
274                    if (scFrameworkVersion != null) {
275                            return scFrameworkVersion;
276                    }
277    
278                    StringBundler msg = new StringBundler(4);
279    
280                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
281    
282                    msg.append("groupId=");
283                    msg.append(groupId);
284    
285                    msg.append(StringPool.CLOSE_CURLY_BRACE);
286    
287                    throw new NoSuchFrameworkVersionException(msg.toString());
288            }
289    
290            /**
291             * Returns the first s c framework version in the ordered set where groupId = &#63;.
292             *
293             * @param groupId the group ID
294             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
295             * @return the first matching s c framework version, or <code>null</code> if a matching s c framework version could not be found
296             * @throws SystemException if a system exception occurred
297             */
298            public SCFrameworkVersion fetchByGroupId_First(long groupId,
299                    OrderByComparator orderByComparator) throws SystemException {
300                    List<SCFrameworkVersion> list = findByGroupId(groupId, 0, 1,
301                                    orderByComparator);
302    
303                    if (!list.isEmpty()) {
304                            return list.get(0);
305                    }
306    
307                    return null;
308            }
309    
310            /**
311             * Returns the last s c framework version in the ordered set where groupId = &#63;.
312             *
313             * @param groupId the group ID
314             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
315             * @return the last matching s c framework version
316             * @throws com.liferay.portlet.softwarecatalog.NoSuchFrameworkVersionException if a matching s c framework version could not be found
317             * @throws SystemException if a system exception occurred
318             */
319            public SCFrameworkVersion findByGroupId_Last(long groupId,
320                    OrderByComparator orderByComparator)
321                    throws NoSuchFrameworkVersionException, SystemException {
322                    SCFrameworkVersion scFrameworkVersion = fetchByGroupId_Last(groupId,
323                                    orderByComparator);
324    
325                    if (scFrameworkVersion != null) {
326                            return scFrameworkVersion;
327                    }
328    
329                    StringBundler msg = new StringBundler(4);
330    
331                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
332    
333                    msg.append("groupId=");
334                    msg.append(groupId);
335    
336                    msg.append(StringPool.CLOSE_CURLY_BRACE);
337    
338                    throw new NoSuchFrameworkVersionException(msg.toString());
339            }
340    
341            /**
342             * Returns the last s c framework version in the ordered set where groupId = &#63;.
343             *
344             * @param groupId the group ID
345             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
346             * @return the last matching s c framework version, or <code>null</code> if a matching s c framework version could not be found
347             * @throws SystemException if a system exception occurred
348             */
349            public SCFrameworkVersion fetchByGroupId_Last(long groupId,
350                    OrderByComparator orderByComparator) throws SystemException {
351                    int count = countByGroupId(groupId);
352    
353                    List<SCFrameworkVersion> list = findByGroupId(groupId, count - 1,
354                                    count, orderByComparator);
355    
356                    if (!list.isEmpty()) {
357                            return list.get(0);
358                    }
359    
360                    return null;
361            }
362    
363            /**
364             * Returns the s c framework versions before and after the current s c framework version in the ordered set where groupId = &#63;.
365             *
366             * @param frameworkVersionId the primary key of the current s c framework version
367             * @param groupId the group ID
368             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
369             * @return the previous, current, and next s c framework version
370             * @throws com.liferay.portlet.softwarecatalog.NoSuchFrameworkVersionException if a s c framework version with the primary key could not be found
371             * @throws SystemException if a system exception occurred
372             */
373            public SCFrameworkVersion[] findByGroupId_PrevAndNext(
374                    long frameworkVersionId, long groupId,
375                    OrderByComparator orderByComparator)
376                    throws NoSuchFrameworkVersionException, SystemException {
377                    SCFrameworkVersion scFrameworkVersion = findByPrimaryKey(frameworkVersionId);
378    
379                    Session session = null;
380    
381                    try {
382                            session = openSession();
383    
384                            SCFrameworkVersion[] array = new SCFrameworkVersionImpl[3];
385    
386                            array[0] = getByGroupId_PrevAndNext(session, scFrameworkVersion,
387                                            groupId, orderByComparator, true);
388    
389                            array[1] = scFrameworkVersion;
390    
391                            array[2] = getByGroupId_PrevAndNext(session, scFrameworkVersion,
392                                            groupId, orderByComparator, false);
393    
394                            return array;
395                    }
396                    catch (Exception e) {
397                            throw processException(e);
398                    }
399                    finally {
400                            closeSession(session);
401                    }
402            }
403    
404            protected SCFrameworkVersion getByGroupId_PrevAndNext(Session session,
405                    SCFrameworkVersion scFrameworkVersion, long groupId,
406                    OrderByComparator orderByComparator, boolean previous) {
407                    StringBundler query = null;
408    
409                    if (orderByComparator != null) {
410                            query = new StringBundler(6 +
411                                            (orderByComparator.getOrderByFields().length * 6));
412                    }
413                    else {
414                            query = new StringBundler(3);
415                    }
416    
417                    query.append(_SQL_SELECT_SCFRAMEWORKVERSION_WHERE);
418    
419                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
420    
421                    if (orderByComparator != null) {
422                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
423    
424                            if (orderByConditionFields.length > 0) {
425                                    query.append(WHERE_AND);
426                            }
427    
428                            for (int i = 0; i < orderByConditionFields.length; i++) {
429                                    query.append(_ORDER_BY_ENTITY_ALIAS);
430                                    query.append(orderByConditionFields[i]);
431    
432                                    if ((i + 1) < orderByConditionFields.length) {
433                                            if (orderByComparator.isAscending() ^ previous) {
434                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
435                                            }
436                                            else {
437                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
438                                            }
439                                    }
440                                    else {
441                                            if (orderByComparator.isAscending() ^ previous) {
442                                                    query.append(WHERE_GREATER_THAN);
443                                            }
444                                            else {
445                                                    query.append(WHERE_LESSER_THAN);
446                                            }
447                                    }
448                            }
449    
450                            query.append(ORDER_BY_CLAUSE);
451    
452                            String[] orderByFields = orderByComparator.getOrderByFields();
453    
454                            for (int i = 0; i < orderByFields.length; i++) {
455                                    query.append(_ORDER_BY_ENTITY_ALIAS);
456                                    query.append(orderByFields[i]);
457    
458                                    if ((i + 1) < orderByFields.length) {
459                                            if (orderByComparator.isAscending() ^ previous) {
460                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
461                                            }
462                                            else {
463                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
464                                            }
465                                    }
466                                    else {
467                                            if (orderByComparator.isAscending() ^ previous) {
468                                                    query.append(ORDER_BY_ASC);
469                                            }
470                                            else {
471                                                    query.append(ORDER_BY_DESC);
472                                            }
473                                    }
474                            }
475                    }
476                    else {
477                            query.append(SCFrameworkVersionModelImpl.ORDER_BY_JPQL);
478                    }
479    
480                    String sql = query.toString();
481    
482                    Query q = session.createQuery(sql);
483    
484                    q.setFirstResult(0);
485                    q.setMaxResults(2);
486    
487                    QueryPos qPos = QueryPos.getInstance(q);
488    
489                    qPos.add(groupId);
490    
491                    if (orderByComparator != null) {
492                            Object[] values = orderByComparator.getOrderByConditionValues(scFrameworkVersion);
493    
494                            for (Object value : values) {
495                                    qPos.add(value);
496                            }
497                    }
498    
499                    List<SCFrameworkVersion> list = q.list();
500    
501                    if (list.size() == 2) {
502                            return list.get(1);
503                    }
504                    else {
505                            return null;
506                    }
507            }
508    
509            /**
510             * Returns all the s c framework versions that the user has permission to view where groupId = &#63;.
511             *
512             * @param groupId the group ID
513             * @return the matching s c framework versions that the user has permission to view
514             * @throws SystemException if a system exception occurred
515             */
516            public List<SCFrameworkVersion> filterFindByGroupId(long groupId)
517                    throws SystemException {
518                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
519                            QueryUtil.ALL_POS, null);
520            }
521    
522            /**
523             * Returns a range of all the s c framework versions that the user has permission to view where groupId = &#63;.
524             *
525             * <p>
526             * 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.SCFrameworkVersionModelImpl}. 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.
527             * </p>
528             *
529             * @param groupId the group ID
530             * @param start the lower bound of the range of s c framework versions
531             * @param end the upper bound of the range of s c framework versions (not inclusive)
532             * @return the range of matching s c framework versions that the user has permission to view
533             * @throws SystemException if a system exception occurred
534             */
535            public List<SCFrameworkVersion> filterFindByGroupId(long groupId,
536                    int start, int end) throws SystemException {
537                    return filterFindByGroupId(groupId, start, end, null);
538            }
539    
540            /**
541             * Returns an ordered range of all the s c framework versions that the user has permissions to view where groupId = &#63;.
542             *
543             * <p>
544             * 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.SCFrameworkVersionModelImpl}. 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.
545             * </p>
546             *
547             * @param groupId the group ID
548             * @param start the lower bound of the range of s c framework versions
549             * @param end the upper bound of the range of s c framework versions (not inclusive)
550             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
551             * @return the ordered range of matching s c framework versions that the user has permission to view
552             * @throws SystemException if a system exception occurred
553             */
554            public List<SCFrameworkVersion> filterFindByGroupId(long groupId,
555                    int start, int end, OrderByComparator orderByComparator)
556                    throws SystemException {
557                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
558                            return findByGroupId(groupId, start, end, orderByComparator);
559                    }
560    
561                    StringBundler query = null;
562    
563                    if (orderByComparator != null) {
564                            query = new StringBundler(3 +
565                                            (orderByComparator.getOrderByFields().length * 3));
566                    }
567                    else {
568                            query = new StringBundler(3);
569                    }
570    
571                    if (getDB().isSupportsInlineDistinct()) {
572                            query.append(_FILTER_SQL_SELECT_SCFRAMEWORKVERSION_WHERE);
573                    }
574                    else {
575                            query.append(_FILTER_SQL_SELECT_SCFRAMEWORKVERSION_NO_INLINE_DISTINCT_WHERE_1);
576                    }
577    
578                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
579    
580                    if (!getDB().isSupportsInlineDistinct()) {
581                            query.append(_FILTER_SQL_SELECT_SCFRAMEWORKVERSION_NO_INLINE_DISTINCT_WHERE_2);
582                    }
583    
584                    if (orderByComparator != null) {
585                            if (getDB().isSupportsInlineDistinct()) {
586                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
587                                            orderByComparator, true);
588                            }
589                            else {
590                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
591                                            orderByComparator, true);
592                            }
593                    }
594                    else {
595                            if (getDB().isSupportsInlineDistinct()) {
596                                    query.append(SCFrameworkVersionModelImpl.ORDER_BY_JPQL);
597                            }
598                            else {
599                                    query.append(SCFrameworkVersionModelImpl.ORDER_BY_SQL);
600                            }
601                    }
602    
603                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
604                                    SCFrameworkVersion.class.getName(),
605                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
606    
607                    Session session = null;
608    
609                    try {
610                            session = openSession();
611    
612                            SQLQuery q = session.createSQLQuery(sql);
613    
614                            if (getDB().isSupportsInlineDistinct()) {
615                                    q.addEntity(_FILTER_ENTITY_ALIAS, SCFrameworkVersionImpl.class);
616                            }
617                            else {
618                                    q.addEntity(_FILTER_ENTITY_TABLE, SCFrameworkVersionImpl.class);
619                            }
620    
621                            QueryPos qPos = QueryPos.getInstance(q);
622    
623                            qPos.add(groupId);
624    
625                            return (List<SCFrameworkVersion>)QueryUtil.list(q, getDialect(),
626                                    start, end);
627                    }
628                    catch (Exception e) {
629                            throw processException(e);
630                    }
631                    finally {
632                            closeSession(session);
633                    }
634            }
635    
636            /**
637             * Returns the s c framework versions before and after the current s c framework version in the ordered set of s c framework versions that the user has permission to view where groupId = &#63;.
638             *
639             * @param frameworkVersionId the primary key of the current s c framework version
640             * @param groupId the group ID
641             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
642             * @return the previous, current, and next s c framework version
643             * @throws com.liferay.portlet.softwarecatalog.NoSuchFrameworkVersionException if a s c framework version with the primary key could not be found
644             * @throws SystemException if a system exception occurred
645             */
646            public SCFrameworkVersion[] filterFindByGroupId_PrevAndNext(
647                    long frameworkVersionId, long groupId,
648                    OrderByComparator orderByComparator)
649                    throws NoSuchFrameworkVersionException, SystemException {
650                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
651                            return findByGroupId_PrevAndNext(frameworkVersionId, groupId,
652                                    orderByComparator);
653                    }
654    
655                    SCFrameworkVersion scFrameworkVersion = findByPrimaryKey(frameworkVersionId);
656    
657                    Session session = null;
658    
659                    try {
660                            session = openSession();
661    
662                            SCFrameworkVersion[] array = new SCFrameworkVersionImpl[3];
663    
664                            array[0] = filterGetByGroupId_PrevAndNext(session,
665                                            scFrameworkVersion, groupId, orderByComparator, true);
666    
667                            array[1] = scFrameworkVersion;
668    
669                            array[2] = filterGetByGroupId_PrevAndNext(session,
670                                            scFrameworkVersion, groupId, orderByComparator, false);
671    
672                            return array;
673                    }
674                    catch (Exception e) {
675                            throw processException(e);
676                    }
677                    finally {
678                            closeSession(session);
679                    }
680            }
681    
682            protected SCFrameworkVersion filterGetByGroupId_PrevAndNext(
683                    Session session, SCFrameworkVersion scFrameworkVersion, long groupId,
684                    OrderByComparator orderByComparator, boolean previous) {
685                    StringBundler query = null;
686    
687                    if (orderByComparator != null) {
688                            query = new StringBundler(6 +
689                                            (orderByComparator.getOrderByFields().length * 6));
690                    }
691                    else {
692                            query = new StringBundler(3);
693                    }
694    
695                    if (getDB().isSupportsInlineDistinct()) {
696                            query.append(_FILTER_SQL_SELECT_SCFRAMEWORKVERSION_WHERE);
697                    }
698                    else {
699                            query.append(_FILTER_SQL_SELECT_SCFRAMEWORKVERSION_NO_INLINE_DISTINCT_WHERE_1);
700                    }
701    
702                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
703    
704                    if (!getDB().isSupportsInlineDistinct()) {
705                            query.append(_FILTER_SQL_SELECT_SCFRAMEWORKVERSION_NO_INLINE_DISTINCT_WHERE_2);
706                    }
707    
708                    if (orderByComparator != null) {
709                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
710    
711                            if (orderByConditionFields.length > 0) {
712                                    query.append(WHERE_AND);
713                            }
714    
715                            for (int i = 0; i < orderByConditionFields.length; i++) {
716                                    if (getDB().isSupportsInlineDistinct()) {
717                                            query.append(_ORDER_BY_ENTITY_ALIAS);
718                                    }
719                                    else {
720                                            query.append(_ORDER_BY_ENTITY_TABLE);
721                                    }
722    
723                                    query.append(orderByConditionFields[i]);
724    
725                                    if ((i + 1) < orderByConditionFields.length) {
726                                            if (orderByComparator.isAscending() ^ previous) {
727                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
728                                            }
729                                            else {
730                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
731                                            }
732                                    }
733                                    else {
734                                            if (orderByComparator.isAscending() ^ previous) {
735                                                    query.append(WHERE_GREATER_THAN);
736                                            }
737                                            else {
738                                                    query.append(WHERE_LESSER_THAN);
739                                            }
740                                    }
741                            }
742    
743                            query.append(ORDER_BY_CLAUSE);
744    
745                            String[] orderByFields = orderByComparator.getOrderByFields();
746    
747                            for (int i = 0; i < orderByFields.length; i++) {
748                                    if (getDB().isSupportsInlineDistinct()) {
749                                            query.append(_ORDER_BY_ENTITY_ALIAS);
750                                    }
751                                    else {
752                                            query.append(_ORDER_BY_ENTITY_TABLE);
753                                    }
754    
755                                    query.append(orderByFields[i]);
756    
757                                    if ((i + 1) < orderByFields.length) {
758                                            if (orderByComparator.isAscending() ^ previous) {
759                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
760                                            }
761                                            else {
762                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
763                                            }
764                                    }
765                                    else {
766                                            if (orderByComparator.isAscending() ^ previous) {
767                                                    query.append(ORDER_BY_ASC);
768                                            }
769                                            else {
770                                                    query.append(ORDER_BY_DESC);
771                                            }
772                                    }
773                            }
774                    }
775                    else {
776                            if (getDB().isSupportsInlineDistinct()) {
777                                    query.append(SCFrameworkVersionModelImpl.ORDER_BY_JPQL);
778                            }
779                            else {
780                                    query.append(SCFrameworkVersionModelImpl.ORDER_BY_SQL);
781                            }
782                    }
783    
784                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
785                                    SCFrameworkVersion.class.getName(),
786                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
787    
788                    SQLQuery q = session.createSQLQuery(sql);
789    
790                    q.setFirstResult(0);
791                    q.setMaxResults(2);
792    
793                    if (getDB().isSupportsInlineDistinct()) {
794                            q.addEntity(_FILTER_ENTITY_ALIAS, SCFrameworkVersionImpl.class);
795                    }
796                    else {
797                            q.addEntity(_FILTER_ENTITY_TABLE, SCFrameworkVersionImpl.class);
798                    }
799    
800                    QueryPos qPos = QueryPos.getInstance(q);
801    
802                    qPos.add(groupId);
803    
804                    if (orderByComparator != null) {
805                            Object[] values = orderByComparator.getOrderByConditionValues(scFrameworkVersion);
806    
807                            for (Object value : values) {
808                                    qPos.add(value);
809                            }
810                    }
811    
812                    List<SCFrameworkVersion> list = q.list();
813    
814                    if (list.size() == 2) {
815                            return list.get(1);
816                    }
817                    else {
818                            return null;
819                    }
820            }
821    
822            /**
823             * Removes all the s c framework versions where groupId = &#63; from the database.
824             *
825             * @param groupId the group ID
826             * @throws SystemException if a system exception occurred
827             */
828            public void removeByGroupId(long groupId) throws SystemException {
829                    for (SCFrameworkVersion scFrameworkVersion : findByGroupId(groupId,
830                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
831                            remove(scFrameworkVersion);
832                    }
833            }
834    
835            /**
836             * Returns the number of s c framework versions where groupId = &#63;.
837             *
838             * @param groupId the group ID
839             * @return the number of matching s c framework versions
840             * @throws SystemException if a system exception occurred
841             */
842            public int countByGroupId(long groupId) throws SystemException {
843                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
844    
845                    Object[] finderArgs = new Object[] { groupId };
846    
847                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
848                                    this);
849    
850                    if (count == null) {
851                            StringBundler query = new StringBundler(2);
852    
853                            query.append(_SQL_COUNT_SCFRAMEWORKVERSION_WHERE);
854    
855                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
856    
857                            String sql = query.toString();
858    
859                            Session session = null;
860    
861                            try {
862                                    session = openSession();
863    
864                                    Query q = session.createQuery(sql);
865    
866                                    QueryPos qPos = QueryPos.getInstance(q);
867    
868                                    qPos.add(groupId);
869    
870                                    count = (Long)q.uniqueResult();
871    
872                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
873                            }
874                            catch (Exception e) {
875                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
876    
877                                    throw processException(e);
878                            }
879                            finally {
880                                    closeSession(session);
881                            }
882                    }
883    
884                    return count.intValue();
885            }
886    
887            /**
888             * Returns the number of s c framework versions that the user has permission to view where groupId = &#63;.
889             *
890             * @param groupId the group ID
891             * @return the number of matching s c framework versions that the user has permission to view
892             * @throws SystemException if a system exception occurred
893             */
894            public int filterCountByGroupId(long groupId) throws SystemException {
895                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
896                            return countByGroupId(groupId);
897                    }
898    
899                    StringBundler query = new StringBundler(2);
900    
901                    query.append(_FILTER_SQL_COUNT_SCFRAMEWORKVERSION_WHERE);
902    
903                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
904    
905                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
906                                    SCFrameworkVersion.class.getName(),
907                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
908    
909                    Session session = null;
910    
911                    try {
912                            session = openSession();
913    
914                            SQLQuery q = session.createSQLQuery(sql);
915    
916                            q.addScalar(COUNT_COLUMN_NAME,
917                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
918    
919                            QueryPos qPos = QueryPos.getInstance(q);
920    
921                            qPos.add(groupId);
922    
923                            Long count = (Long)q.uniqueResult();
924    
925                            return count.intValue();
926                    }
927                    catch (Exception e) {
928                            throw processException(e);
929                    }
930                    finally {
931                            closeSession(session);
932                    }
933            }
934    
935            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "scFrameworkVersion.groupId = ?";
936            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
937                    new FinderPath(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
938                            SCFrameworkVersionModelImpl.FINDER_CACHE_ENABLED,
939                            SCFrameworkVersionImpl.class,
940                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
941                            new String[] {
942                                    Long.class.getName(),
943                                    
944                            Integer.class.getName(), Integer.class.getName(),
945                                    OrderByComparator.class.getName()
946                            });
947            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
948                    new FinderPath(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
949                            SCFrameworkVersionModelImpl.FINDER_CACHE_ENABLED,
950                            SCFrameworkVersionImpl.class,
951                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
952                            new String[] { Long.class.getName() },
953                            SCFrameworkVersionModelImpl.COMPANYID_COLUMN_BITMASK |
954                            SCFrameworkVersionModelImpl.NAME_COLUMN_BITMASK);
955            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
956                            SCFrameworkVersionModelImpl.FINDER_CACHE_ENABLED, Long.class,
957                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
958                            new String[] { Long.class.getName() });
959    
960            /**
961             * Returns all the s c framework versions where companyId = &#63;.
962             *
963             * @param companyId the company ID
964             * @return the matching s c framework versions
965             * @throws SystemException if a system exception occurred
966             */
967            public List<SCFrameworkVersion> findByCompanyId(long companyId)
968                    throws SystemException {
969                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
970                            null);
971            }
972    
973            /**
974             * Returns a range of all the s c framework versions where companyId = &#63;.
975             *
976             * <p>
977             * 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.SCFrameworkVersionModelImpl}. 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.
978             * </p>
979             *
980             * @param companyId the company ID
981             * @param start the lower bound of the range of s c framework versions
982             * @param end the upper bound of the range of s c framework versions (not inclusive)
983             * @return the range of matching s c framework versions
984             * @throws SystemException if a system exception occurred
985             */
986            public List<SCFrameworkVersion> findByCompanyId(long companyId, int start,
987                    int end) throws SystemException {
988                    return findByCompanyId(companyId, start, end, null);
989            }
990    
991            /**
992             * Returns an ordered range of all the s c framework versions where companyId = &#63;.
993             *
994             * <p>
995             * 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.SCFrameworkVersionModelImpl}. 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.
996             * </p>
997             *
998             * @param companyId the company ID
999             * @param start the lower bound of the range of s c framework versions
1000             * @param end the upper bound of the range of s c framework versions (not inclusive)
1001             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1002             * @return the ordered range of matching s c framework versions
1003             * @throws SystemException if a system exception occurred
1004             */
1005            public List<SCFrameworkVersion> findByCompanyId(long companyId, int start,
1006                    int end, OrderByComparator orderByComparator) throws SystemException {
1007                    boolean pagination = true;
1008                    FinderPath finderPath = null;
1009                    Object[] finderArgs = null;
1010    
1011                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1012                                    (orderByComparator == null)) {
1013                            pagination = false;
1014                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
1015                            finderArgs = new Object[] { companyId };
1016                    }
1017                    else {
1018                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
1019                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
1020                    }
1021    
1022                    List<SCFrameworkVersion> list = (List<SCFrameworkVersion>)FinderCacheUtil.getResult(finderPath,
1023                                    finderArgs, this);
1024    
1025                    if ((list != null) && !list.isEmpty()) {
1026                            for (SCFrameworkVersion scFrameworkVersion : list) {
1027                                    if ((companyId != scFrameworkVersion.getCompanyId())) {
1028                                            list = null;
1029    
1030                                            break;
1031                                    }
1032                            }
1033                    }
1034    
1035                    if (list == null) {
1036                            StringBundler query = null;
1037    
1038                            if (orderByComparator != null) {
1039                                    query = new StringBundler(3 +
1040                                                    (orderByComparator.getOrderByFields().length * 3));
1041                            }
1042                            else {
1043                                    query = new StringBundler(3);
1044                            }
1045    
1046                            query.append(_SQL_SELECT_SCFRAMEWORKVERSION_WHERE);
1047    
1048                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1049    
1050                            if (orderByComparator != null) {
1051                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1052                                            orderByComparator);
1053                            }
1054                            else
1055                             if (pagination) {
1056                                    query.append(SCFrameworkVersionModelImpl.ORDER_BY_JPQL);
1057                            }
1058    
1059                            String sql = query.toString();
1060    
1061                            Session session = null;
1062    
1063                            try {
1064                                    session = openSession();
1065    
1066                                    Query q = session.createQuery(sql);
1067    
1068                                    QueryPos qPos = QueryPos.getInstance(q);
1069    
1070                                    qPos.add(companyId);
1071    
1072                                    if (!pagination) {
1073                                            list = (List<SCFrameworkVersion>)QueryUtil.list(q,
1074                                                            getDialect(), start, end, false);
1075    
1076                                            Collections.sort(list);
1077    
1078                                            list = new UnmodifiableList<SCFrameworkVersion>(list);
1079                                    }
1080                                    else {
1081                                            list = (List<SCFrameworkVersion>)QueryUtil.list(q,
1082                                                            getDialect(), start, end);
1083                                    }
1084    
1085                                    cacheResult(list);
1086    
1087                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1088                            }
1089                            catch (Exception e) {
1090                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1091    
1092                                    throw processException(e);
1093                            }
1094                            finally {
1095                                    closeSession(session);
1096                            }
1097                    }
1098    
1099                    return list;
1100            }
1101    
1102            /**
1103             * Returns the first s c framework version in the ordered set where companyId = &#63;.
1104             *
1105             * @param companyId the company ID
1106             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1107             * @return the first matching s c framework version
1108             * @throws com.liferay.portlet.softwarecatalog.NoSuchFrameworkVersionException if a matching s c framework version could not be found
1109             * @throws SystemException if a system exception occurred
1110             */
1111            public SCFrameworkVersion findByCompanyId_First(long companyId,
1112                    OrderByComparator orderByComparator)
1113                    throws NoSuchFrameworkVersionException, SystemException {
1114                    SCFrameworkVersion scFrameworkVersion = fetchByCompanyId_First(companyId,
1115                                    orderByComparator);
1116    
1117                    if (scFrameworkVersion != null) {
1118                            return scFrameworkVersion;
1119                    }
1120    
1121                    StringBundler msg = new StringBundler(4);
1122    
1123                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1124    
1125                    msg.append("companyId=");
1126                    msg.append(companyId);
1127    
1128                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1129    
1130                    throw new NoSuchFrameworkVersionException(msg.toString());
1131            }
1132    
1133            /**
1134             * Returns the first s c framework version in the ordered set where companyId = &#63;.
1135             *
1136             * @param companyId the company ID
1137             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1138             * @return the first matching s c framework version, or <code>null</code> if a matching s c framework version could not be found
1139             * @throws SystemException if a system exception occurred
1140             */
1141            public SCFrameworkVersion fetchByCompanyId_First(long companyId,
1142                    OrderByComparator orderByComparator) throws SystemException {
1143                    List<SCFrameworkVersion> list = findByCompanyId(companyId, 0, 1,
1144                                    orderByComparator);
1145    
1146                    if (!list.isEmpty()) {
1147                            return list.get(0);
1148                    }
1149    
1150                    return null;
1151            }
1152    
1153            /**
1154             * Returns the last s c framework version in the ordered set where companyId = &#63;.
1155             *
1156             * @param companyId the company ID
1157             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1158             * @return the last matching s c framework version
1159             * @throws com.liferay.portlet.softwarecatalog.NoSuchFrameworkVersionException if a matching s c framework version could not be found
1160             * @throws SystemException if a system exception occurred
1161             */
1162            public SCFrameworkVersion findByCompanyId_Last(long companyId,
1163                    OrderByComparator orderByComparator)
1164                    throws NoSuchFrameworkVersionException, SystemException {
1165                    SCFrameworkVersion scFrameworkVersion = fetchByCompanyId_Last(companyId,
1166                                    orderByComparator);
1167    
1168                    if (scFrameworkVersion != null) {
1169                            return scFrameworkVersion;
1170                    }
1171    
1172                    StringBundler msg = new StringBundler(4);
1173    
1174                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1175    
1176                    msg.append("companyId=");
1177                    msg.append(companyId);
1178    
1179                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1180    
1181                    throw new NoSuchFrameworkVersionException(msg.toString());
1182            }
1183    
1184            /**
1185             * Returns the last s c framework version in the ordered set where companyId = &#63;.
1186             *
1187             * @param companyId the company ID
1188             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1189             * @return the last matching s c framework version, or <code>null</code> if a matching s c framework version could not be found
1190             * @throws SystemException if a system exception occurred
1191             */
1192            public SCFrameworkVersion fetchByCompanyId_Last(long companyId,
1193                    OrderByComparator orderByComparator) throws SystemException {
1194                    int count = countByCompanyId(companyId);
1195    
1196                    List<SCFrameworkVersion> list = findByCompanyId(companyId, count - 1,
1197                                    count, orderByComparator);
1198    
1199                    if (!list.isEmpty()) {
1200                            return list.get(0);
1201                    }
1202    
1203                    return null;
1204            }
1205    
1206            /**
1207             * Returns the s c framework versions before and after the current s c framework version in the ordered set where companyId = &#63;.
1208             *
1209             * @param frameworkVersionId the primary key of the current s c framework version
1210             * @param companyId the company ID
1211             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1212             * @return the previous, current, and next s c framework version
1213             * @throws com.liferay.portlet.softwarecatalog.NoSuchFrameworkVersionException if a s c framework version with the primary key could not be found
1214             * @throws SystemException if a system exception occurred
1215             */
1216            public SCFrameworkVersion[] findByCompanyId_PrevAndNext(
1217                    long frameworkVersionId, long companyId,
1218                    OrderByComparator orderByComparator)
1219                    throws NoSuchFrameworkVersionException, SystemException {
1220                    SCFrameworkVersion scFrameworkVersion = findByPrimaryKey(frameworkVersionId);
1221    
1222                    Session session = null;
1223    
1224                    try {
1225                            session = openSession();
1226    
1227                            SCFrameworkVersion[] array = new SCFrameworkVersionImpl[3];
1228    
1229                            array[0] = getByCompanyId_PrevAndNext(session, scFrameworkVersion,
1230                                            companyId, orderByComparator, true);
1231    
1232                            array[1] = scFrameworkVersion;
1233    
1234                            array[2] = getByCompanyId_PrevAndNext(session, scFrameworkVersion,
1235                                            companyId, orderByComparator, false);
1236    
1237                            return array;
1238                    }
1239                    catch (Exception e) {
1240                            throw processException(e);
1241                    }
1242                    finally {
1243                            closeSession(session);
1244                    }
1245            }
1246    
1247            protected SCFrameworkVersion getByCompanyId_PrevAndNext(Session session,
1248                    SCFrameworkVersion scFrameworkVersion, long companyId,
1249                    OrderByComparator orderByComparator, boolean previous) {
1250                    StringBundler query = null;
1251    
1252                    if (orderByComparator != null) {
1253                            query = new StringBundler(6 +
1254                                            (orderByComparator.getOrderByFields().length * 6));
1255                    }
1256                    else {
1257                            query = new StringBundler(3);
1258                    }
1259    
1260                    query.append(_SQL_SELECT_SCFRAMEWORKVERSION_WHERE);
1261    
1262                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1263    
1264                    if (orderByComparator != null) {
1265                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1266    
1267                            if (orderByConditionFields.length > 0) {
1268                                    query.append(WHERE_AND);
1269                            }
1270    
1271                            for (int i = 0; i < orderByConditionFields.length; i++) {
1272                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1273                                    query.append(orderByConditionFields[i]);
1274    
1275                                    if ((i + 1) < orderByConditionFields.length) {
1276                                            if (orderByComparator.isAscending() ^ previous) {
1277                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1278                                            }
1279                                            else {
1280                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1281                                            }
1282                                    }
1283                                    else {
1284                                            if (orderByComparator.isAscending() ^ previous) {
1285                                                    query.append(WHERE_GREATER_THAN);
1286                                            }
1287                                            else {
1288                                                    query.append(WHERE_LESSER_THAN);
1289                                            }
1290                                    }
1291                            }
1292    
1293                            query.append(ORDER_BY_CLAUSE);
1294    
1295                            String[] orderByFields = orderByComparator.getOrderByFields();
1296    
1297                            for (int i = 0; i < orderByFields.length; i++) {
1298                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1299                                    query.append(orderByFields[i]);
1300    
1301                                    if ((i + 1) < orderByFields.length) {
1302                                            if (orderByComparator.isAscending() ^ previous) {
1303                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1304                                            }
1305                                            else {
1306                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1307                                            }
1308                                    }
1309                                    else {
1310                                            if (orderByComparator.isAscending() ^ previous) {
1311                                                    query.append(ORDER_BY_ASC);
1312                                            }
1313                                            else {
1314                                                    query.append(ORDER_BY_DESC);
1315                                            }
1316                                    }
1317                            }
1318                    }
1319                    else {
1320                            query.append(SCFrameworkVersionModelImpl.ORDER_BY_JPQL);
1321                    }
1322    
1323                    String sql = query.toString();
1324    
1325                    Query q = session.createQuery(sql);
1326    
1327                    q.setFirstResult(0);
1328                    q.setMaxResults(2);
1329    
1330                    QueryPos qPos = QueryPos.getInstance(q);
1331    
1332                    qPos.add(companyId);
1333    
1334                    if (orderByComparator != null) {
1335                            Object[] values = orderByComparator.getOrderByConditionValues(scFrameworkVersion);
1336    
1337                            for (Object value : values) {
1338                                    qPos.add(value);
1339                            }
1340                    }
1341    
1342                    List<SCFrameworkVersion> list = q.list();
1343    
1344                    if (list.size() == 2) {
1345                            return list.get(1);
1346                    }
1347                    else {
1348                            return null;
1349                    }
1350            }
1351    
1352            /**
1353             * Removes all the s c framework versions where companyId = &#63; from the database.
1354             *
1355             * @param companyId the company ID
1356             * @throws SystemException if a system exception occurred
1357             */
1358            public void removeByCompanyId(long companyId) throws SystemException {
1359                    for (SCFrameworkVersion scFrameworkVersion : findByCompanyId(
1360                                    companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1361                            remove(scFrameworkVersion);
1362                    }
1363            }
1364    
1365            /**
1366             * Returns the number of s c framework versions where companyId = &#63;.
1367             *
1368             * @param companyId the company ID
1369             * @return the number of matching s c framework versions
1370             * @throws SystemException if a system exception occurred
1371             */
1372            public int countByCompanyId(long companyId) throws SystemException {
1373                    FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
1374    
1375                    Object[] finderArgs = new Object[] { companyId };
1376    
1377                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1378                                    this);
1379    
1380                    if (count == null) {
1381                            StringBundler query = new StringBundler(2);
1382    
1383                            query.append(_SQL_COUNT_SCFRAMEWORKVERSION_WHERE);
1384    
1385                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1386    
1387                            String sql = query.toString();
1388    
1389                            Session session = null;
1390    
1391                            try {
1392                                    session = openSession();
1393    
1394                                    Query q = session.createQuery(sql);
1395    
1396                                    QueryPos qPos = QueryPos.getInstance(q);
1397    
1398                                    qPos.add(companyId);
1399    
1400                                    count = (Long)q.uniqueResult();
1401    
1402                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1403                            }
1404                            catch (Exception e) {
1405                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1406    
1407                                    throw processException(e);
1408                            }
1409                            finally {
1410                                    closeSession(session);
1411                            }
1412                    }
1413    
1414                    return count.intValue();
1415            }
1416    
1417            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "scFrameworkVersion.companyId = ?";
1418            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A = new FinderPath(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
1419                            SCFrameworkVersionModelImpl.FINDER_CACHE_ENABLED,
1420                            SCFrameworkVersionImpl.class,
1421                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_A",
1422                            new String[] {
1423                                    Long.class.getName(), Boolean.class.getName(),
1424                                    
1425                            Integer.class.getName(), Integer.class.getName(),
1426                                    OrderByComparator.class.getName()
1427                            });
1428            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A = new FinderPath(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
1429                            SCFrameworkVersionModelImpl.FINDER_CACHE_ENABLED,
1430                            SCFrameworkVersionImpl.class,
1431                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_A",
1432                            new String[] { Long.class.getName(), Boolean.class.getName() },
1433                            SCFrameworkVersionModelImpl.GROUPID_COLUMN_BITMASK |
1434                            SCFrameworkVersionModelImpl.ACTIVE_COLUMN_BITMASK |
1435                            SCFrameworkVersionModelImpl.NAME_COLUMN_BITMASK);
1436            public static final FinderPath FINDER_PATH_COUNT_BY_G_A = new FinderPath(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
1437                            SCFrameworkVersionModelImpl.FINDER_CACHE_ENABLED, Long.class,
1438                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A",
1439                            new String[] { Long.class.getName(), Boolean.class.getName() });
1440    
1441            /**
1442             * Returns all the s c framework versions where groupId = &#63; and active = &#63;.
1443             *
1444             * @param groupId the group ID
1445             * @param active the active
1446             * @return the matching s c framework versions
1447             * @throws SystemException if a system exception occurred
1448             */
1449            public List<SCFrameworkVersion> findByG_A(long groupId, boolean active)
1450                    throws SystemException {
1451                    return findByG_A(groupId, active, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1452                            null);
1453            }
1454    
1455            /**
1456             * Returns a range of all the s c framework versions where groupId = &#63; and active = &#63;.
1457             *
1458             * <p>
1459             * 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.SCFrameworkVersionModelImpl}. 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.
1460             * </p>
1461             *
1462             * @param groupId the group ID
1463             * @param active the active
1464             * @param start the lower bound of the range of s c framework versions
1465             * @param end the upper bound of the range of s c framework versions (not inclusive)
1466             * @return the range of matching s c framework versions
1467             * @throws SystemException if a system exception occurred
1468             */
1469            public List<SCFrameworkVersion> findByG_A(long groupId, boolean active,
1470                    int start, int end) throws SystemException {
1471                    return findByG_A(groupId, active, start, end, null);
1472            }
1473    
1474            /**
1475             * Returns an ordered range of all the s c framework versions where groupId = &#63; and active = &#63;.
1476             *
1477             * <p>
1478             * 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.SCFrameworkVersionModelImpl}. 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.
1479             * </p>
1480             *
1481             * @param groupId the group ID
1482             * @param active the active
1483             * @param start the lower bound of the range of s c framework versions
1484             * @param end the upper bound of the range of s c framework versions (not inclusive)
1485             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1486             * @return the ordered range of matching s c framework versions
1487             * @throws SystemException if a system exception occurred
1488             */
1489            public List<SCFrameworkVersion> findByG_A(long groupId, boolean active,
1490                    int start, int end, OrderByComparator orderByComparator)
1491                    throws SystemException {
1492                    boolean pagination = true;
1493                    FinderPath finderPath = null;
1494                    Object[] finderArgs = null;
1495    
1496                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1497                                    (orderByComparator == null)) {
1498                            pagination = false;
1499                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A;
1500                            finderArgs = new Object[] { groupId, active };
1501                    }
1502                    else {
1503                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A;
1504                            finderArgs = new Object[] {
1505                                            groupId, active,
1506                                            
1507                                            start, end, orderByComparator
1508                                    };
1509                    }
1510    
1511                    List<SCFrameworkVersion> list = (List<SCFrameworkVersion>)FinderCacheUtil.getResult(finderPath,
1512                                    finderArgs, this);
1513    
1514                    if ((list != null) && !list.isEmpty()) {
1515                            for (SCFrameworkVersion scFrameworkVersion : list) {
1516                                    if ((groupId != scFrameworkVersion.getGroupId()) ||
1517                                                    (active != scFrameworkVersion.getActive())) {
1518                                            list = null;
1519    
1520                                            break;
1521                                    }
1522                            }
1523                    }
1524    
1525                    if (list == null) {
1526                            StringBundler query = null;
1527    
1528                            if (orderByComparator != null) {
1529                                    query = new StringBundler(4 +
1530                                                    (orderByComparator.getOrderByFields().length * 3));
1531                            }
1532                            else {
1533                                    query = new StringBundler(4);
1534                            }
1535    
1536                            query.append(_SQL_SELECT_SCFRAMEWORKVERSION_WHERE);
1537    
1538                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
1539    
1540                            query.append(_FINDER_COLUMN_G_A_ACTIVE_2);
1541    
1542                            if (orderByComparator != null) {
1543                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1544                                            orderByComparator);
1545                            }
1546                            else
1547                             if (pagination) {
1548                                    query.append(SCFrameworkVersionModelImpl.ORDER_BY_JPQL);
1549                            }
1550    
1551                            String sql = query.toString();
1552    
1553                            Session session = null;
1554    
1555                            try {
1556                                    session = openSession();
1557    
1558                                    Query q = session.createQuery(sql);
1559    
1560                                    QueryPos qPos = QueryPos.getInstance(q);
1561    
1562                                    qPos.add(groupId);
1563    
1564                                    qPos.add(active);
1565    
1566                                    if (!pagination) {
1567                                            list = (List<SCFrameworkVersion>)QueryUtil.list(q,
1568                                                            getDialect(), start, end, false);
1569    
1570                                            Collections.sort(list);
1571    
1572                                            list = new UnmodifiableList<SCFrameworkVersion>(list);
1573                                    }
1574                                    else {
1575                                            list = (List<SCFrameworkVersion>)QueryUtil.list(q,
1576                                                            getDialect(), start, end);
1577                                    }
1578    
1579                                    cacheResult(list);
1580    
1581                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1582                            }
1583                            catch (Exception e) {
1584                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1585    
1586                                    throw processException(e);
1587                            }
1588                            finally {
1589                                    closeSession(session);
1590                            }
1591                    }
1592    
1593                    return list;
1594            }
1595    
1596            /**
1597             * Returns the first s c framework version in the ordered set where groupId = &#63; and active = &#63;.
1598             *
1599             * @param groupId the group ID
1600             * @param active the active
1601             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1602             * @return the first matching s c framework version
1603             * @throws com.liferay.portlet.softwarecatalog.NoSuchFrameworkVersionException if a matching s c framework version could not be found
1604             * @throws SystemException if a system exception occurred
1605             */
1606            public SCFrameworkVersion findByG_A_First(long groupId, boolean active,
1607                    OrderByComparator orderByComparator)
1608                    throws NoSuchFrameworkVersionException, SystemException {
1609                    SCFrameworkVersion scFrameworkVersion = fetchByG_A_First(groupId,
1610                                    active, orderByComparator);
1611    
1612                    if (scFrameworkVersion != null) {
1613                            return scFrameworkVersion;
1614                    }
1615    
1616                    StringBundler msg = new StringBundler(6);
1617    
1618                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1619    
1620                    msg.append("groupId=");
1621                    msg.append(groupId);
1622    
1623                    msg.append(", active=");
1624                    msg.append(active);
1625    
1626                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1627    
1628                    throw new NoSuchFrameworkVersionException(msg.toString());
1629            }
1630    
1631            /**
1632             * Returns the first s c framework version in the ordered set where groupId = &#63; and active = &#63;.
1633             *
1634             * @param groupId the group ID
1635             * @param active the active
1636             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1637             * @return the first matching s c framework version, or <code>null</code> if a matching s c framework version could not be found
1638             * @throws SystemException if a system exception occurred
1639             */
1640            public SCFrameworkVersion fetchByG_A_First(long groupId, boolean active,
1641                    OrderByComparator orderByComparator) throws SystemException {
1642                    List<SCFrameworkVersion> list = findByG_A(groupId, active, 0, 1,
1643                                    orderByComparator);
1644    
1645                    if (!list.isEmpty()) {
1646                            return list.get(0);
1647                    }
1648    
1649                    return null;
1650            }
1651    
1652            /**
1653             * Returns the last s c framework version in the ordered set where groupId = &#63; and active = &#63;.
1654             *
1655             * @param groupId the group ID
1656             * @param active the active
1657             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1658             * @return the last matching s c framework version
1659             * @throws com.liferay.portlet.softwarecatalog.NoSuchFrameworkVersionException if a matching s c framework version could not be found
1660             * @throws SystemException if a system exception occurred
1661             */
1662            public SCFrameworkVersion findByG_A_Last(long groupId, boolean active,
1663                    OrderByComparator orderByComparator)
1664                    throws NoSuchFrameworkVersionException, SystemException {
1665                    SCFrameworkVersion scFrameworkVersion = fetchByG_A_Last(groupId,
1666                                    active, orderByComparator);
1667    
1668                    if (scFrameworkVersion != null) {
1669                            return scFrameworkVersion;
1670                    }
1671    
1672                    StringBundler msg = new StringBundler(6);
1673    
1674                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1675    
1676                    msg.append("groupId=");
1677                    msg.append(groupId);
1678    
1679                    msg.append(", active=");
1680                    msg.append(active);
1681    
1682                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1683    
1684                    throw new NoSuchFrameworkVersionException(msg.toString());
1685            }
1686    
1687            /**
1688             * Returns the last s c framework version in the ordered set where groupId = &#63; and active = &#63;.
1689             *
1690             * @param groupId the group ID
1691             * @param active the active
1692             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1693             * @return the last matching s c framework version, or <code>null</code> if a matching s c framework version could not be found
1694             * @throws SystemException if a system exception occurred
1695             */
1696            public SCFrameworkVersion fetchByG_A_Last(long groupId, boolean active,
1697                    OrderByComparator orderByComparator) throws SystemException {
1698                    int count = countByG_A(groupId, active);
1699    
1700                    List<SCFrameworkVersion> list = findByG_A(groupId, active, count - 1,
1701                                    count, orderByComparator);
1702    
1703                    if (!list.isEmpty()) {
1704                            return list.get(0);
1705                    }
1706    
1707                    return null;
1708            }
1709    
1710            /**
1711             * Returns the s c framework versions before and after the current s c framework version in the ordered set where groupId = &#63; and active = &#63;.
1712             *
1713             * @param frameworkVersionId the primary key of the current s c framework version
1714             * @param groupId the group ID
1715             * @param active the active
1716             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1717             * @return the previous, current, and next s c framework version
1718             * @throws com.liferay.portlet.softwarecatalog.NoSuchFrameworkVersionException if a s c framework version with the primary key could not be found
1719             * @throws SystemException if a system exception occurred
1720             */
1721            public SCFrameworkVersion[] findByG_A_PrevAndNext(long frameworkVersionId,
1722                    long groupId, boolean active, OrderByComparator orderByComparator)
1723                    throws NoSuchFrameworkVersionException, SystemException {
1724                    SCFrameworkVersion scFrameworkVersion = findByPrimaryKey(frameworkVersionId);
1725    
1726                    Session session = null;
1727    
1728                    try {
1729                            session = openSession();
1730    
1731                            SCFrameworkVersion[] array = new SCFrameworkVersionImpl[3];
1732    
1733                            array[0] = getByG_A_PrevAndNext(session, scFrameworkVersion,
1734                                            groupId, active, orderByComparator, true);
1735    
1736                            array[1] = scFrameworkVersion;
1737    
1738                            array[2] = getByG_A_PrevAndNext(session, scFrameworkVersion,
1739                                            groupId, active, orderByComparator, false);
1740    
1741                            return array;
1742                    }
1743                    catch (Exception e) {
1744                            throw processException(e);
1745                    }
1746                    finally {
1747                            closeSession(session);
1748                    }
1749            }
1750    
1751            protected SCFrameworkVersion getByG_A_PrevAndNext(Session session,
1752                    SCFrameworkVersion scFrameworkVersion, long groupId, boolean active,
1753                    OrderByComparator orderByComparator, boolean previous) {
1754                    StringBundler query = null;
1755    
1756                    if (orderByComparator != null) {
1757                            query = new StringBundler(6 +
1758                                            (orderByComparator.getOrderByFields().length * 6));
1759                    }
1760                    else {
1761                            query = new StringBundler(3);
1762                    }
1763    
1764                    query.append(_SQL_SELECT_SCFRAMEWORKVERSION_WHERE);
1765    
1766                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
1767    
1768                    query.append(_FINDER_COLUMN_G_A_ACTIVE_2);
1769    
1770                    if (orderByComparator != null) {
1771                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1772    
1773                            if (orderByConditionFields.length > 0) {
1774                                    query.append(WHERE_AND);
1775                            }
1776    
1777                            for (int i = 0; i < orderByConditionFields.length; i++) {
1778                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1779                                    query.append(orderByConditionFields[i]);
1780    
1781                                    if ((i + 1) < orderByConditionFields.length) {
1782                                            if (orderByComparator.isAscending() ^ previous) {
1783                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1784                                            }
1785                                            else {
1786                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1787                                            }
1788                                    }
1789                                    else {
1790                                            if (orderByComparator.isAscending() ^ previous) {
1791                                                    query.append(WHERE_GREATER_THAN);
1792                                            }
1793                                            else {
1794                                                    query.append(WHERE_LESSER_THAN);
1795                                            }
1796                                    }
1797                            }
1798    
1799                            query.append(ORDER_BY_CLAUSE);
1800    
1801                            String[] orderByFields = orderByComparator.getOrderByFields();
1802    
1803                            for (int i = 0; i < orderByFields.length; i++) {
1804                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1805                                    query.append(orderByFields[i]);
1806    
1807                                    if ((i + 1) < orderByFields.length) {
1808                                            if (orderByComparator.isAscending() ^ previous) {
1809                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1810                                            }
1811                                            else {
1812                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1813                                            }
1814                                    }
1815                                    else {
1816                                            if (orderByComparator.isAscending() ^ previous) {
1817                                                    query.append(ORDER_BY_ASC);
1818                                            }
1819                                            else {
1820                                                    query.append(ORDER_BY_DESC);
1821                                            }
1822                                    }
1823                            }
1824                    }
1825                    else {
1826                            query.append(SCFrameworkVersionModelImpl.ORDER_BY_JPQL);
1827                    }
1828    
1829                    String sql = query.toString();
1830    
1831                    Query q = session.createQuery(sql);
1832    
1833                    q.setFirstResult(0);
1834                    q.setMaxResults(2);
1835    
1836                    QueryPos qPos = QueryPos.getInstance(q);
1837    
1838                    qPos.add(groupId);
1839    
1840                    qPos.add(active);
1841    
1842                    if (orderByComparator != null) {
1843                            Object[] values = orderByComparator.getOrderByConditionValues(scFrameworkVersion);
1844    
1845                            for (Object value : values) {
1846                                    qPos.add(value);
1847                            }
1848                    }
1849    
1850                    List<SCFrameworkVersion> list = q.list();
1851    
1852                    if (list.size() == 2) {
1853                            return list.get(1);
1854                    }
1855                    else {
1856                            return null;
1857                    }
1858            }
1859    
1860            /**
1861             * Returns all the s c framework versions that the user has permission to view where groupId = &#63; and active = &#63;.
1862             *
1863             * @param groupId the group ID
1864             * @param active the active
1865             * @return the matching s c framework versions that the user has permission to view
1866             * @throws SystemException if a system exception occurred
1867             */
1868            public List<SCFrameworkVersion> filterFindByG_A(long groupId, boolean active)
1869                    throws SystemException {
1870                    return filterFindByG_A(groupId, active, QueryUtil.ALL_POS,
1871                            QueryUtil.ALL_POS, null);
1872            }
1873    
1874            /**
1875             * Returns a range of all the s c framework versions that the user has permission to view where groupId = &#63; and active = &#63;.
1876             *
1877             * <p>
1878             * 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.SCFrameworkVersionModelImpl}. 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.
1879             * </p>
1880             *
1881             * @param groupId the group ID
1882             * @param active the active
1883             * @param start the lower bound of the range of s c framework versions
1884             * @param end the upper bound of the range of s c framework versions (not inclusive)
1885             * @return the range of matching s c framework versions that the user has permission to view
1886             * @throws SystemException if a system exception occurred
1887             */
1888            public List<SCFrameworkVersion> filterFindByG_A(long groupId,
1889                    boolean active, int start, int end) throws SystemException {
1890                    return filterFindByG_A(groupId, active, start, end, null);
1891            }
1892    
1893            /**
1894             * Returns an ordered range of all the s c framework versions that the user has permissions to view where groupId = &#63; and active = &#63;.
1895             *
1896             * <p>
1897             * 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.SCFrameworkVersionModelImpl}. 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.
1898             * </p>
1899             *
1900             * @param groupId the group ID
1901             * @param active the active
1902             * @param start the lower bound of the range of s c framework versions
1903             * @param end the upper bound of the range of s c framework versions (not inclusive)
1904             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1905             * @return the ordered range of matching s c framework versions that the user has permission to view
1906             * @throws SystemException if a system exception occurred
1907             */
1908            public List<SCFrameworkVersion> filterFindByG_A(long groupId,
1909                    boolean active, int start, int end, OrderByComparator orderByComparator)
1910                    throws SystemException {
1911                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1912                            return findByG_A(groupId, active, start, end, orderByComparator);
1913                    }
1914    
1915                    StringBundler query = null;
1916    
1917                    if (orderByComparator != null) {
1918                            query = new StringBundler(4 +
1919                                            (orderByComparator.getOrderByFields().length * 3));
1920                    }
1921                    else {
1922                            query = new StringBundler(4);
1923                    }
1924    
1925                    if (getDB().isSupportsInlineDistinct()) {
1926                            query.append(_FILTER_SQL_SELECT_SCFRAMEWORKVERSION_WHERE);
1927                    }
1928                    else {
1929                            query.append(_FILTER_SQL_SELECT_SCFRAMEWORKVERSION_NO_INLINE_DISTINCT_WHERE_1);
1930                    }
1931    
1932                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
1933    
1934                    query.append(_FINDER_COLUMN_G_A_ACTIVE_2_SQL);
1935    
1936                    if (!getDB().isSupportsInlineDistinct()) {
1937                            query.append(_FILTER_SQL_SELECT_SCFRAMEWORKVERSION_NO_INLINE_DISTINCT_WHERE_2);
1938                    }
1939    
1940                    if (orderByComparator != null) {
1941                            if (getDB().isSupportsInlineDistinct()) {
1942                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1943                                            orderByComparator, true);
1944                            }
1945                            else {
1946                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1947                                            orderByComparator, true);
1948                            }
1949                    }
1950                    else {
1951                            if (getDB().isSupportsInlineDistinct()) {
1952                                    query.append(SCFrameworkVersionModelImpl.ORDER_BY_JPQL);
1953                            }
1954                            else {
1955                                    query.append(SCFrameworkVersionModelImpl.ORDER_BY_SQL);
1956                            }
1957                    }
1958    
1959                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1960                                    SCFrameworkVersion.class.getName(),
1961                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1962    
1963                    Session session = null;
1964    
1965                    try {
1966                            session = openSession();
1967    
1968                            SQLQuery q = session.createSQLQuery(sql);
1969    
1970                            if (getDB().isSupportsInlineDistinct()) {
1971                                    q.addEntity(_FILTER_ENTITY_ALIAS, SCFrameworkVersionImpl.class);
1972                            }
1973                            else {
1974                                    q.addEntity(_FILTER_ENTITY_TABLE, SCFrameworkVersionImpl.class);
1975                            }
1976    
1977                            QueryPos qPos = QueryPos.getInstance(q);
1978    
1979                            qPos.add(groupId);
1980    
1981                            qPos.add(active);
1982    
1983                            return (List<SCFrameworkVersion>)QueryUtil.list(q, getDialect(),
1984                                    start, end);
1985                    }
1986                    catch (Exception e) {
1987                            throw processException(e);
1988                    }
1989                    finally {
1990                            closeSession(session);
1991                    }
1992            }
1993    
1994            /**
1995             * Returns the s c framework versions before and after the current s c framework version in the ordered set of s c framework versions that the user has permission to view where groupId = &#63; and active = &#63;.
1996             *
1997             * @param frameworkVersionId the primary key of the current s c framework version
1998             * @param groupId the group ID
1999             * @param active the active
2000             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2001             * @return the previous, current, and next s c framework version
2002             * @throws com.liferay.portlet.softwarecatalog.NoSuchFrameworkVersionException if a s c framework version with the primary key could not be found
2003             * @throws SystemException if a system exception occurred
2004             */
2005            public SCFrameworkVersion[] filterFindByG_A_PrevAndNext(
2006                    long frameworkVersionId, long groupId, boolean active,
2007                    OrderByComparator orderByComparator)
2008                    throws NoSuchFrameworkVersionException, SystemException {
2009                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2010                            return findByG_A_PrevAndNext(frameworkVersionId, groupId, active,
2011                                    orderByComparator);
2012                    }
2013    
2014                    SCFrameworkVersion scFrameworkVersion = findByPrimaryKey(frameworkVersionId);
2015    
2016                    Session session = null;
2017    
2018                    try {
2019                            session = openSession();
2020    
2021                            SCFrameworkVersion[] array = new SCFrameworkVersionImpl[3];
2022    
2023                            array[0] = filterGetByG_A_PrevAndNext(session, scFrameworkVersion,
2024                                            groupId, active, orderByComparator, true);
2025    
2026                            array[1] = scFrameworkVersion;
2027    
2028                            array[2] = filterGetByG_A_PrevAndNext(session, scFrameworkVersion,
2029                                            groupId, active, orderByComparator, false);
2030    
2031                            return array;
2032                    }
2033                    catch (Exception e) {
2034                            throw processException(e);
2035                    }
2036                    finally {
2037                            closeSession(session);
2038                    }
2039            }
2040    
2041            protected SCFrameworkVersion filterGetByG_A_PrevAndNext(Session session,
2042                    SCFrameworkVersion scFrameworkVersion, long groupId, boolean active,
2043                    OrderByComparator orderByComparator, boolean previous) {
2044                    StringBundler query = null;
2045    
2046                    if (orderByComparator != null) {
2047                            query = new StringBundler(6 +
2048                                            (orderByComparator.getOrderByFields().length * 6));
2049                    }
2050                    else {
2051                            query = new StringBundler(3);
2052                    }
2053    
2054                    if (getDB().isSupportsInlineDistinct()) {
2055                            query.append(_FILTER_SQL_SELECT_SCFRAMEWORKVERSION_WHERE);
2056                    }
2057                    else {
2058                            query.append(_FILTER_SQL_SELECT_SCFRAMEWORKVERSION_NO_INLINE_DISTINCT_WHERE_1);
2059                    }
2060    
2061                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
2062    
2063                    query.append(_FINDER_COLUMN_G_A_ACTIVE_2_SQL);
2064    
2065                    if (!getDB().isSupportsInlineDistinct()) {
2066                            query.append(_FILTER_SQL_SELECT_SCFRAMEWORKVERSION_NO_INLINE_DISTINCT_WHERE_2);
2067                    }
2068    
2069                    if (orderByComparator != null) {
2070                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2071    
2072                            if (orderByConditionFields.length > 0) {
2073                                    query.append(WHERE_AND);
2074                            }
2075    
2076                            for (int i = 0; i < orderByConditionFields.length; i++) {
2077                                    if (getDB().isSupportsInlineDistinct()) {
2078                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2079                                    }
2080                                    else {
2081                                            query.append(_ORDER_BY_ENTITY_TABLE);
2082                                    }
2083    
2084                                    query.append(orderByConditionFields[i]);
2085    
2086                                    if ((i + 1) < orderByConditionFields.length) {
2087                                            if (orderByComparator.isAscending() ^ previous) {
2088                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2089                                            }
2090                                            else {
2091                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2092                                            }
2093                                    }
2094                                    else {
2095                                            if (orderByComparator.isAscending() ^ previous) {
2096                                                    query.append(WHERE_GREATER_THAN);
2097                                            }
2098                                            else {
2099                                                    query.append(WHERE_LESSER_THAN);
2100                                            }
2101                                    }
2102                            }
2103    
2104                            query.append(ORDER_BY_CLAUSE);
2105    
2106                            String[] orderByFields = orderByComparator.getOrderByFields();
2107    
2108                            for (int i = 0; i < orderByFields.length; i++) {
2109                                    if (getDB().isSupportsInlineDistinct()) {
2110                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2111                                    }
2112                                    else {
2113                                            query.append(_ORDER_BY_ENTITY_TABLE);
2114                                    }
2115    
2116                                    query.append(orderByFields[i]);
2117    
2118                                    if ((i + 1) < orderByFields.length) {
2119                                            if (orderByComparator.isAscending() ^ previous) {
2120                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2121                                            }
2122                                            else {
2123                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2124                                            }
2125                                    }
2126                                    else {
2127                                            if (orderByComparator.isAscending() ^ previous) {
2128                                                    query.append(ORDER_BY_ASC);
2129                                            }
2130                                            else {
2131                                                    query.append(ORDER_BY_DESC);
2132                                            }
2133                                    }
2134                            }
2135                    }
2136                    else {
2137                            if (getDB().isSupportsInlineDistinct()) {
2138                                    query.append(SCFrameworkVersionModelImpl.ORDER_BY_JPQL);
2139                            }
2140                            else {
2141                                    query.append(SCFrameworkVersionModelImpl.ORDER_BY_SQL);
2142                            }
2143                    }
2144    
2145                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2146                                    SCFrameworkVersion.class.getName(),
2147                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2148    
2149                    SQLQuery q = session.createSQLQuery(sql);
2150    
2151                    q.setFirstResult(0);
2152                    q.setMaxResults(2);
2153    
2154                    if (getDB().isSupportsInlineDistinct()) {
2155                            q.addEntity(_FILTER_ENTITY_ALIAS, SCFrameworkVersionImpl.class);
2156                    }
2157                    else {
2158                            q.addEntity(_FILTER_ENTITY_TABLE, SCFrameworkVersionImpl.class);
2159                    }
2160    
2161                    QueryPos qPos = QueryPos.getInstance(q);
2162    
2163                    qPos.add(groupId);
2164    
2165                    qPos.add(active);
2166    
2167                    if (orderByComparator != null) {
2168                            Object[] values = orderByComparator.getOrderByConditionValues(scFrameworkVersion);
2169    
2170                            for (Object value : values) {
2171                                    qPos.add(value);
2172                            }
2173                    }
2174    
2175                    List<SCFrameworkVersion> list = q.list();
2176    
2177                    if (list.size() == 2) {
2178                            return list.get(1);
2179                    }
2180                    else {
2181                            return null;
2182                    }
2183            }
2184    
2185            /**
2186             * Removes all the s c framework versions where groupId = &#63; and active = &#63; from the database.
2187             *
2188             * @param groupId the group ID
2189             * @param active the active
2190             * @throws SystemException if a system exception occurred
2191             */
2192            public void removeByG_A(long groupId, boolean active)
2193                    throws SystemException {
2194                    for (SCFrameworkVersion scFrameworkVersion : findByG_A(groupId, active,
2195                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2196                            remove(scFrameworkVersion);
2197                    }
2198            }
2199    
2200            /**
2201             * Returns the number of s c framework versions where groupId = &#63; and active = &#63;.
2202             *
2203             * @param groupId the group ID
2204             * @param active the active
2205             * @return the number of matching s c framework versions
2206             * @throws SystemException if a system exception occurred
2207             */
2208            public int countByG_A(long groupId, boolean active)
2209                    throws SystemException {
2210                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A;
2211    
2212                    Object[] finderArgs = new Object[] { groupId, active };
2213    
2214                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2215                                    this);
2216    
2217                    if (count == null) {
2218                            StringBundler query = new StringBundler(3);
2219    
2220                            query.append(_SQL_COUNT_SCFRAMEWORKVERSION_WHERE);
2221    
2222                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
2223    
2224                            query.append(_FINDER_COLUMN_G_A_ACTIVE_2);
2225    
2226                            String sql = query.toString();
2227    
2228                            Session session = null;
2229    
2230                            try {
2231                                    session = openSession();
2232    
2233                                    Query q = session.createQuery(sql);
2234    
2235                                    QueryPos qPos = QueryPos.getInstance(q);
2236    
2237                                    qPos.add(groupId);
2238    
2239                                    qPos.add(active);
2240    
2241                                    count = (Long)q.uniqueResult();
2242    
2243                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2244                            }
2245                            catch (Exception e) {
2246                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2247    
2248                                    throw processException(e);
2249                            }
2250                            finally {
2251                                    closeSession(session);
2252                            }
2253                    }
2254    
2255                    return count.intValue();
2256            }
2257    
2258            /**
2259             * Returns the number of s c framework versions that the user has permission to view where groupId = &#63; and active = &#63;.
2260             *
2261             * @param groupId the group ID
2262             * @param active the active
2263             * @return the number of matching s c framework versions that the user has permission to view
2264             * @throws SystemException if a system exception occurred
2265             */
2266            public int filterCountByG_A(long groupId, boolean active)
2267                    throws SystemException {
2268                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2269                            return countByG_A(groupId, active);
2270                    }
2271    
2272                    StringBundler query = new StringBundler(3);
2273    
2274                    query.append(_FILTER_SQL_COUNT_SCFRAMEWORKVERSION_WHERE);
2275    
2276                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
2277    
2278                    query.append(_FINDER_COLUMN_G_A_ACTIVE_2_SQL);
2279    
2280                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2281                                    SCFrameworkVersion.class.getName(),
2282                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2283    
2284                    Session session = null;
2285    
2286                    try {
2287                            session = openSession();
2288    
2289                            SQLQuery q = session.createSQLQuery(sql);
2290    
2291                            q.addScalar(COUNT_COLUMN_NAME,
2292                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2293    
2294                            QueryPos qPos = QueryPos.getInstance(q);
2295    
2296                            qPos.add(groupId);
2297    
2298                            qPos.add(active);
2299    
2300                            Long count = (Long)q.uniqueResult();
2301    
2302                            return count.intValue();
2303                    }
2304                    catch (Exception e) {
2305                            throw processException(e);
2306                    }
2307                    finally {
2308                            closeSession(session);
2309                    }
2310            }
2311    
2312            private static final String _FINDER_COLUMN_G_A_GROUPID_2 = "scFrameworkVersion.groupId = ? AND ";
2313            private static final String _FINDER_COLUMN_G_A_ACTIVE_2 = "scFrameworkVersion.active = ?";
2314            private static final String _FINDER_COLUMN_G_A_ACTIVE_2_SQL = "scFrameworkVersion.active_ = ?";
2315    
2316            /**
2317             * Caches the s c framework version in the entity cache if it is enabled.
2318             *
2319             * @param scFrameworkVersion the s c framework version
2320             */
2321            public void cacheResult(SCFrameworkVersion scFrameworkVersion) {
2322                    EntityCacheUtil.putResult(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
2323                            SCFrameworkVersionImpl.class, scFrameworkVersion.getPrimaryKey(),
2324                            scFrameworkVersion);
2325    
2326                    scFrameworkVersion.resetOriginalValues();
2327            }
2328    
2329            /**
2330             * Caches the s c framework versions in the entity cache if it is enabled.
2331             *
2332             * @param scFrameworkVersions the s c framework versions
2333             */
2334            public void cacheResult(List<SCFrameworkVersion> scFrameworkVersions) {
2335                    for (SCFrameworkVersion scFrameworkVersion : scFrameworkVersions) {
2336                            if (EntityCacheUtil.getResult(
2337                                                    SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
2338                                                    SCFrameworkVersionImpl.class,
2339                                                    scFrameworkVersion.getPrimaryKey()) == null) {
2340                                    cacheResult(scFrameworkVersion);
2341                            }
2342                            else {
2343                                    scFrameworkVersion.resetOriginalValues();
2344                            }
2345                    }
2346            }
2347    
2348            /**
2349             * Clears the cache for all s c framework versions.
2350             *
2351             * <p>
2352             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
2353             * </p>
2354             */
2355            @Override
2356            public void clearCache() {
2357                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
2358                            CacheRegistryUtil.clear(SCFrameworkVersionImpl.class.getName());
2359                    }
2360    
2361                    EntityCacheUtil.clearCache(SCFrameworkVersionImpl.class.getName());
2362    
2363                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
2364                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2365                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2366            }
2367    
2368            /**
2369             * Clears the cache for the s c framework version.
2370             *
2371             * <p>
2372             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
2373             * </p>
2374             */
2375            @Override
2376            public void clearCache(SCFrameworkVersion scFrameworkVersion) {
2377                    EntityCacheUtil.removeResult(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
2378                            SCFrameworkVersionImpl.class, scFrameworkVersion.getPrimaryKey());
2379    
2380                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2381                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2382            }
2383    
2384            @Override
2385            public void clearCache(List<SCFrameworkVersion> scFrameworkVersions) {
2386                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2387                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2388    
2389                    for (SCFrameworkVersion scFrameworkVersion : scFrameworkVersions) {
2390                            EntityCacheUtil.removeResult(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
2391                                    SCFrameworkVersionImpl.class, scFrameworkVersion.getPrimaryKey());
2392                    }
2393            }
2394    
2395            /**
2396             * Creates a new s c framework version with the primary key. Does not add the s c framework version to the database.
2397             *
2398             * @param frameworkVersionId the primary key for the new s c framework version
2399             * @return the new s c framework version
2400             */
2401            public SCFrameworkVersion create(long frameworkVersionId) {
2402                    SCFrameworkVersion scFrameworkVersion = new SCFrameworkVersionImpl();
2403    
2404                    scFrameworkVersion.setNew(true);
2405                    scFrameworkVersion.setPrimaryKey(frameworkVersionId);
2406    
2407                    return scFrameworkVersion;
2408            }
2409    
2410            /**
2411             * Removes the s c framework version with the primary key from the database. Also notifies the appropriate model listeners.
2412             *
2413             * @param frameworkVersionId the primary key of the s c framework version
2414             * @return the s c framework version that was removed
2415             * @throws com.liferay.portlet.softwarecatalog.NoSuchFrameworkVersionException if a s c framework version with the primary key could not be found
2416             * @throws SystemException if a system exception occurred
2417             */
2418            public SCFrameworkVersion remove(long frameworkVersionId)
2419                    throws NoSuchFrameworkVersionException, SystemException {
2420                    return remove((Serializable)frameworkVersionId);
2421            }
2422    
2423            /**
2424             * Removes the s c framework version with the primary key from the database. Also notifies the appropriate model listeners.
2425             *
2426             * @param primaryKey the primary key of the s c framework version
2427             * @return the s c framework version that was removed
2428             * @throws com.liferay.portlet.softwarecatalog.NoSuchFrameworkVersionException if a s c framework version with the primary key could not be found
2429             * @throws SystemException if a system exception occurred
2430             */
2431            @Override
2432            public SCFrameworkVersion remove(Serializable primaryKey)
2433                    throws NoSuchFrameworkVersionException, SystemException {
2434                    Session session = null;
2435    
2436                    try {
2437                            session = openSession();
2438    
2439                            SCFrameworkVersion scFrameworkVersion = (SCFrameworkVersion)session.get(SCFrameworkVersionImpl.class,
2440                                            primaryKey);
2441    
2442                            if (scFrameworkVersion == null) {
2443                                    if (_log.isWarnEnabled()) {
2444                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2445                                    }
2446    
2447                                    throw new NoSuchFrameworkVersionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2448                                            primaryKey);
2449                            }
2450    
2451                            return remove(scFrameworkVersion);
2452                    }
2453                    catch (NoSuchFrameworkVersionException nsee) {
2454                            throw nsee;
2455                    }
2456                    catch (Exception e) {
2457                            throw processException(e);
2458                    }
2459                    finally {
2460                            closeSession(session);
2461                    }
2462            }
2463    
2464            @Override
2465            protected SCFrameworkVersion removeImpl(
2466                    SCFrameworkVersion scFrameworkVersion) throws SystemException {
2467                    scFrameworkVersion = toUnwrappedModel(scFrameworkVersion);
2468    
2469                    try {
2470                            clearSCProductVersions.clear(scFrameworkVersion.getPrimaryKey());
2471                    }
2472                    catch (Exception e) {
2473                            throw processException(e);
2474                    }
2475                    finally {
2476                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
2477                    }
2478    
2479                    Session session = null;
2480    
2481                    try {
2482                            session = openSession();
2483    
2484                            if (!session.contains(scFrameworkVersion)) {
2485                                    scFrameworkVersion = (SCFrameworkVersion)session.get(SCFrameworkVersionImpl.class,
2486                                                    scFrameworkVersion.getPrimaryKeyObj());
2487                            }
2488    
2489                            if (scFrameworkVersion != null) {
2490                                    session.delete(scFrameworkVersion);
2491                            }
2492                    }
2493                    catch (Exception e) {
2494                            throw processException(e);
2495                    }
2496                    finally {
2497                            closeSession(session);
2498                    }
2499    
2500                    if (scFrameworkVersion != null) {
2501                            clearCache(scFrameworkVersion);
2502                    }
2503    
2504                    return scFrameworkVersion;
2505            }
2506    
2507            @Override
2508            public SCFrameworkVersion updateImpl(
2509                    com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion)
2510                    throws SystemException {
2511                    scFrameworkVersion = toUnwrappedModel(scFrameworkVersion);
2512    
2513                    boolean isNew = scFrameworkVersion.isNew();
2514    
2515                    SCFrameworkVersionModelImpl scFrameworkVersionModelImpl = (SCFrameworkVersionModelImpl)scFrameworkVersion;
2516    
2517                    Session session = null;
2518    
2519                    try {
2520                            session = openSession();
2521    
2522                            if (scFrameworkVersion.isNew()) {
2523                                    session.save(scFrameworkVersion);
2524    
2525                                    scFrameworkVersion.setNew(false);
2526                            }
2527                            else {
2528                                    session.merge(scFrameworkVersion);
2529                            }
2530                    }
2531                    catch (Exception e) {
2532                            throw processException(e);
2533                    }
2534                    finally {
2535                            closeSession(session);
2536                    }
2537    
2538                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2539    
2540                    if (isNew || !SCFrameworkVersionModelImpl.COLUMN_BITMASK_ENABLED) {
2541                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2542                    }
2543    
2544                    else {
2545                            if ((scFrameworkVersionModelImpl.getColumnBitmask() &
2546                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
2547                                    Object[] args = new Object[] {
2548                                                    scFrameworkVersionModelImpl.getOriginalGroupId()
2549                                            };
2550    
2551                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
2552                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
2553                                            args);
2554    
2555                                    args = new Object[] { scFrameworkVersionModelImpl.getGroupId() };
2556    
2557                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
2558                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
2559                                            args);
2560                            }
2561    
2562                            if ((scFrameworkVersionModelImpl.getColumnBitmask() &
2563                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
2564                                    Object[] args = new Object[] {
2565                                                    scFrameworkVersionModelImpl.getOriginalCompanyId()
2566                                            };
2567    
2568                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
2569                                            args);
2570                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
2571                                            args);
2572    
2573                                    args = new Object[] { scFrameworkVersionModelImpl.getCompanyId() };
2574    
2575                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
2576                                            args);
2577                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
2578                                            args);
2579                            }
2580    
2581                            if ((scFrameworkVersionModelImpl.getColumnBitmask() &
2582                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A.getColumnBitmask()) != 0) {
2583                                    Object[] args = new Object[] {
2584                                                    scFrameworkVersionModelImpl.getOriginalGroupId(),
2585                                                    scFrameworkVersionModelImpl.getOriginalActive()
2586                                            };
2587    
2588                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
2589                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
2590                                            args);
2591    
2592                                    args = new Object[] {
2593                                                    scFrameworkVersionModelImpl.getGroupId(),
2594                                                    scFrameworkVersionModelImpl.getActive()
2595                                            };
2596    
2597                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
2598                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
2599                                            args);
2600                            }
2601                    }
2602    
2603                    EntityCacheUtil.putResult(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
2604                            SCFrameworkVersionImpl.class, scFrameworkVersion.getPrimaryKey(),
2605                            scFrameworkVersion);
2606    
2607                    return scFrameworkVersion;
2608            }
2609    
2610            protected SCFrameworkVersion toUnwrappedModel(
2611                    SCFrameworkVersion scFrameworkVersion) {
2612                    if (scFrameworkVersion instanceof SCFrameworkVersionImpl) {
2613                            return scFrameworkVersion;
2614                    }
2615    
2616                    SCFrameworkVersionImpl scFrameworkVersionImpl = new SCFrameworkVersionImpl();
2617    
2618                    scFrameworkVersionImpl.setNew(scFrameworkVersion.isNew());
2619                    scFrameworkVersionImpl.setPrimaryKey(scFrameworkVersion.getPrimaryKey());
2620    
2621                    scFrameworkVersionImpl.setFrameworkVersionId(scFrameworkVersion.getFrameworkVersionId());
2622                    scFrameworkVersionImpl.setGroupId(scFrameworkVersion.getGroupId());
2623                    scFrameworkVersionImpl.setCompanyId(scFrameworkVersion.getCompanyId());
2624                    scFrameworkVersionImpl.setUserId(scFrameworkVersion.getUserId());
2625                    scFrameworkVersionImpl.setUserName(scFrameworkVersion.getUserName());
2626                    scFrameworkVersionImpl.setCreateDate(scFrameworkVersion.getCreateDate());
2627                    scFrameworkVersionImpl.setModifiedDate(scFrameworkVersion.getModifiedDate());
2628                    scFrameworkVersionImpl.setName(scFrameworkVersion.getName());
2629                    scFrameworkVersionImpl.setUrl(scFrameworkVersion.getUrl());
2630                    scFrameworkVersionImpl.setActive(scFrameworkVersion.isActive());
2631                    scFrameworkVersionImpl.setPriority(scFrameworkVersion.getPriority());
2632    
2633                    return scFrameworkVersionImpl;
2634            }
2635    
2636            /**
2637             * Returns the s c framework version with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
2638             *
2639             * @param primaryKey the primary key of the s c framework version
2640             * @return the s c framework version
2641             * @throws com.liferay.portlet.softwarecatalog.NoSuchFrameworkVersionException if a s c framework version with the primary key could not be found
2642             * @throws SystemException if a system exception occurred
2643             */
2644            @Override
2645            public SCFrameworkVersion findByPrimaryKey(Serializable primaryKey)
2646                    throws NoSuchFrameworkVersionException, SystemException {
2647                    SCFrameworkVersion scFrameworkVersion = fetchByPrimaryKey(primaryKey);
2648    
2649                    if (scFrameworkVersion == null) {
2650                            if (_log.isWarnEnabled()) {
2651                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2652                            }
2653    
2654                            throw new NoSuchFrameworkVersionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2655                                    primaryKey);
2656                    }
2657    
2658                    return scFrameworkVersion;
2659            }
2660    
2661            /**
2662             * Returns the s c framework version with the primary key or throws a {@link com.liferay.portlet.softwarecatalog.NoSuchFrameworkVersionException} if it could not be found.
2663             *
2664             * @param frameworkVersionId the primary key of the s c framework version
2665             * @return the s c framework version
2666             * @throws com.liferay.portlet.softwarecatalog.NoSuchFrameworkVersionException if a s c framework version with the primary key could not be found
2667             * @throws SystemException if a system exception occurred
2668             */
2669            public SCFrameworkVersion findByPrimaryKey(long frameworkVersionId)
2670                    throws NoSuchFrameworkVersionException, SystemException {
2671                    return findByPrimaryKey((Serializable)frameworkVersionId);
2672            }
2673    
2674            /**
2675             * Returns the s c framework version with the primary key or returns <code>null</code> if it could not be found.
2676             *
2677             * @param primaryKey the primary key of the s c framework version
2678             * @return the s c framework version, or <code>null</code> if a s c framework version with the primary key could not be found
2679             * @throws SystemException if a system exception occurred
2680             */
2681            @Override
2682            public SCFrameworkVersion fetchByPrimaryKey(Serializable primaryKey)
2683                    throws SystemException {
2684                    SCFrameworkVersion scFrameworkVersion = (SCFrameworkVersion)EntityCacheUtil.getResult(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
2685                                    SCFrameworkVersionImpl.class, primaryKey);
2686    
2687                    if (scFrameworkVersion == _nullSCFrameworkVersion) {
2688                            return null;
2689                    }
2690    
2691                    if (scFrameworkVersion == null) {
2692                            Session session = null;
2693    
2694                            try {
2695                                    session = openSession();
2696    
2697                                    scFrameworkVersion = (SCFrameworkVersion)session.get(SCFrameworkVersionImpl.class,
2698                                                    primaryKey);
2699    
2700                                    if (scFrameworkVersion != null) {
2701                                            cacheResult(scFrameworkVersion);
2702                                    }
2703                                    else {
2704                                            EntityCacheUtil.putResult(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
2705                                                    SCFrameworkVersionImpl.class, primaryKey,
2706                                                    _nullSCFrameworkVersion);
2707                                    }
2708                            }
2709                            catch (Exception e) {
2710                                    EntityCacheUtil.removeResult(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
2711                                            SCFrameworkVersionImpl.class, primaryKey);
2712    
2713                                    throw processException(e);
2714                            }
2715                            finally {
2716                                    closeSession(session);
2717                            }
2718                    }
2719    
2720                    return scFrameworkVersion;
2721            }
2722    
2723            /**
2724             * Returns the s c framework version with the primary key or returns <code>null</code> if it could not be found.
2725             *
2726             * @param frameworkVersionId the primary key of the s c framework version
2727             * @return the s c framework version, or <code>null</code> if a s c framework version with the primary key could not be found
2728             * @throws SystemException if a system exception occurred
2729             */
2730            public SCFrameworkVersion fetchByPrimaryKey(long frameworkVersionId)
2731                    throws SystemException {
2732                    return fetchByPrimaryKey((Serializable)frameworkVersionId);
2733            }
2734    
2735            /**
2736             * Returns all the s c framework versions.
2737             *
2738             * @return the s c framework versions
2739             * @throws SystemException if a system exception occurred
2740             */
2741            public List<SCFrameworkVersion> findAll() throws SystemException {
2742                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2743            }
2744    
2745            /**
2746             * Returns a range of all the s c framework versions.
2747             *
2748             * <p>
2749             * 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.SCFrameworkVersionModelImpl}. 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.
2750             * </p>
2751             *
2752             * @param start the lower bound of the range of s c framework versions
2753             * @param end the upper bound of the range of s c framework versions (not inclusive)
2754             * @return the range of s c framework versions
2755             * @throws SystemException if a system exception occurred
2756             */
2757            public List<SCFrameworkVersion> findAll(int start, int end)
2758                    throws SystemException {
2759                    return findAll(start, end, null);
2760            }
2761    
2762            /**
2763             * Returns an ordered range of all the s c framework versions.
2764             *
2765             * <p>
2766             * 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.SCFrameworkVersionModelImpl}. 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.
2767             * </p>
2768             *
2769             * @param start the lower bound of the range of s c framework versions
2770             * @param end the upper bound of the range of s c framework versions (not inclusive)
2771             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2772             * @return the ordered range of s c framework versions
2773             * @throws SystemException if a system exception occurred
2774             */
2775            public List<SCFrameworkVersion> findAll(int start, int end,
2776                    OrderByComparator orderByComparator) throws SystemException {
2777                    boolean pagination = true;
2778                    FinderPath finderPath = null;
2779                    Object[] finderArgs = null;
2780    
2781                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2782                                    (orderByComparator == null)) {
2783                            pagination = false;
2784                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2785                            finderArgs = FINDER_ARGS_EMPTY;
2786                    }
2787                    else {
2788                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2789                            finderArgs = new Object[] { start, end, orderByComparator };
2790                    }
2791    
2792                    List<SCFrameworkVersion> list = (List<SCFrameworkVersion>)FinderCacheUtil.getResult(finderPath,
2793                                    finderArgs, this);
2794    
2795                    if (list == null) {
2796                            StringBundler query = null;
2797                            String sql = null;
2798    
2799                            if (orderByComparator != null) {
2800                                    query = new StringBundler(2 +
2801                                                    (orderByComparator.getOrderByFields().length * 3));
2802    
2803                                    query.append(_SQL_SELECT_SCFRAMEWORKVERSION);
2804    
2805                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2806                                            orderByComparator);
2807    
2808                                    sql = query.toString();
2809                            }
2810                            else {
2811                                    sql = _SQL_SELECT_SCFRAMEWORKVERSION;
2812    
2813                                    if (pagination) {
2814                                            sql = sql.concat(SCFrameworkVersionModelImpl.ORDER_BY_JPQL);
2815                                    }
2816                            }
2817    
2818                            Session session = null;
2819    
2820                            try {
2821                                    session = openSession();
2822    
2823                                    Query q = session.createQuery(sql);
2824    
2825                                    if (!pagination) {
2826                                            list = (List<SCFrameworkVersion>)QueryUtil.list(q,
2827                                                            getDialect(), start, end, false);
2828    
2829                                            Collections.sort(list);
2830    
2831                                            list = new UnmodifiableList<SCFrameworkVersion>(list);
2832                                    }
2833                                    else {
2834                                            list = (List<SCFrameworkVersion>)QueryUtil.list(q,
2835                                                            getDialect(), start, end);
2836                                    }
2837    
2838                                    cacheResult(list);
2839    
2840                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2841                            }
2842                            catch (Exception e) {
2843                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2844    
2845                                    throw processException(e);
2846                            }
2847                            finally {
2848                                    closeSession(session);
2849                            }
2850                    }
2851    
2852                    return list;
2853            }
2854    
2855            /**
2856             * Removes all the s c framework versions from the database.
2857             *
2858             * @throws SystemException if a system exception occurred
2859             */
2860            public void removeAll() throws SystemException {
2861                    for (SCFrameworkVersion scFrameworkVersion : findAll()) {
2862                            remove(scFrameworkVersion);
2863                    }
2864            }
2865    
2866            /**
2867             * Returns the number of s c framework versions.
2868             *
2869             * @return the number of s c framework versions
2870             * @throws SystemException if a system exception occurred
2871             */
2872            public int countAll() throws SystemException {
2873                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2874                                    FINDER_ARGS_EMPTY, this);
2875    
2876                    if (count == null) {
2877                            Session session = null;
2878    
2879                            try {
2880                                    session = openSession();
2881    
2882                                    Query q = session.createQuery(_SQL_COUNT_SCFRAMEWORKVERSION);
2883    
2884                                    count = (Long)q.uniqueResult();
2885    
2886                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2887                                            FINDER_ARGS_EMPTY, count);
2888                            }
2889                            catch (Exception e) {
2890                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
2891                                            FINDER_ARGS_EMPTY);
2892    
2893                                    throw processException(e);
2894                            }
2895                            finally {
2896                                    closeSession(session);
2897                            }
2898                    }
2899    
2900                    return count.intValue();
2901            }
2902    
2903            /**
2904             * Returns all the s c product versions associated with the s c framework version.
2905             *
2906             * @param pk the primary key of the s c framework version
2907             * @return the s c product versions associated with the s c framework version
2908             * @throws SystemException if a system exception occurred
2909             */
2910            public List<com.liferay.portlet.softwarecatalog.model.SCProductVersion> getSCProductVersions(
2911                    long pk) throws SystemException {
2912                    return getSCProductVersions(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2913            }
2914    
2915            /**
2916             * Returns a range of all the s c product versions associated with the s c framework version.
2917             *
2918             * <p>
2919             * 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.SCFrameworkVersionModelImpl}. 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.
2920             * </p>
2921             *
2922             * @param pk the primary key of the s c framework version
2923             * @param start the lower bound of the range of s c framework versions
2924             * @param end the upper bound of the range of s c framework versions (not inclusive)
2925             * @return the range of s c product versions associated with the s c framework version
2926             * @throws SystemException if a system exception occurred
2927             */
2928            public List<com.liferay.portlet.softwarecatalog.model.SCProductVersion> getSCProductVersions(
2929                    long pk, int start, int end) throws SystemException {
2930                    return getSCProductVersions(pk, start, end, null);
2931            }
2932    
2933            public static final FinderPath FINDER_PATH_GET_SCPRODUCTVERSIONS = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
2934                            SCFrameworkVersionModelImpl.FINDER_CACHE_ENABLED_SCFRAMEWORKVERSI_SCPRODUCTVERS,
2935                            com.liferay.portlet.softwarecatalog.model.impl.SCProductVersionImpl.class,
2936                            SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME,
2937                            "getSCProductVersions",
2938                            new String[] {
2939                                    Long.class.getName(), Integer.class.getName(),
2940                                    Integer.class.getName(), OrderByComparator.class.getName()
2941                            });
2942    
2943            static {
2944                    FINDER_PATH_GET_SCPRODUCTVERSIONS.setCacheKeyGeneratorCacheName(null);
2945            }
2946    
2947            /**
2948             * Returns an ordered range of all the s c product versions associated with the s c framework version.
2949             *
2950             * <p>
2951             * 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.SCFrameworkVersionModelImpl}. 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.
2952             * </p>
2953             *
2954             * @param pk the primary key of the s c framework version
2955             * @param start the lower bound of the range of s c framework versions
2956             * @param end the upper bound of the range of s c framework versions (not inclusive)
2957             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2958             * @return the ordered range of s c product versions associated with the s c framework version
2959             * @throws SystemException if a system exception occurred
2960             */
2961            public List<com.liferay.portlet.softwarecatalog.model.SCProductVersion> getSCProductVersions(
2962                    long pk, int start, int end, OrderByComparator orderByComparator)
2963                    throws SystemException {
2964                    boolean pagination = true;
2965                    Object[] finderArgs = null;
2966    
2967                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2968                                    (orderByComparator == null)) {
2969                            pagination = false;
2970                            finderArgs = new Object[] { pk };
2971                    }
2972                    else {
2973                            finderArgs = new Object[] { pk, start, end, orderByComparator };
2974                    }
2975    
2976                    List<com.liferay.portlet.softwarecatalog.model.SCProductVersion> list = (List<com.liferay.portlet.softwarecatalog.model.SCProductVersion>)FinderCacheUtil.getResult(FINDER_PATH_GET_SCPRODUCTVERSIONS,
2977                                    finderArgs, this);
2978    
2979                    if (list == null) {
2980                            Session session = null;
2981    
2982                            try {
2983                                    session = openSession();
2984    
2985                                    String sql = null;
2986    
2987                                    if (orderByComparator != null) {
2988                                            sql = _SQL_GETSCPRODUCTVERSIONS.concat(ORDER_BY_CLAUSE)
2989                                                                                                       .concat(orderByComparator.getOrderBy());
2990                                    }
2991                                    else {
2992                                            sql = _SQL_GETSCPRODUCTVERSIONS;
2993    
2994                                            if (pagination) {
2995                                                    sql = sql.concat(com.liferay.portlet.softwarecatalog.model.impl.SCProductVersionModelImpl.ORDER_BY_SQL);
2996                                            }
2997                                    }
2998    
2999                                    SQLQuery q = session.createSQLQuery(sql);
3000    
3001                                    q.addEntity("SCProductVersion",
3002                                            com.liferay.portlet.softwarecatalog.model.impl.SCProductVersionImpl.class);
3003    
3004                                    QueryPos qPos = QueryPos.getInstance(q);
3005    
3006                                    qPos.add(pk);
3007    
3008                                    if (!pagination) {
3009                                            list = (List<com.liferay.portlet.softwarecatalog.model.SCProductVersion>)QueryUtil.list(q,
3010                                                            getDialect(), start, end, false);
3011    
3012                                            Collections.sort(list);
3013    
3014                                            list = new UnmodifiableList<com.liferay.portlet.softwarecatalog.model.SCProductVersion>(list);
3015                                    }
3016                                    else {
3017                                            list = (List<com.liferay.portlet.softwarecatalog.model.SCProductVersion>)QueryUtil.list(q,
3018                                                            getDialect(), start, end);
3019                                    }
3020    
3021                                    scProductVersionPersistence.cacheResult(list);
3022    
3023                                    FinderCacheUtil.putResult(FINDER_PATH_GET_SCPRODUCTVERSIONS,
3024                                            finderArgs, list);
3025                            }
3026                            catch (Exception e) {
3027                                    FinderCacheUtil.removeResult(FINDER_PATH_GET_SCPRODUCTVERSIONS,
3028                                            finderArgs);
3029    
3030                                    throw processException(e);
3031                            }
3032                            finally {
3033                                    closeSession(session);
3034                            }
3035                    }
3036    
3037                    return list;
3038            }
3039    
3040            public static final FinderPath FINDER_PATH_GET_SCPRODUCTVERSIONS_SIZE = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
3041                            SCFrameworkVersionModelImpl.FINDER_CACHE_ENABLED_SCFRAMEWORKVERSI_SCPRODUCTVERS,
3042                            Long.class,
3043                            SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME,
3044                            "getSCProductVersionsSize", new String[] { Long.class.getName() });
3045    
3046            static {
3047                    FINDER_PATH_GET_SCPRODUCTVERSIONS_SIZE.setCacheKeyGeneratorCacheName(null);
3048            }
3049    
3050            /**
3051             * Returns the number of s c product versions associated with the s c framework version.
3052             *
3053             * @param pk the primary key of the s c framework version
3054             * @return the number of s c product versions associated with the s c framework version
3055             * @throws SystemException if a system exception occurred
3056             */
3057            public int getSCProductVersionsSize(long pk) throws SystemException {
3058                    Object[] finderArgs = new Object[] { pk };
3059    
3060                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_SCPRODUCTVERSIONS_SIZE,
3061                                    finderArgs, this);
3062    
3063                    if (count == null) {
3064                            Session session = null;
3065    
3066                            try {
3067                                    session = openSession();
3068    
3069                                    SQLQuery q = session.createSQLQuery(_SQL_GETSCPRODUCTVERSIONSSIZE);
3070    
3071                                    q.addScalar(COUNT_COLUMN_NAME,
3072                                            com.liferay.portal.kernel.dao.orm.Type.LONG);
3073    
3074                                    QueryPos qPos = QueryPos.getInstance(q);
3075    
3076                                    qPos.add(pk);
3077    
3078                                    count = (Long)q.uniqueResult();
3079    
3080                                    FinderCacheUtil.putResult(FINDER_PATH_GET_SCPRODUCTVERSIONS_SIZE,
3081                                            finderArgs, count);
3082                            }
3083                            catch (Exception e) {
3084                                    FinderCacheUtil.removeResult(FINDER_PATH_GET_SCPRODUCTVERSIONS_SIZE,
3085                                            finderArgs);
3086    
3087                                    throw processException(e);
3088                            }
3089                            finally {
3090                                    closeSession(session);
3091                            }
3092                    }
3093    
3094                    return count.intValue();
3095            }
3096    
3097            public static final FinderPath FINDER_PATH_CONTAINS_SCPRODUCTVERSION = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
3098                            SCFrameworkVersionModelImpl.FINDER_CACHE_ENABLED_SCFRAMEWORKVERSI_SCPRODUCTVERS,
3099                            Boolean.class,
3100                            SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME,
3101                            "containsSCProductVersion",
3102                            new String[] { Long.class.getName(), Long.class.getName() });
3103    
3104            /**
3105             * Returns <code>true</code> if the s c product version is associated with the s c framework version.
3106             *
3107             * @param pk the primary key of the s c framework version
3108             * @param scProductVersionPK the primary key of the s c product version
3109             * @return <code>true</code> if the s c product version is associated with the s c framework version; <code>false</code> otherwise
3110             * @throws SystemException if a system exception occurred
3111             */
3112            public boolean containsSCProductVersion(long pk, long scProductVersionPK)
3113                    throws SystemException {
3114                    Object[] finderArgs = new Object[] { pk, scProductVersionPK };
3115    
3116                    Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_SCPRODUCTVERSION,
3117                                    finderArgs, this);
3118    
3119                    if (value == null) {
3120                            try {
3121                                    value = Boolean.valueOf(containsSCProductVersion.contains(pk,
3122                                                            scProductVersionPK));
3123    
3124                                    FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_SCPRODUCTVERSION,
3125                                            finderArgs, value);
3126                            }
3127                            catch (Exception e) {
3128                                    FinderCacheUtil.removeResult(FINDER_PATH_CONTAINS_SCPRODUCTVERSION,
3129                                            finderArgs);
3130    
3131                                    throw processException(e);
3132                            }
3133                    }
3134    
3135                    return value.booleanValue();
3136            }
3137    
3138            /**
3139             * Returns <code>true</code> if the s c framework version has any s c product versions associated with it.
3140             *
3141             * @param pk the primary key of the s c framework version to check for associations with s c product versions
3142             * @return <code>true</code> if the s c framework version has any s c product versions associated with it; <code>false</code> otherwise
3143             * @throws SystemException if a system exception occurred
3144             */
3145            public boolean containsSCProductVersions(long pk) throws SystemException {
3146                    if (getSCProductVersionsSize(pk) > 0) {
3147                            return true;
3148                    }
3149                    else {
3150                            return false;
3151                    }
3152            }
3153    
3154            /**
3155             * Adds an association between the s c framework version and the s c product version. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3156             *
3157             * @param pk the primary key of the s c framework version
3158             * @param scProductVersionPK the primary key of the s c product version
3159             * @throws SystemException if a system exception occurred
3160             */
3161            public void addSCProductVersion(long pk, long scProductVersionPK)
3162                    throws SystemException {
3163                    try {
3164                            addSCProductVersion.add(pk, scProductVersionPK);
3165                    }
3166                    catch (Exception e) {
3167                            throw processException(e);
3168                    }
3169                    finally {
3170                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
3171                    }
3172            }
3173    
3174            /**
3175             * Adds an association between the s c framework version and the s c product version. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3176             *
3177             * @param pk the primary key of the s c framework version
3178             * @param scProductVersion the s c product version
3179             * @throws SystemException if a system exception occurred
3180             */
3181            public void addSCProductVersion(long pk,
3182                    com.liferay.portlet.softwarecatalog.model.SCProductVersion scProductVersion)
3183                    throws SystemException {
3184                    try {
3185                            addSCProductVersion.add(pk, scProductVersion.getPrimaryKey());
3186                    }
3187                    catch (Exception e) {
3188                            throw processException(e);
3189                    }
3190                    finally {
3191                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
3192                    }
3193            }
3194    
3195            /**
3196             * Adds an association between the s c framework version and the s c product versions. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3197             *
3198             * @param pk the primary key of the s c framework version
3199             * @param scProductVersionPKs the primary keys of the s c product versions
3200             * @throws SystemException if a system exception occurred
3201             */
3202            public void addSCProductVersions(long pk, long[] scProductVersionPKs)
3203                    throws SystemException {
3204                    try {
3205                            for (long scProductVersionPK : scProductVersionPKs) {
3206                                    addSCProductVersion.add(pk, scProductVersionPK);
3207                            }
3208                    }
3209                    catch (Exception e) {
3210                            throw processException(e);
3211                    }
3212                    finally {
3213                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
3214                    }
3215            }
3216    
3217            /**
3218             * Adds an association between the s c framework version and the s c product versions. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3219             *
3220             * @param pk the primary key of the s c framework version
3221             * @param scProductVersions the s c product versions
3222             * @throws SystemException if a system exception occurred
3223             */
3224            public void addSCProductVersions(long pk,
3225                    List<com.liferay.portlet.softwarecatalog.model.SCProductVersion> scProductVersions)
3226                    throws SystemException {
3227                    try {
3228                            for (com.liferay.portlet.softwarecatalog.model.SCProductVersion scProductVersion : scProductVersions) {
3229                                    addSCProductVersion.add(pk, scProductVersion.getPrimaryKey());
3230                            }
3231                    }
3232                    catch (Exception e) {
3233                            throw processException(e);
3234                    }
3235                    finally {
3236                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
3237                    }
3238            }
3239    
3240            /**
3241             * Clears all associations between the s c framework version and its s c product versions. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3242             *
3243             * @param pk the primary key of the s c framework version to clear the associated s c product versions from
3244             * @throws SystemException if a system exception occurred
3245             */
3246            public void clearSCProductVersions(long pk) throws SystemException {
3247                    try {
3248                            clearSCProductVersions.clear(pk);
3249                    }
3250                    catch (Exception e) {
3251                            throw processException(e);
3252                    }
3253                    finally {
3254                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
3255                    }
3256            }
3257    
3258            /**
3259             * Removes the association between the s c framework version and the s c product version. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3260             *
3261             * @param pk the primary key of the s c framework version
3262             * @param scProductVersionPK the primary key of the s c product version
3263             * @throws SystemException if a system exception occurred
3264             */
3265            public void removeSCProductVersion(long pk, long scProductVersionPK)
3266                    throws SystemException {
3267                    try {
3268                            removeSCProductVersion.remove(pk, scProductVersionPK);
3269                    }
3270                    catch (Exception e) {
3271                            throw processException(e);
3272                    }
3273                    finally {
3274                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
3275                    }
3276            }
3277    
3278            /**
3279             * Removes the association between the s c framework version and the s c product version. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3280             *
3281             * @param pk the primary key of the s c framework version
3282             * @param scProductVersion the s c product version
3283             * @throws SystemException if a system exception occurred
3284             */
3285            public void removeSCProductVersion(long pk,
3286                    com.liferay.portlet.softwarecatalog.model.SCProductVersion scProductVersion)
3287                    throws SystemException {
3288                    try {
3289                            removeSCProductVersion.remove(pk, scProductVersion.getPrimaryKey());
3290                    }
3291                    catch (Exception e) {
3292                            throw processException(e);
3293                    }
3294                    finally {
3295                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
3296                    }
3297            }
3298    
3299            /**
3300             * Removes the association between the s c framework version and the s c product versions. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3301             *
3302             * @param pk the primary key of the s c framework version
3303             * @param scProductVersionPKs the primary keys of the s c product versions
3304             * @throws SystemException if a system exception occurred
3305             */
3306            public void removeSCProductVersions(long pk, long[] scProductVersionPKs)
3307                    throws SystemException {
3308                    try {
3309                            for (long scProductVersionPK : scProductVersionPKs) {
3310                                    removeSCProductVersion.remove(pk, scProductVersionPK);
3311                            }
3312                    }
3313                    catch (Exception e) {
3314                            throw processException(e);
3315                    }
3316                    finally {
3317                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
3318                    }
3319            }
3320    
3321            /**
3322             * Removes the association between the s c framework version and the s c product versions. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3323             *
3324             * @param pk the primary key of the s c framework version
3325             * @param scProductVersions the s c product versions
3326             * @throws SystemException if a system exception occurred
3327             */
3328            public void removeSCProductVersions(long pk,
3329                    List<com.liferay.portlet.softwarecatalog.model.SCProductVersion> scProductVersions)
3330                    throws SystemException {
3331                    try {
3332                            for (com.liferay.portlet.softwarecatalog.model.SCProductVersion scProductVersion : scProductVersions) {
3333                                    removeSCProductVersion.remove(pk,
3334                                            scProductVersion.getPrimaryKey());
3335                            }
3336                    }
3337                    catch (Exception e) {
3338                            throw processException(e);
3339                    }
3340                    finally {
3341                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
3342                    }
3343            }
3344    
3345            /**
3346             * Sets the s c product versions associated with the s c framework version, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3347             *
3348             * @param pk the primary key of the s c framework version
3349             * @param scProductVersionPKs the primary keys of the s c product versions to be associated with the s c framework version
3350             * @throws SystemException if a system exception occurred
3351             */
3352            public void setSCProductVersions(long pk, long[] scProductVersionPKs)
3353                    throws SystemException {
3354                    try {
3355                            Set<Long> scProductVersionPKSet = SetUtil.fromArray(scProductVersionPKs);
3356    
3357                            List<com.liferay.portlet.softwarecatalog.model.SCProductVersion> scProductVersions =
3358                                    getSCProductVersions(pk);
3359    
3360                            for (com.liferay.portlet.softwarecatalog.model.SCProductVersion scProductVersion : scProductVersions) {
3361                                    if (!scProductVersionPKSet.remove(
3362                                                            scProductVersion.getPrimaryKey())) {
3363                                            removeSCProductVersion.remove(pk,
3364                                                    scProductVersion.getPrimaryKey());
3365                                    }
3366                            }
3367    
3368                            for (Long scProductVersionPK : scProductVersionPKSet) {
3369                                    addSCProductVersion.add(pk, scProductVersionPK);
3370                            }
3371                    }
3372                    catch (Exception e) {
3373                            throw processException(e);
3374                    }
3375                    finally {
3376                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
3377                    }
3378            }
3379    
3380            /**
3381             * Sets the s c product versions associated with the s c framework version, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3382             *
3383             * @param pk the primary key of the s c framework version
3384             * @param scProductVersions the s c product versions to be associated with the s c framework version
3385             * @throws SystemException if a system exception occurred
3386             */
3387            public void setSCProductVersions(long pk,
3388                    List<com.liferay.portlet.softwarecatalog.model.SCProductVersion> scProductVersions)
3389                    throws SystemException {
3390                    try {
3391                            long[] scProductVersionPKs = new long[scProductVersions.size()];
3392    
3393                            for (int i = 0; i < scProductVersions.size(); i++) {
3394                                    com.liferay.portlet.softwarecatalog.model.SCProductVersion scProductVersion =
3395                                            scProductVersions.get(i);
3396    
3397                                    scProductVersionPKs[i] = scProductVersion.getPrimaryKey();
3398                            }
3399    
3400                            setSCProductVersions(pk, scProductVersionPKs);
3401                    }
3402                    catch (Exception e) {
3403                            throw processException(e);
3404                    }
3405                    finally {
3406                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
3407                    }
3408            }
3409    
3410            @Override
3411            protected Set<String> getBadColumnNames() {
3412                    return _badColumnNames;
3413            }
3414    
3415            /**
3416             * Initializes the s c framework version persistence.
3417             */
3418            public void afterPropertiesSet() {
3419                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3420                                            com.liferay.portal.util.PropsUtil.get(
3421                                                    "value.object.listener.com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion")));
3422    
3423                    if (listenerClassNames.length > 0) {
3424                            try {
3425                                    List<ModelListener<SCFrameworkVersion>> listenersList = new ArrayList<ModelListener<SCFrameworkVersion>>();
3426    
3427                                    for (String listenerClassName : listenerClassNames) {
3428                                            listenersList.add((ModelListener<SCFrameworkVersion>)InstanceFactory.newInstance(
3429                                                            getClassLoader(), listenerClassName));
3430                                    }
3431    
3432                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3433                            }
3434                            catch (Exception e) {
3435                                    _log.error(e);
3436                            }
3437                    }
3438    
3439                    containsSCProductVersion = new ContainsSCProductVersion();
3440    
3441                    addSCProductVersion = new AddSCProductVersion();
3442                    clearSCProductVersions = new ClearSCProductVersions();
3443                    removeSCProductVersion = new RemoveSCProductVersion();
3444            }
3445    
3446            public void destroy() {
3447                    EntityCacheUtil.removeCache(SCFrameworkVersionImpl.class.getName());
3448                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3449                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3450                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3451            }
3452    
3453            @BeanReference(type = SCProductVersionPersistence.class)
3454            protected SCProductVersionPersistence scProductVersionPersistence;
3455            protected ContainsSCProductVersion containsSCProductVersion;
3456            protected AddSCProductVersion addSCProductVersion;
3457            protected ClearSCProductVersions clearSCProductVersions;
3458            protected RemoveSCProductVersion removeSCProductVersion;
3459    
3460            protected class ContainsSCProductVersion {
3461                    protected ContainsSCProductVersion() {
3462                            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
3463                                            "SELECT COUNT(*) AS COUNT_VALUE FROM SCFrameworkVersi_SCProductVers WHERE frameworkVersionId = ? AND productVersionId = ?",
3464                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
3465                                            RowMapper.COUNT);
3466                    }
3467    
3468                    protected boolean contains(long frameworkVersionId,
3469                            long productVersionId) {
3470                            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
3471                                                    new Long(frameworkVersionId), new Long(productVersionId)
3472                                            });
3473    
3474                            if (results.size() > 0) {
3475                                    Integer count = results.get(0);
3476    
3477                                    if (count.intValue() > 0) {
3478                                            return true;
3479                                    }
3480                            }
3481    
3482                            return false;
3483                    }
3484    
3485                    private MappingSqlQuery<Integer> _mappingSqlQuery;
3486            }
3487    
3488            protected class AddSCProductVersion {
3489                    protected AddSCProductVersion() {
3490                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3491                                            "INSERT INTO SCFrameworkVersi_SCProductVers (frameworkVersionId, productVersionId) VALUES (?, ?)",
3492                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3493                    }
3494    
3495                    protected void add(long frameworkVersionId, long productVersionId)
3496                            throws SystemException {
3497                            if (!containsSCProductVersion.contains(frameworkVersionId,
3498                                                    productVersionId)) {
3499                                    ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductVersion>[] scProductVersionListeners =
3500                                            scProductVersionPersistence.getListeners();
3501    
3502                                    for (ModelListener<SCFrameworkVersion> listener : listeners) {
3503                                            listener.onBeforeAddAssociation(frameworkVersionId,
3504                                                    com.liferay.portlet.softwarecatalog.model.SCProductVersion.class.getName(),
3505                                                    productVersionId);
3506                                    }
3507    
3508                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductVersion> listener : scProductVersionListeners) {
3509                                            listener.onBeforeAddAssociation(productVersionId,
3510                                                    SCFrameworkVersion.class.getName(), frameworkVersionId);
3511                                    }
3512    
3513                                    _sqlUpdate.update(new Object[] {
3514                                                    new Long(frameworkVersionId), new Long(productVersionId)
3515                                            });
3516    
3517                                    for (ModelListener<SCFrameworkVersion> listener : listeners) {
3518                                            listener.onAfterAddAssociation(frameworkVersionId,
3519                                                    com.liferay.portlet.softwarecatalog.model.SCProductVersion.class.getName(),
3520                                                    productVersionId);
3521                                    }
3522    
3523                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductVersion> listener : scProductVersionListeners) {
3524                                            listener.onAfterAddAssociation(productVersionId,
3525                                                    SCFrameworkVersion.class.getName(), frameworkVersionId);
3526                                    }
3527                            }
3528                    }
3529    
3530                    private SqlUpdate _sqlUpdate;
3531            }
3532    
3533            protected class ClearSCProductVersions {
3534                    protected ClearSCProductVersions() {
3535                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3536                                            "DELETE FROM SCFrameworkVersi_SCProductVers WHERE frameworkVersionId = ?",
3537                                            new int[] { java.sql.Types.BIGINT });
3538                    }
3539    
3540                    protected void clear(long frameworkVersionId) throws SystemException {
3541                            ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductVersion>[] scProductVersionListeners =
3542                                    scProductVersionPersistence.getListeners();
3543    
3544                            List<com.liferay.portlet.softwarecatalog.model.SCProductVersion> scProductVersions =
3545                                    null;
3546    
3547                            if ((listeners.length > 0) ||
3548                                            (scProductVersionListeners.length > 0)) {
3549                                    scProductVersions = getSCProductVersions(frameworkVersionId);
3550    
3551                                    for (com.liferay.portlet.softwarecatalog.model.SCProductVersion scProductVersion : scProductVersions) {
3552                                            for (ModelListener<SCFrameworkVersion> listener : listeners) {
3553                                                    listener.onBeforeRemoveAssociation(frameworkVersionId,
3554                                                            com.liferay.portlet.softwarecatalog.model.SCProductVersion.class.getName(),
3555                                                            scProductVersion.getPrimaryKey());
3556                                            }
3557    
3558                                            for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductVersion> listener : scProductVersionListeners) {
3559                                                    listener.onBeforeRemoveAssociation(scProductVersion.getPrimaryKey(),
3560                                                            SCFrameworkVersion.class.getName(),
3561                                                            frameworkVersionId);
3562                                            }
3563                                    }
3564                            }
3565    
3566                            _sqlUpdate.update(new Object[] { new Long(frameworkVersionId) });
3567    
3568                            if ((listeners.length > 0) ||
3569                                            (scProductVersionListeners.length > 0)) {
3570                                    for (com.liferay.portlet.softwarecatalog.model.SCProductVersion scProductVersion : scProductVersions) {
3571                                            for (ModelListener<SCFrameworkVersion> listener : listeners) {
3572                                                    listener.onAfterRemoveAssociation(frameworkVersionId,
3573                                                            com.liferay.portlet.softwarecatalog.model.SCProductVersion.class.getName(),
3574                                                            scProductVersion.getPrimaryKey());
3575                                            }
3576    
3577                                            for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductVersion> listener : scProductVersionListeners) {
3578                                                    listener.onAfterRemoveAssociation(scProductVersion.getPrimaryKey(),
3579                                                            SCFrameworkVersion.class.getName(),
3580                                                            frameworkVersionId);
3581                                            }
3582                                    }
3583                            }
3584                    }
3585    
3586                    private SqlUpdate _sqlUpdate;
3587            }
3588    
3589            protected class RemoveSCProductVersion {
3590                    protected RemoveSCProductVersion() {
3591                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3592                                            "DELETE FROM SCFrameworkVersi_SCProductVers WHERE frameworkVersionId = ? AND productVersionId = ?",
3593                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3594                    }
3595    
3596                    protected void remove(long frameworkVersionId, long productVersionId)
3597                            throws SystemException {
3598                            if (containsSCProductVersion.contains(frameworkVersionId,
3599                                                    productVersionId)) {
3600                                    ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductVersion>[] scProductVersionListeners =
3601                                            scProductVersionPersistence.getListeners();
3602    
3603                                    for (ModelListener<SCFrameworkVersion> listener : listeners) {
3604                                            listener.onBeforeRemoveAssociation(frameworkVersionId,
3605                                                    com.liferay.portlet.softwarecatalog.model.SCProductVersion.class.getName(),
3606                                                    productVersionId);
3607                                    }
3608    
3609                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductVersion> listener : scProductVersionListeners) {
3610                                            listener.onBeforeRemoveAssociation(productVersionId,
3611                                                    SCFrameworkVersion.class.getName(), frameworkVersionId);
3612                                    }
3613    
3614                                    _sqlUpdate.update(new Object[] {
3615                                                    new Long(frameworkVersionId), new Long(productVersionId)
3616                                            });
3617    
3618                                    for (ModelListener<SCFrameworkVersion> listener : listeners) {
3619                                            listener.onAfterRemoveAssociation(frameworkVersionId,
3620                                                    com.liferay.portlet.softwarecatalog.model.SCProductVersion.class.getName(),
3621                                                    productVersionId);
3622                                    }
3623    
3624                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductVersion> listener : scProductVersionListeners) {
3625                                            listener.onAfterRemoveAssociation(productVersionId,
3626                                                    SCFrameworkVersion.class.getName(), frameworkVersionId);
3627                                    }
3628                            }
3629                    }
3630    
3631                    private SqlUpdate _sqlUpdate;
3632            }
3633    
3634            private static final String _SQL_SELECT_SCFRAMEWORKVERSION = "SELECT scFrameworkVersion FROM SCFrameworkVersion scFrameworkVersion";
3635            private static final String _SQL_SELECT_SCFRAMEWORKVERSION_WHERE = "SELECT scFrameworkVersion FROM SCFrameworkVersion scFrameworkVersion WHERE ";
3636            private static final String _SQL_COUNT_SCFRAMEWORKVERSION = "SELECT COUNT(scFrameworkVersion) FROM SCFrameworkVersion scFrameworkVersion";
3637            private static final String _SQL_COUNT_SCFRAMEWORKVERSION_WHERE = "SELECT COUNT(scFrameworkVersion) FROM SCFrameworkVersion scFrameworkVersion WHERE ";
3638            private static final String _SQL_GETSCPRODUCTVERSIONS = "SELECT {SCProductVersion.*} FROM SCProductVersion INNER JOIN SCFrameworkVersi_SCProductVers ON (SCFrameworkVersi_SCProductVers.productVersionId = SCProductVersion.productVersionId) WHERE (SCFrameworkVersi_SCProductVers.frameworkVersionId = ?)";
3639            private static final String _SQL_GETSCPRODUCTVERSIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCFrameworkVersi_SCProductVers WHERE frameworkVersionId = ?";
3640            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "scFrameworkVersion.frameworkVersionId";
3641            private static final String _FILTER_SQL_SELECT_SCFRAMEWORKVERSION_WHERE = "SELECT DISTINCT {scFrameworkVersion.*} FROM SCFrameworkVersion scFrameworkVersion WHERE ";
3642            private static final String _FILTER_SQL_SELECT_SCFRAMEWORKVERSION_NO_INLINE_DISTINCT_WHERE_1 =
3643                    "SELECT {SCFrameworkVersion.*} FROM (SELECT DISTINCT scFrameworkVersion.frameworkVersionId FROM SCFrameworkVersion scFrameworkVersion WHERE ";
3644            private static final String _FILTER_SQL_SELECT_SCFRAMEWORKVERSION_NO_INLINE_DISTINCT_WHERE_2 =
3645                    ") TEMP_TABLE INNER JOIN SCFrameworkVersion ON TEMP_TABLE.frameworkVersionId = SCFrameworkVersion.frameworkVersionId";
3646            private static final String _FILTER_SQL_COUNT_SCFRAMEWORKVERSION_WHERE = "SELECT COUNT(DISTINCT scFrameworkVersion.frameworkVersionId) AS COUNT_VALUE FROM SCFrameworkVersion scFrameworkVersion WHERE ";
3647            private static final String _FILTER_ENTITY_ALIAS = "scFrameworkVersion";
3648            private static final String _FILTER_ENTITY_TABLE = "SCFrameworkVersion";
3649            private static final String _ORDER_BY_ENTITY_ALIAS = "scFrameworkVersion.";
3650            private static final String _ORDER_BY_ENTITY_TABLE = "SCFrameworkVersion.";
3651            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SCFrameworkVersion exists with the primary key ";
3652            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SCFrameworkVersion exists with the key {";
3653            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3654            private static Log _log = LogFactoryUtil.getLog(SCFrameworkVersionPersistenceImpl.class);
3655            private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
3656                                    "active"
3657                            });
3658            private static SCFrameworkVersion _nullSCFrameworkVersion = new SCFrameworkVersionImpl() {
3659                            @Override
3660                            public Object clone() {
3661                                    return this;
3662                            }
3663    
3664                            @Override
3665                            public CacheModel<SCFrameworkVersion> toCacheModel() {
3666                                    return _nullSCFrameworkVersionCacheModel;
3667                            }
3668                    };
3669    
3670            private static CacheModel<SCFrameworkVersion> _nullSCFrameworkVersionCacheModel =
3671                    new CacheModel<SCFrameworkVersion>() {
3672                            public SCFrameworkVersion toEntityModel() {
3673                                    return _nullSCFrameworkVersion;
3674                            }
3675                    };
3676    }