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