001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.softwarecatalog.service.persistence;
016    
017    import com.liferay.portal.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);
588                            }
589                            else {
590                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
591                                            orderByComparator);
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);
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);
1944                            }
1945                            else {
1946                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1947                                            orderByComparator);
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);
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);
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    
2315            /**
2316             * Caches the s c framework version in the entity cache if it is enabled.
2317             *
2318             * @param scFrameworkVersion the s c framework version
2319             */
2320            public void cacheResult(SCFrameworkVersion scFrameworkVersion) {
2321                    EntityCacheUtil.putResult(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
2322                            SCFrameworkVersionImpl.class, scFrameworkVersion.getPrimaryKey(),
2323                            scFrameworkVersion);
2324    
2325                    scFrameworkVersion.resetOriginalValues();
2326            }
2327    
2328            /**
2329             * Caches the s c framework versions in the entity cache if it is enabled.
2330             *
2331             * @param scFrameworkVersions the s c framework versions
2332             */
2333            public void cacheResult(List<SCFrameworkVersion> scFrameworkVersions) {
2334                    for (SCFrameworkVersion scFrameworkVersion : scFrameworkVersions) {
2335                            if (EntityCacheUtil.getResult(
2336                                                    SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
2337                                                    SCFrameworkVersionImpl.class,
2338                                                    scFrameworkVersion.getPrimaryKey()) == null) {
2339                                    cacheResult(scFrameworkVersion);
2340                            }
2341                            else {
2342                                    scFrameworkVersion.resetOriginalValues();
2343                            }
2344                    }
2345            }
2346    
2347            /**
2348             * Clears the cache for all s c framework versions.
2349             *
2350             * <p>
2351             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
2352             * </p>
2353             */
2354            @Override
2355            public void clearCache() {
2356                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
2357                            CacheRegistryUtil.clear(SCFrameworkVersionImpl.class.getName());
2358                    }
2359    
2360                    EntityCacheUtil.clearCache(SCFrameworkVersionImpl.class.getName());
2361    
2362                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
2363                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2364                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2365            }
2366    
2367            /**
2368             * Clears the cache for the s c framework version.
2369             *
2370             * <p>
2371             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
2372             * </p>
2373             */
2374            @Override
2375            public void clearCache(SCFrameworkVersion scFrameworkVersion) {
2376                    EntityCacheUtil.removeResult(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
2377                            SCFrameworkVersionImpl.class, scFrameworkVersion.getPrimaryKey());
2378    
2379                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2380                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2381            }
2382    
2383            @Override
2384            public void clearCache(List<SCFrameworkVersion> scFrameworkVersions) {
2385                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2386                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2387    
2388                    for (SCFrameworkVersion scFrameworkVersion : scFrameworkVersions) {
2389                            EntityCacheUtil.removeResult(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
2390                                    SCFrameworkVersionImpl.class, scFrameworkVersion.getPrimaryKey());
2391                    }
2392            }
2393    
2394            /**
2395             * Creates a new s c framework version with the primary key. Does not add the s c framework version to the database.
2396             *
2397             * @param frameworkVersionId the primary key for the new s c framework version
2398             * @return the new s c framework version
2399             */
2400            public SCFrameworkVersion create(long frameworkVersionId) {
2401                    SCFrameworkVersion scFrameworkVersion = new SCFrameworkVersionImpl();
2402    
2403                    scFrameworkVersion.setNew(true);
2404                    scFrameworkVersion.setPrimaryKey(frameworkVersionId);
2405    
2406                    return scFrameworkVersion;
2407            }
2408    
2409            /**
2410             * Removes the s c framework version with the primary key from the database. Also notifies the appropriate model listeners.
2411             *
2412             * @param frameworkVersionId the primary key of the s c framework version
2413             * @return the s c framework version that was removed
2414             * @throws com.liferay.portlet.softwarecatalog.NoSuchFrameworkVersionException if a s c framework version with the primary key could not be found
2415             * @throws SystemException if a system exception occurred
2416             */
2417            public SCFrameworkVersion remove(long frameworkVersionId)
2418                    throws NoSuchFrameworkVersionException, SystemException {
2419                    return remove((Serializable)frameworkVersionId);
2420            }
2421    
2422            /**
2423             * Removes the s c framework version with the primary key from the database. Also notifies the appropriate model listeners.
2424             *
2425             * @param primaryKey the primary key of the s c framework version
2426             * @return the s c framework version that was removed
2427             * @throws com.liferay.portlet.softwarecatalog.NoSuchFrameworkVersionException if a s c framework version with the primary key could not be found
2428             * @throws SystemException if a system exception occurred
2429             */
2430            @Override
2431            public SCFrameworkVersion remove(Serializable primaryKey)
2432                    throws NoSuchFrameworkVersionException, SystemException {
2433                    Session session = null;
2434    
2435                    try {
2436                            session = openSession();
2437    
2438                            SCFrameworkVersion scFrameworkVersion = (SCFrameworkVersion)session.get(SCFrameworkVersionImpl.class,
2439                                            primaryKey);
2440    
2441                            if (scFrameworkVersion == null) {
2442                                    if (_log.isWarnEnabled()) {
2443                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2444                                    }
2445    
2446                                    throw new NoSuchFrameworkVersionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2447                                            primaryKey);
2448                            }
2449    
2450                            return remove(scFrameworkVersion);
2451                    }
2452                    catch (NoSuchFrameworkVersionException nsee) {
2453                            throw nsee;
2454                    }
2455                    catch (Exception e) {
2456                            throw processException(e);
2457                    }
2458                    finally {
2459                            closeSession(session);
2460                    }
2461            }
2462    
2463            @Override
2464            protected SCFrameworkVersion removeImpl(
2465                    SCFrameworkVersion scFrameworkVersion) throws SystemException {
2466                    scFrameworkVersion = toUnwrappedModel(scFrameworkVersion);
2467    
2468                    try {
2469                            clearSCProductVersions.clear(scFrameworkVersion.getPrimaryKey());
2470                    }
2471                    catch (Exception e) {
2472                            throw processException(e);
2473                    }
2474                    finally {
2475                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
2476                    }
2477    
2478                    Session session = null;
2479    
2480                    try {
2481                            session = openSession();
2482    
2483                            if (!session.contains(scFrameworkVersion)) {
2484                                    scFrameworkVersion = (SCFrameworkVersion)session.get(SCFrameworkVersionImpl.class,
2485                                                    scFrameworkVersion.getPrimaryKeyObj());
2486                            }
2487    
2488                            if (scFrameworkVersion != null) {
2489                                    session.delete(scFrameworkVersion);
2490                            }
2491                    }
2492                    catch (Exception e) {
2493                            throw processException(e);
2494                    }
2495                    finally {
2496                            closeSession(session);
2497                    }
2498    
2499                    if (scFrameworkVersion != null) {
2500                            clearCache(scFrameworkVersion);
2501                    }
2502    
2503                    return scFrameworkVersion;
2504            }
2505    
2506            @Override
2507            public SCFrameworkVersion updateImpl(
2508                    com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion)
2509                    throws SystemException {
2510                    scFrameworkVersion = toUnwrappedModel(scFrameworkVersion);
2511    
2512                    boolean isNew = scFrameworkVersion.isNew();
2513    
2514                    SCFrameworkVersionModelImpl scFrameworkVersionModelImpl = (SCFrameworkVersionModelImpl)scFrameworkVersion;
2515    
2516                    Session session = null;
2517    
2518                    try {
2519                            session = openSession();
2520    
2521                            if (scFrameworkVersion.isNew()) {
2522                                    session.save(scFrameworkVersion);
2523    
2524                                    scFrameworkVersion.setNew(false);
2525                            }
2526                            else {
2527                                    session.merge(scFrameworkVersion);
2528                            }
2529                    }
2530                    catch (Exception e) {
2531                            throw processException(e);
2532                    }
2533                    finally {
2534                            closeSession(session);
2535                    }
2536    
2537                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2538    
2539                    if (isNew || !SCFrameworkVersionModelImpl.COLUMN_BITMASK_ENABLED) {
2540                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2541                    }
2542    
2543                    else {
2544                            if ((scFrameworkVersionModelImpl.getColumnBitmask() &
2545                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
2546                                    Object[] args = new Object[] {
2547                                                    scFrameworkVersionModelImpl.getOriginalGroupId()
2548                                            };
2549    
2550                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
2551                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
2552                                            args);
2553    
2554                                    args = new Object[] { scFrameworkVersionModelImpl.getGroupId() };
2555    
2556                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
2557                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
2558                                            args);
2559                            }
2560    
2561                            if ((scFrameworkVersionModelImpl.getColumnBitmask() &
2562                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
2563                                    Object[] args = new Object[] {
2564                                                    scFrameworkVersionModelImpl.getOriginalCompanyId()
2565                                            };
2566    
2567                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
2568                                            args);
2569                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
2570                                            args);
2571    
2572                                    args = new Object[] { scFrameworkVersionModelImpl.getCompanyId() };
2573    
2574                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
2575                                            args);
2576                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
2577                                            args);
2578                            }
2579    
2580                            if ((scFrameworkVersionModelImpl.getColumnBitmask() &
2581                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A.getColumnBitmask()) != 0) {
2582                                    Object[] args = new Object[] {
2583                                                    scFrameworkVersionModelImpl.getOriginalGroupId(),
2584                                                    scFrameworkVersionModelImpl.getOriginalActive()
2585                                            };
2586    
2587                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
2588                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
2589                                            args);
2590    
2591                                    args = new Object[] {
2592                                                    scFrameworkVersionModelImpl.getGroupId(),
2593                                                    scFrameworkVersionModelImpl.getActive()
2594                                            };
2595    
2596                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
2597                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
2598                                            args);
2599                            }
2600                    }
2601    
2602                    EntityCacheUtil.putResult(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
2603                            SCFrameworkVersionImpl.class, scFrameworkVersion.getPrimaryKey(),
2604                            scFrameworkVersion);
2605    
2606                    return scFrameworkVersion;
2607            }
2608    
2609            protected SCFrameworkVersion toUnwrappedModel(
2610                    SCFrameworkVersion scFrameworkVersion) {
2611                    if (scFrameworkVersion instanceof SCFrameworkVersionImpl) {
2612                            return scFrameworkVersion;
2613                    }
2614    
2615                    SCFrameworkVersionImpl scFrameworkVersionImpl = new SCFrameworkVersionImpl();
2616    
2617                    scFrameworkVersionImpl.setNew(scFrameworkVersion.isNew());
2618                    scFrameworkVersionImpl.setPrimaryKey(scFrameworkVersion.getPrimaryKey());
2619    
2620                    scFrameworkVersionImpl.setFrameworkVersionId(scFrameworkVersion.getFrameworkVersionId());
2621                    scFrameworkVersionImpl.setGroupId(scFrameworkVersion.getGroupId());
2622                    scFrameworkVersionImpl.setCompanyId(scFrameworkVersion.getCompanyId());
2623                    scFrameworkVersionImpl.setUserId(scFrameworkVersion.getUserId());
2624                    scFrameworkVersionImpl.setUserName(scFrameworkVersion.getUserName());
2625                    scFrameworkVersionImpl.setCreateDate(scFrameworkVersion.getCreateDate());
2626                    scFrameworkVersionImpl.setModifiedDate(scFrameworkVersion.getModifiedDate());
2627                    scFrameworkVersionImpl.setName(scFrameworkVersion.getName());
2628                    scFrameworkVersionImpl.setUrl(scFrameworkVersion.getUrl());
2629                    scFrameworkVersionImpl.setActive(scFrameworkVersion.isActive());
2630                    scFrameworkVersionImpl.setPriority(scFrameworkVersion.getPriority());
2631    
2632                    return scFrameworkVersionImpl;
2633            }
2634    
2635            /**
2636             * Returns the s c framework version with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
2637             *
2638             * @param primaryKey the primary key of the s c framework version
2639             * @return the s c framework version
2640             * @throws com.liferay.portlet.softwarecatalog.NoSuchFrameworkVersionException if a s c framework version with the primary key could not be found
2641             * @throws SystemException if a system exception occurred
2642             */
2643            @Override
2644            public SCFrameworkVersion findByPrimaryKey(Serializable primaryKey)
2645                    throws NoSuchFrameworkVersionException, SystemException {
2646                    SCFrameworkVersion scFrameworkVersion = fetchByPrimaryKey(primaryKey);
2647    
2648                    if (scFrameworkVersion == null) {
2649                            if (_log.isWarnEnabled()) {
2650                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2651                            }
2652    
2653                            throw new NoSuchFrameworkVersionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2654                                    primaryKey);
2655                    }
2656    
2657                    return scFrameworkVersion;
2658            }
2659    
2660            /**
2661             * 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.
2662             *
2663             * @param frameworkVersionId the primary key of the s c framework version
2664             * @return the s c framework version
2665             * @throws com.liferay.portlet.softwarecatalog.NoSuchFrameworkVersionException if a s c framework version with the primary key could not be found
2666             * @throws SystemException if a system exception occurred
2667             */
2668            public SCFrameworkVersion findByPrimaryKey(long frameworkVersionId)
2669                    throws NoSuchFrameworkVersionException, SystemException {
2670                    return findByPrimaryKey((Serializable)frameworkVersionId);
2671            }
2672    
2673            /**
2674             * Returns the s c framework version with the primary key or returns <code>null</code> if it could not be found.
2675             *
2676             * @param primaryKey the primary key of the s c framework version
2677             * @return the s c framework version, or <code>null</code> if a s c framework version with the primary key could not be found
2678             * @throws SystemException if a system exception occurred
2679             */
2680            @Override
2681            public SCFrameworkVersion fetchByPrimaryKey(Serializable primaryKey)
2682                    throws SystemException {
2683                    SCFrameworkVersion scFrameworkVersion = (SCFrameworkVersion)EntityCacheUtil.getResult(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
2684                                    SCFrameworkVersionImpl.class, primaryKey);
2685    
2686                    if (scFrameworkVersion == _nullSCFrameworkVersion) {
2687                            return null;
2688                    }
2689    
2690                    if (scFrameworkVersion == null) {
2691                            Session session = null;
2692    
2693                            try {
2694                                    session = openSession();
2695    
2696                                    scFrameworkVersion = (SCFrameworkVersion)session.get(SCFrameworkVersionImpl.class,
2697                                                    primaryKey);
2698    
2699                                    if (scFrameworkVersion != null) {
2700                                            cacheResult(scFrameworkVersion);
2701                                    }
2702                                    else {
2703                                            EntityCacheUtil.putResult(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
2704                                                    SCFrameworkVersionImpl.class, primaryKey,
2705                                                    _nullSCFrameworkVersion);
2706                                    }
2707                            }
2708                            catch (Exception e) {
2709                                    EntityCacheUtil.removeResult(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
2710                                            SCFrameworkVersionImpl.class, primaryKey);
2711    
2712                                    throw processException(e);
2713                            }
2714                            finally {
2715                                    closeSession(session);
2716                            }
2717                    }
2718    
2719                    return scFrameworkVersion;
2720            }
2721    
2722            /**
2723             * Returns the s c framework version with the primary key or returns <code>null</code> if it could not be found.
2724             *
2725             * @param frameworkVersionId the primary key of the s c framework version
2726             * @return the s c framework version, or <code>null</code> if a s c framework version with the primary key could not be found
2727             * @throws SystemException if a system exception occurred
2728             */
2729            public SCFrameworkVersion fetchByPrimaryKey(long frameworkVersionId)
2730                    throws SystemException {
2731                    return fetchByPrimaryKey((Serializable)frameworkVersionId);
2732            }
2733    
2734            /**
2735             * Returns all the s c framework versions.
2736             *
2737             * @return the s c framework versions
2738             * @throws SystemException if a system exception occurred
2739             */
2740            public List<SCFrameworkVersion> findAll() throws SystemException {
2741                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2742            }
2743    
2744            /**
2745             * Returns a range of all the s c framework versions.
2746             *
2747             * <p>
2748             * 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.
2749             * </p>
2750             *
2751             * @param start the lower bound of the range of s c framework versions
2752             * @param end the upper bound of the range of s c framework versions (not inclusive)
2753             * @return the range of s c framework versions
2754             * @throws SystemException if a system exception occurred
2755             */
2756            public List<SCFrameworkVersion> findAll(int start, int end)
2757                    throws SystemException {
2758                    return findAll(start, end, null);
2759            }
2760    
2761            /**
2762             * Returns an ordered range of all the s c framework versions.
2763             *
2764             * <p>
2765             * 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.
2766             * </p>
2767             *
2768             * @param start the lower bound of the range of s c framework versions
2769             * @param end the upper bound of the range of s c framework versions (not inclusive)
2770             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2771             * @return the ordered range of s c framework versions
2772             * @throws SystemException if a system exception occurred
2773             */
2774            public List<SCFrameworkVersion> findAll(int start, int end,
2775                    OrderByComparator orderByComparator) throws SystemException {
2776                    boolean pagination = true;
2777                    FinderPath finderPath = null;
2778                    Object[] finderArgs = null;
2779    
2780                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2781                                    (orderByComparator == null)) {
2782                            pagination = false;
2783                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2784                            finderArgs = FINDER_ARGS_EMPTY;
2785                    }
2786                    else {
2787                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2788                            finderArgs = new Object[] { start, end, orderByComparator };
2789                    }
2790    
2791                    List<SCFrameworkVersion> list = (List<SCFrameworkVersion>)FinderCacheUtil.getResult(finderPath,
2792                                    finderArgs, this);
2793    
2794                    if (list == null) {
2795                            StringBundler query = null;
2796                            String sql = null;
2797    
2798                            if (orderByComparator != null) {
2799                                    query = new StringBundler(2 +
2800                                                    (orderByComparator.getOrderByFields().length * 3));
2801    
2802                                    query.append(_SQL_SELECT_SCFRAMEWORKVERSION);
2803    
2804                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2805                                            orderByComparator);
2806    
2807                                    sql = query.toString();
2808                            }
2809                            else {
2810                                    sql = _SQL_SELECT_SCFRAMEWORKVERSION;
2811    
2812                                    if (pagination) {
2813                                            sql = sql.concat(SCFrameworkVersionModelImpl.ORDER_BY_JPQL);
2814                                    }
2815                            }
2816    
2817                            Session session = null;
2818    
2819                            try {
2820                                    session = openSession();
2821    
2822                                    Query q = session.createQuery(sql);
2823    
2824                                    if (!pagination) {
2825                                            list = (List<SCFrameworkVersion>)QueryUtil.list(q,
2826                                                            getDialect(), start, end, false);
2827    
2828                                            Collections.sort(list);
2829    
2830                                            list = new UnmodifiableList<SCFrameworkVersion>(list);
2831                                    }
2832                                    else {
2833                                            list = (List<SCFrameworkVersion>)QueryUtil.list(q,
2834                                                            getDialect(), start, end);
2835                                    }
2836    
2837                                    cacheResult(list);
2838    
2839                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2840                            }
2841                            catch (Exception e) {
2842                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2843    
2844                                    throw processException(e);
2845                            }
2846                            finally {
2847                                    closeSession(session);
2848                            }
2849                    }
2850    
2851                    return list;
2852            }
2853    
2854            /**
2855             * Removes all the s c framework versions from the database.
2856             *
2857             * @throws SystemException if a system exception occurred
2858             */
2859            public void removeAll() throws SystemException {
2860                    for (SCFrameworkVersion scFrameworkVersion : findAll()) {
2861                            remove(scFrameworkVersion);
2862                    }
2863            }
2864    
2865            /**
2866             * Returns the number of s c framework versions.
2867             *
2868             * @return the number of s c framework versions
2869             * @throws SystemException if a system exception occurred
2870             */
2871            public int countAll() throws SystemException {
2872                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2873                                    FINDER_ARGS_EMPTY, this);
2874    
2875                    if (count == null) {
2876                            Session session = null;
2877    
2878                            try {
2879                                    session = openSession();
2880    
2881                                    Query q = session.createQuery(_SQL_COUNT_SCFRAMEWORKVERSION);
2882    
2883                                    count = (Long)q.uniqueResult();
2884    
2885                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2886                                            FINDER_ARGS_EMPTY, count);
2887                            }
2888                            catch (Exception e) {
2889                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
2890                                            FINDER_ARGS_EMPTY);
2891    
2892                                    throw processException(e);
2893                            }
2894                            finally {
2895                                    closeSession(session);
2896                            }
2897                    }
2898    
2899                    return count.intValue();
2900            }
2901    
2902            /**
2903             * Returns all the s c product versions associated with the s c framework version.
2904             *
2905             * @param pk the primary key of the s c framework version
2906             * @return the s c product versions associated with the s c framework version
2907             * @throws SystemException if a system exception occurred
2908             */
2909            public List<com.liferay.portlet.softwarecatalog.model.SCProductVersion> getSCProductVersions(
2910                    long pk) throws SystemException {
2911                    return getSCProductVersions(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2912            }
2913    
2914            /**
2915             * Returns a range of all the s c product versions associated with the s c framework version.
2916             *
2917             * <p>
2918             * 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.
2919             * </p>
2920             *
2921             * @param pk the primary key of the s c framework version
2922             * @param start the lower bound of the range of s c framework versions
2923             * @param end the upper bound of the range of s c framework versions (not inclusive)
2924             * @return the range of s c product versions associated with the s c framework version
2925             * @throws SystemException if a system exception occurred
2926             */
2927            public List<com.liferay.portlet.softwarecatalog.model.SCProductVersion> getSCProductVersions(
2928                    long pk, int start, int end) throws SystemException {
2929                    return getSCProductVersions(pk, start, end, null);
2930            }
2931    
2932            public static final FinderPath FINDER_PATH_GET_SCPRODUCTVERSIONS = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
2933                            SCFrameworkVersionModelImpl.FINDER_CACHE_ENABLED_SCFRAMEWORKVERSI_SCPRODUCTVERS,
2934                            com.liferay.portlet.softwarecatalog.model.impl.SCProductVersionImpl.class,
2935                            SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME,
2936                            "getSCProductVersions",
2937                            new String[] {
2938                                    Long.class.getName(), Integer.class.getName(),
2939                                    Integer.class.getName(), OrderByComparator.class.getName()
2940                            });
2941    
2942            static {
2943                    FINDER_PATH_GET_SCPRODUCTVERSIONS.setCacheKeyGeneratorCacheName(null);
2944            }
2945    
2946            /**
2947             * Returns an ordered range of all the s c product versions associated with the s c framework version.
2948             *
2949             * <p>
2950             * 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.
2951             * </p>
2952             *
2953             * @param pk the primary key of the s c framework version
2954             * @param start the lower bound of the range of s c framework versions
2955             * @param end the upper bound of the range of s c framework versions (not inclusive)
2956             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2957             * @return the ordered range of s c product versions associated with the s c framework version
2958             * @throws SystemException if a system exception occurred
2959             */
2960            public List<com.liferay.portlet.softwarecatalog.model.SCProductVersion> getSCProductVersions(
2961                    long pk, int start, int end, OrderByComparator orderByComparator)
2962                    throws SystemException {
2963                    boolean pagination = true;
2964                    Object[] finderArgs = null;
2965    
2966                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2967                                    (orderByComparator == null)) {
2968                            pagination = false;
2969                            finderArgs = new Object[] { pk };
2970                    }
2971                    else {
2972                            finderArgs = new Object[] { pk, start, end, orderByComparator };
2973                    }
2974    
2975                    List<com.liferay.portlet.softwarecatalog.model.SCProductVersion> list = (List<com.liferay.portlet.softwarecatalog.model.SCProductVersion>)FinderCacheUtil.getResult(FINDER_PATH_GET_SCPRODUCTVERSIONS,
2976                                    finderArgs, this);
2977    
2978                    if (list == null) {
2979                            Session session = null;
2980    
2981                            try {
2982                                    session = openSession();
2983    
2984                                    String sql = null;
2985    
2986                                    if (orderByComparator != null) {
2987                                            sql = _SQL_GETSCPRODUCTVERSIONS.concat(ORDER_BY_CLAUSE)
2988                                                                                                       .concat(orderByComparator.getOrderBy());
2989                                    }
2990                                    else {
2991                                            sql = _SQL_GETSCPRODUCTVERSIONS;
2992    
2993                                            if (pagination) {
2994                                                    sql = sql.concat(com.liferay.portlet.softwarecatalog.model.impl.SCProductVersionModelImpl.ORDER_BY_SQL);
2995                                            }
2996                                    }
2997    
2998                                    SQLQuery q = session.createSQLQuery(sql);
2999    
3000                                    q.addEntity("SCProductVersion",
3001                                            com.liferay.portlet.softwarecatalog.model.impl.SCProductVersionImpl.class);
3002    
3003                                    QueryPos qPos = QueryPos.getInstance(q);
3004    
3005                                    qPos.add(pk);
3006    
3007                                    if (!pagination) {
3008                                            list = (List<com.liferay.portlet.softwarecatalog.model.SCProductVersion>)QueryUtil.list(q,
3009                                                            getDialect(), start, end, false);
3010    
3011                                            Collections.sort(list);
3012    
3013                                            list = new UnmodifiableList<com.liferay.portlet.softwarecatalog.model.SCProductVersion>(list);
3014                                    }
3015                                    else {
3016                                            list = (List<com.liferay.portlet.softwarecatalog.model.SCProductVersion>)QueryUtil.list(q,
3017                                                            getDialect(), start, end);
3018                                    }
3019    
3020                                    scProductVersionPersistence.cacheResult(list);
3021    
3022                                    FinderCacheUtil.putResult(FINDER_PATH_GET_SCPRODUCTVERSIONS,
3023                                            finderArgs, list);
3024                            }
3025                            catch (Exception e) {
3026                                    FinderCacheUtil.removeResult(FINDER_PATH_GET_SCPRODUCTVERSIONS,
3027                                            finderArgs);
3028    
3029                                    throw processException(e);
3030                            }
3031                            finally {
3032                                    closeSession(session);
3033                            }
3034                    }
3035    
3036                    return list;
3037            }
3038    
3039            public static final FinderPath FINDER_PATH_GET_SCPRODUCTVERSIONS_SIZE = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
3040                            SCFrameworkVersionModelImpl.FINDER_CACHE_ENABLED_SCFRAMEWORKVERSI_SCPRODUCTVERS,
3041                            Long.class,
3042                            SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME,
3043                            "getSCProductVersionsSize", new String[] { Long.class.getName() });
3044    
3045            static {
3046                    FINDER_PATH_GET_SCPRODUCTVERSIONS_SIZE.setCacheKeyGeneratorCacheName(null);
3047            }
3048    
3049            /**
3050             * Returns the number of s c product versions associated with the s c framework version.
3051             *
3052             * @param pk the primary key of the s c framework version
3053             * @return the number of s c product versions associated with the s c framework version
3054             * @throws SystemException if a system exception occurred
3055             */
3056            public int getSCProductVersionsSize(long pk) throws SystemException {
3057                    Object[] finderArgs = new Object[] { pk };
3058    
3059                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_SCPRODUCTVERSIONS_SIZE,
3060                                    finderArgs, this);
3061    
3062                    if (count == null) {
3063                            Session session = null;
3064    
3065                            try {
3066                                    session = openSession();
3067    
3068                                    SQLQuery q = session.createSQLQuery(_SQL_GETSCPRODUCTVERSIONSSIZE);
3069    
3070                                    q.addScalar(COUNT_COLUMN_NAME,
3071                                            com.liferay.portal.kernel.dao.orm.Type.LONG);
3072    
3073                                    QueryPos qPos = QueryPos.getInstance(q);
3074    
3075                                    qPos.add(pk);
3076    
3077                                    count = (Long)q.uniqueResult();
3078    
3079                                    FinderCacheUtil.putResult(FINDER_PATH_GET_SCPRODUCTVERSIONS_SIZE,
3080                                            finderArgs, count);
3081                            }
3082                            catch (Exception e) {
3083                                    FinderCacheUtil.removeResult(FINDER_PATH_GET_SCPRODUCTVERSIONS_SIZE,
3084                                            finderArgs);
3085    
3086                                    throw processException(e);
3087                            }
3088                            finally {
3089                                    closeSession(session);
3090                            }
3091                    }
3092    
3093                    return count.intValue();
3094            }
3095    
3096            public static final FinderPath FINDER_PATH_CONTAINS_SCPRODUCTVERSION = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
3097                            SCFrameworkVersionModelImpl.FINDER_CACHE_ENABLED_SCFRAMEWORKVERSI_SCPRODUCTVERS,
3098                            Boolean.class,
3099                            SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME,
3100                            "containsSCProductVersion",
3101                            new String[] { Long.class.getName(), Long.class.getName() });
3102    
3103            /**
3104             * Returns <code>true</code> if the s c product version is associated with the s c framework version.
3105             *
3106             * @param pk the primary key of the s c framework version
3107             * @param scProductVersionPK the primary key of the s c product version
3108             * @return <code>true</code> if the s c product version is associated with the s c framework version; <code>false</code> otherwise
3109             * @throws SystemException if a system exception occurred
3110             */
3111            public boolean containsSCProductVersion(long pk, long scProductVersionPK)
3112                    throws SystemException {
3113                    Object[] finderArgs = new Object[] { pk, scProductVersionPK };
3114    
3115                    Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_SCPRODUCTVERSION,
3116                                    finderArgs, this);
3117    
3118                    if (value == null) {
3119                            try {
3120                                    value = Boolean.valueOf(containsSCProductVersion.contains(pk,
3121                                                            scProductVersionPK));
3122    
3123                                    FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_SCPRODUCTVERSION,
3124                                            finderArgs, value);
3125                            }
3126                            catch (Exception e) {
3127                                    FinderCacheUtil.removeResult(FINDER_PATH_CONTAINS_SCPRODUCTVERSION,
3128                                            finderArgs);
3129    
3130                                    throw processException(e);
3131                            }
3132                    }
3133    
3134                    return value.booleanValue();
3135            }
3136    
3137            /**
3138             * Returns <code>true</code> if the s c framework version has any s c product versions associated with it.
3139             *
3140             * @param pk the primary key of the s c framework version to check for associations with s c product versions
3141             * @return <code>true</code> if the s c framework version has any s c product versions associated with it; <code>false</code> otherwise
3142             * @throws SystemException if a system exception occurred
3143             */
3144            public boolean containsSCProductVersions(long pk) throws SystemException {
3145                    if (getSCProductVersionsSize(pk) > 0) {
3146                            return true;
3147                    }
3148                    else {
3149                            return false;
3150                    }
3151            }
3152    
3153            /**
3154             * 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.
3155             *
3156             * @param pk the primary key of the s c framework version
3157             * @param scProductVersionPK the primary key of the s c product version
3158             * @throws SystemException if a system exception occurred
3159             */
3160            public void addSCProductVersion(long pk, long scProductVersionPK)
3161                    throws SystemException {
3162                    try {
3163                            addSCProductVersion.add(pk, scProductVersionPK);
3164                    }
3165                    catch (Exception e) {
3166                            throw processException(e);
3167                    }
3168                    finally {
3169                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
3170                    }
3171            }
3172    
3173            /**
3174             * 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.
3175             *
3176             * @param pk the primary key of the s c framework version
3177             * @param scProductVersion the s c product version
3178             * @throws SystemException if a system exception occurred
3179             */
3180            public void addSCProductVersion(long pk,
3181                    com.liferay.portlet.softwarecatalog.model.SCProductVersion scProductVersion)
3182                    throws SystemException {
3183                    try {
3184                            addSCProductVersion.add(pk, scProductVersion.getPrimaryKey());
3185                    }
3186                    catch (Exception e) {
3187                            throw processException(e);
3188                    }
3189                    finally {
3190                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
3191                    }
3192            }
3193    
3194            /**
3195             * 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.
3196             *
3197             * @param pk the primary key of the s c framework version
3198             * @param scProductVersionPKs the primary keys of the s c product versions
3199             * @throws SystemException if a system exception occurred
3200             */
3201            public void addSCProductVersions(long pk, long[] scProductVersionPKs)
3202                    throws SystemException {
3203                    try {
3204                            for (long scProductVersionPK : scProductVersionPKs) {
3205                                    addSCProductVersion.add(pk, scProductVersionPK);
3206                            }
3207                    }
3208                    catch (Exception e) {
3209                            throw processException(e);
3210                    }
3211                    finally {
3212                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
3213                    }
3214            }
3215    
3216            /**
3217             * 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.
3218             *
3219             * @param pk the primary key of the s c framework version
3220             * @param scProductVersions the s c product versions
3221             * @throws SystemException if a system exception occurred
3222             */
3223            public void addSCProductVersions(long pk,
3224                    List<com.liferay.portlet.softwarecatalog.model.SCProductVersion> scProductVersions)
3225                    throws SystemException {
3226                    try {
3227                            for (com.liferay.portlet.softwarecatalog.model.SCProductVersion scProductVersion : scProductVersions) {
3228                                    addSCProductVersion.add(pk, scProductVersion.getPrimaryKey());
3229                            }
3230                    }
3231                    catch (Exception e) {
3232                            throw processException(e);
3233                    }
3234                    finally {
3235                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
3236                    }
3237            }
3238    
3239            /**
3240             * 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.
3241             *
3242             * @param pk the primary key of the s c framework version to clear the associated s c product versions from
3243             * @throws SystemException if a system exception occurred
3244             */
3245            public void clearSCProductVersions(long pk) throws SystemException {
3246                    try {
3247                            clearSCProductVersions.clear(pk);
3248                    }
3249                    catch (Exception e) {
3250                            throw processException(e);
3251                    }
3252                    finally {
3253                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
3254                    }
3255            }
3256    
3257            /**
3258             * 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.
3259             *
3260             * @param pk the primary key of the s c framework version
3261             * @param scProductVersionPK the primary key of the s c product version
3262             * @throws SystemException if a system exception occurred
3263             */
3264            public void removeSCProductVersion(long pk, long scProductVersionPK)
3265                    throws SystemException {
3266                    try {
3267                            removeSCProductVersion.remove(pk, scProductVersionPK);
3268                    }
3269                    catch (Exception e) {
3270                            throw processException(e);
3271                    }
3272                    finally {
3273                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
3274                    }
3275            }
3276    
3277            /**
3278             * 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.
3279             *
3280             * @param pk the primary key of the s c framework version
3281             * @param scProductVersion the s c product version
3282             * @throws SystemException if a system exception occurred
3283             */
3284            public void removeSCProductVersion(long pk,
3285                    com.liferay.portlet.softwarecatalog.model.SCProductVersion scProductVersion)
3286                    throws SystemException {
3287                    try {
3288                            removeSCProductVersion.remove(pk, scProductVersion.getPrimaryKey());
3289                    }
3290                    catch (Exception e) {
3291                            throw processException(e);
3292                    }
3293                    finally {
3294                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
3295                    }
3296            }
3297    
3298            /**
3299             * 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.
3300             *
3301             * @param pk the primary key of the s c framework version
3302             * @param scProductVersionPKs the primary keys of the s c product versions
3303             * @throws SystemException if a system exception occurred
3304             */
3305            public void removeSCProductVersions(long pk, long[] scProductVersionPKs)
3306                    throws SystemException {
3307                    try {
3308                            for (long scProductVersionPK : scProductVersionPKs) {
3309                                    removeSCProductVersion.remove(pk, scProductVersionPK);
3310                            }
3311                    }
3312                    catch (Exception e) {
3313                            throw processException(e);
3314                    }
3315                    finally {
3316                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
3317                    }
3318            }
3319    
3320            /**
3321             * 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.
3322             *
3323             * @param pk the primary key of the s c framework version
3324             * @param scProductVersions the s c product versions
3325             * @throws SystemException if a system exception occurred
3326             */
3327            public void removeSCProductVersions(long pk,
3328                    List<com.liferay.portlet.softwarecatalog.model.SCProductVersion> scProductVersions)
3329                    throws SystemException {
3330                    try {
3331                            for (com.liferay.portlet.softwarecatalog.model.SCProductVersion scProductVersion : scProductVersions) {
3332                                    removeSCProductVersion.remove(pk,
3333                                            scProductVersion.getPrimaryKey());
3334                            }
3335                    }
3336                    catch (Exception e) {
3337                            throw processException(e);
3338                    }
3339                    finally {
3340                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
3341                    }
3342            }
3343    
3344            /**
3345             * 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.
3346             *
3347             * @param pk the primary key of the s c framework version
3348             * @param scProductVersionPKs the primary keys of the s c product versions to be associated with the s c framework version
3349             * @throws SystemException if a system exception occurred
3350             */
3351            public void setSCProductVersions(long pk, long[] scProductVersionPKs)
3352                    throws SystemException {
3353                    try {
3354                            Set<Long> scProductVersionPKSet = SetUtil.fromArray(scProductVersionPKs);
3355    
3356                            List<com.liferay.portlet.softwarecatalog.model.SCProductVersion> scProductVersions =
3357                                    getSCProductVersions(pk);
3358    
3359                            for (com.liferay.portlet.softwarecatalog.model.SCProductVersion scProductVersion : scProductVersions) {
3360                                    if (!scProductVersionPKSet.remove(
3361                                                            scProductVersion.getPrimaryKey())) {
3362                                            removeSCProductVersion.remove(pk,
3363                                                    scProductVersion.getPrimaryKey());
3364                                    }
3365                            }
3366    
3367                            for (Long scProductVersionPK : scProductVersionPKSet) {
3368                                    addSCProductVersion.add(pk, scProductVersionPK);
3369                            }
3370                    }
3371                    catch (Exception e) {
3372                            throw processException(e);
3373                    }
3374                    finally {
3375                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
3376                    }
3377            }
3378    
3379            /**
3380             * 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.
3381             *
3382             * @param pk the primary key of the s c framework version
3383             * @param scProductVersions the s c product versions to be associated with the s c framework version
3384             * @throws SystemException if a system exception occurred
3385             */
3386            public void setSCProductVersions(long pk,
3387                    List<com.liferay.portlet.softwarecatalog.model.SCProductVersion> scProductVersions)
3388                    throws SystemException {
3389                    try {
3390                            long[] scProductVersionPKs = new long[scProductVersions.size()];
3391    
3392                            for (int i = 0; i < scProductVersions.size(); i++) {
3393                                    com.liferay.portlet.softwarecatalog.model.SCProductVersion scProductVersion =
3394                                            scProductVersions.get(i);
3395    
3396                                    scProductVersionPKs[i] = scProductVersion.getPrimaryKey();
3397                            }
3398    
3399                            setSCProductVersions(pk, scProductVersionPKs);
3400                    }
3401                    catch (Exception e) {
3402                            throw processException(e);
3403                    }
3404                    finally {
3405                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
3406                    }
3407            }
3408    
3409            /**
3410             * Initializes the s c framework version persistence.
3411             */
3412            public void afterPropertiesSet() {
3413                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3414                                            com.liferay.portal.util.PropsUtil.get(
3415                                                    "value.object.listener.com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion")));
3416    
3417                    if (listenerClassNames.length > 0) {
3418                            try {
3419                                    List<ModelListener<SCFrameworkVersion>> listenersList = new ArrayList<ModelListener<SCFrameworkVersion>>();
3420    
3421                                    for (String listenerClassName : listenerClassNames) {
3422                                            listenersList.add((ModelListener<SCFrameworkVersion>)InstanceFactory.newInstance(
3423                                                            listenerClassName));
3424                                    }
3425    
3426                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3427                            }
3428                            catch (Exception e) {
3429                                    _log.error(e);
3430                            }
3431                    }
3432    
3433                    containsSCProductVersion = new ContainsSCProductVersion();
3434    
3435                    addSCProductVersion = new AddSCProductVersion();
3436                    clearSCProductVersions = new ClearSCProductVersions();
3437                    removeSCProductVersion = new RemoveSCProductVersion();
3438            }
3439    
3440            public void destroy() {
3441                    EntityCacheUtil.removeCache(SCFrameworkVersionImpl.class.getName());
3442                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3443                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3444                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3445            }
3446    
3447            @BeanReference(type = SCProductVersionPersistence.class)
3448            protected SCProductVersionPersistence scProductVersionPersistence;
3449            protected ContainsSCProductVersion containsSCProductVersion;
3450            protected AddSCProductVersion addSCProductVersion;
3451            protected ClearSCProductVersions clearSCProductVersions;
3452            protected RemoveSCProductVersion removeSCProductVersion;
3453    
3454            protected class ContainsSCProductVersion {
3455                    protected ContainsSCProductVersion() {
3456                            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
3457                                            _SQL_CONTAINSSCPRODUCTVERSION,
3458                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
3459                                            RowMapper.COUNT);
3460                    }
3461    
3462                    protected boolean contains(long frameworkVersionId,
3463                            long productVersionId) {
3464                            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
3465                                                    new Long(frameworkVersionId), new Long(productVersionId)
3466                                            });
3467    
3468                            if (results.size() > 0) {
3469                                    Integer count = results.get(0);
3470    
3471                                    if (count.intValue() > 0) {
3472                                            return true;
3473                                    }
3474                            }
3475    
3476                            return false;
3477                    }
3478    
3479                    private MappingSqlQuery<Integer> _mappingSqlQuery;
3480            }
3481    
3482            protected class AddSCProductVersion {
3483                    protected AddSCProductVersion() {
3484                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3485                                            "INSERT INTO SCFrameworkVersi_SCProductVers (frameworkVersionId, productVersionId) VALUES (?, ?)",
3486                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3487                    }
3488    
3489                    protected void add(long frameworkVersionId, long productVersionId)
3490                            throws SystemException {
3491                            if (!containsSCProductVersion.contains(frameworkVersionId,
3492                                                    productVersionId)) {
3493                                    ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductVersion>[] scProductVersionListeners =
3494                                            scProductVersionPersistence.getListeners();
3495    
3496                                    for (ModelListener<SCFrameworkVersion> listener : listeners) {
3497                                            listener.onBeforeAddAssociation(frameworkVersionId,
3498                                                    com.liferay.portlet.softwarecatalog.model.SCProductVersion.class.getName(),
3499                                                    productVersionId);
3500                                    }
3501    
3502                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductVersion> listener : scProductVersionListeners) {
3503                                            listener.onBeforeAddAssociation(productVersionId,
3504                                                    SCFrameworkVersion.class.getName(), frameworkVersionId);
3505                                    }
3506    
3507                                    _sqlUpdate.update(new Object[] {
3508                                                    new Long(frameworkVersionId), new Long(productVersionId)
3509                                            });
3510    
3511                                    for (ModelListener<SCFrameworkVersion> listener : listeners) {
3512                                            listener.onAfterAddAssociation(frameworkVersionId,
3513                                                    com.liferay.portlet.softwarecatalog.model.SCProductVersion.class.getName(),
3514                                                    productVersionId);
3515                                    }
3516    
3517                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductVersion> listener : scProductVersionListeners) {
3518                                            listener.onAfterAddAssociation(productVersionId,
3519                                                    SCFrameworkVersion.class.getName(), frameworkVersionId);
3520                                    }
3521                            }
3522                    }
3523    
3524                    private SqlUpdate _sqlUpdate;
3525            }
3526    
3527            protected class ClearSCProductVersions {
3528                    protected ClearSCProductVersions() {
3529                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3530                                            "DELETE FROM SCFrameworkVersi_SCProductVers WHERE frameworkVersionId = ?",
3531                                            new int[] { java.sql.Types.BIGINT });
3532                    }
3533    
3534                    protected void clear(long frameworkVersionId) throws SystemException {
3535                            ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductVersion>[] scProductVersionListeners =
3536                                    scProductVersionPersistence.getListeners();
3537    
3538                            List<com.liferay.portlet.softwarecatalog.model.SCProductVersion> scProductVersions =
3539                                    null;
3540    
3541                            if ((listeners.length > 0) ||
3542                                            (scProductVersionListeners.length > 0)) {
3543                                    scProductVersions = getSCProductVersions(frameworkVersionId);
3544    
3545                                    for (com.liferay.portlet.softwarecatalog.model.SCProductVersion scProductVersion : scProductVersions) {
3546                                            for (ModelListener<SCFrameworkVersion> listener : listeners) {
3547                                                    listener.onBeforeRemoveAssociation(frameworkVersionId,
3548                                                            com.liferay.portlet.softwarecatalog.model.SCProductVersion.class.getName(),
3549                                                            scProductVersion.getPrimaryKey());
3550                                            }
3551    
3552                                            for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductVersion> listener : scProductVersionListeners) {
3553                                                    listener.onBeforeRemoveAssociation(scProductVersion.getPrimaryKey(),
3554                                                            SCFrameworkVersion.class.getName(),
3555                                                            frameworkVersionId);
3556                                            }
3557                                    }
3558                            }
3559    
3560                            _sqlUpdate.update(new Object[] { new Long(frameworkVersionId) });
3561    
3562                            if ((listeners.length > 0) ||
3563                                            (scProductVersionListeners.length > 0)) {
3564                                    for (com.liferay.portlet.softwarecatalog.model.SCProductVersion scProductVersion : scProductVersions) {
3565                                            for (ModelListener<SCFrameworkVersion> listener : listeners) {
3566                                                    listener.onAfterRemoveAssociation(frameworkVersionId,
3567                                                            com.liferay.portlet.softwarecatalog.model.SCProductVersion.class.getName(),
3568                                                            scProductVersion.getPrimaryKey());
3569                                            }
3570    
3571                                            for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductVersion> listener : scProductVersionListeners) {
3572                                                    listener.onAfterRemoveAssociation(scProductVersion.getPrimaryKey(),
3573                                                            SCFrameworkVersion.class.getName(),
3574                                                            frameworkVersionId);
3575                                            }
3576                                    }
3577                            }
3578                    }
3579    
3580                    private SqlUpdate _sqlUpdate;
3581            }
3582    
3583            protected class RemoveSCProductVersion {
3584                    protected RemoveSCProductVersion() {
3585                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3586                                            "DELETE FROM SCFrameworkVersi_SCProductVers WHERE frameworkVersionId = ? AND productVersionId = ?",
3587                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3588                    }
3589    
3590                    protected void remove(long frameworkVersionId, long productVersionId)
3591                            throws SystemException {
3592                            if (containsSCProductVersion.contains(frameworkVersionId,
3593                                                    productVersionId)) {
3594                                    ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductVersion>[] scProductVersionListeners =
3595                                            scProductVersionPersistence.getListeners();
3596    
3597                                    for (ModelListener<SCFrameworkVersion> listener : listeners) {
3598                                            listener.onBeforeRemoveAssociation(frameworkVersionId,
3599                                                    com.liferay.portlet.softwarecatalog.model.SCProductVersion.class.getName(),
3600                                                    productVersionId);
3601                                    }
3602    
3603                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductVersion> listener : scProductVersionListeners) {
3604                                            listener.onBeforeRemoveAssociation(productVersionId,
3605                                                    SCFrameworkVersion.class.getName(), frameworkVersionId);
3606                                    }
3607    
3608                                    _sqlUpdate.update(new Object[] {
3609                                                    new Long(frameworkVersionId), new Long(productVersionId)
3610                                            });
3611    
3612                                    for (ModelListener<SCFrameworkVersion> listener : listeners) {
3613                                            listener.onAfterRemoveAssociation(frameworkVersionId,
3614                                                    com.liferay.portlet.softwarecatalog.model.SCProductVersion.class.getName(),
3615                                                    productVersionId);
3616                                    }
3617    
3618                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductVersion> listener : scProductVersionListeners) {
3619                                            listener.onAfterRemoveAssociation(productVersionId,
3620                                                    SCFrameworkVersion.class.getName(), frameworkVersionId);
3621                                    }
3622                            }
3623                    }
3624    
3625                    private SqlUpdate _sqlUpdate;
3626            }
3627    
3628            private static final String _SQL_SELECT_SCFRAMEWORKVERSION = "SELECT scFrameworkVersion FROM SCFrameworkVersion scFrameworkVersion";
3629            private static final String _SQL_SELECT_SCFRAMEWORKVERSION_WHERE = "SELECT scFrameworkVersion FROM SCFrameworkVersion scFrameworkVersion WHERE ";
3630            private static final String _SQL_COUNT_SCFRAMEWORKVERSION = "SELECT COUNT(scFrameworkVersion) FROM SCFrameworkVersion scFrameworkVersion";
3631            private static final String _SQL_COUNT_SCFRAMEWORKVERSION_WHERE = "SELECT COUNT(scFrameworkVersion) FROM SCFrameworkVersion scFrameworkVersion WHERE ";
3632            private static final String _SQL_GETSCPRODUCTVERSIONS = "SELECT {SCProductVersion.*} FROM SCProductVersion INNER JOIN SCFrameworkVersi_SCProductVers ON (SCFrameworkVersi_SCProductVers.productVersionId = SCProductVersion.productVersionId) WHERE (SCFrameworkVersi_SCProductVers.frameworkVersionId = ?)";
3633            private static final String _SQL_GETSCPRODUCTVERSIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCFrameworkVersi_SCProductVers WHERE frameworkVersionId = ?";
3634            private static final String _SQL_CONTAINSSCPRODUCTVERSION = "SELECT COUNT(*) AS COUNT_VALUE FROM SCFrameworkVersi_SCProductVers WHERE frameworkVersionId = ? AND productVersionId = ?";
3635            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "scFrameworkVersion.frameworkVersionId";
3636            private static final String _FILTER_SQL_SELECT_SCFRAMEWORKVERSION_WHERE = "SELECT DISTINCT {scFrameworkVersion.*} FROM SCFrameworkVersion scFrameworkVersion WHERE ";
3637            private static final String _FILTER_SQL_SELECT_SCFRAMEWORKVERSION_NO_INLINE_DISTINCT_WHERE_1 =
3638                    "SELECT {SCFrameworkVersion.*} FROM (SELECT DISTINCT scFrameworkVersion.frameworkVersionId FROM SCFrameworkVersion scFrameworkVersion WHERE ";
3639            private static final String _FILTER_SQL_SELECT_SCFRAMEWORKVERSION_NO_INLINE_DISTINCT_WHERE_2 =
3640                    ") TEMP_TABLE INNER JOIN SCFrameworkVersion ON TEMP_TABLE.frameworkVersionId = SCFrameworkVersion.frameworkVersionId";
3641            private static final String _FILTER_SQL_COUNT_SCFRAMEWORKVERSION_WHERE = "SELECT COUNT(DISTINCT scFrameworkVersion.frameworkVersionId) AS COUNT_VALUE FROM SCFrameworkVersion scFrameworkVersion WHERE ";
3642            private static final String _FILTER_ENTITY_ALIAS = "scFrameworkVersion";
3643            private static final String _FILTER_ENTITY_TABLE = "SCFrameworkVersion";
3644            private static final String _ORDER_BY_ENTITY_ALIAS = "scFrameworkVersion.";
3645            private static final String _ORDER_BY_ENTITY_TABLE = "SCFrameworkVersion.";
3646            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SCFrameworkVersion exists with the primary key ";
3647            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SCFrameworkVersion exists with the key {";
3648            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3649            private static Log _log = LogFactoryUtil.getLog(SCFrameworkVersionPersistenceImpl.class);
3650            private static SCFrameworkVersion _nullSCFrameworkVersion = new SCFrameworkVersionImpl() {
3651                            @Override
3652                            public Object clone() {
3653                                    return this;
3654                            }
3655    
3656                            @Override
3657                            public CacheModel<SCFrameworkVersion> toCacheModel() {
3658                                    return _nullSCFrameworkVersionCacheModel;
3659                            }
3660                    };
3661    
3662            private static CacheModel<SCFrameworkVersion> _nullSCFrameworkVersionCacheModel =
3663                    new CacheModel<SCFrameworkVersion>() {
3664                            public SCFrameworkVersion toEntityModel() {
3665                                    return _nullSCFrameworkVersion;
3666                            }
3667                    };
3668    }