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