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