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