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