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