001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.softwarecatalog.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.annotation.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
021    import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
022    import com.liferay.portal.kernel.dao.jdbc.RowMapper;
023    import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
024    import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
025    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
026    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
027    import com.liferay.portal.kernel.dao.orm.FinderPath;
028    import com.liferay.portal.kernel.dao.orm.Query;
029    import com.liferay.portal.kernel.dao.orm.QueryPos;
030    import com.liferay.portal.kernel.dao.orm.QueryUtil;
031    import com.liferay.portal.kernel.dao.orm.SQLQuery;
032    import com.liferay.portal.kernel.dao.orm.Session;
033    import com.liferay.portal.kernel.exception.SystemException;
034    import com.liferay.portal.kernel.log.Log;
035    import com.liferay.portal.kernel.log.LogFactoryUtil;
036    import com.liferay.portal.kernel.util.GetterUtil;
037    import com.liferay.portal.kernel.util.InstanceFactory;
038    import com.liferay.portal.kernel.util.OrderByComparator;
039    import com.liferay.portal.kernel.util.SetUtil;
040    import com.liferay.portal.kernel.util.StringBundler;
041    import com.liferay.portal.kernel.util.StringPool;
042    import com.liferay.portal.kernel.util.StringUtil;
043    import com.liferay.portal.model.ModelListener;
044    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
045    import com.liferay.portal.service.persistence.BatchSessionUtil;
046    import com.liferay.portal.service.persistence.ResourcePersistence;
047    import com.liferay.portal.service.persistence.UserPersistence;
048    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
049    
050    import com.liferay.portlet.softwarecatalog.NoSuchFrameworkVersionException;
051    import com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion;
052    import com.liferay.portlet.softwarecatalog.model.impl.SCFrameworkVersionImpl;
053    import com.liferay.portlet.softwarecatalog.model.impl.SCFrameworkVersionModelImpl;
054    
055    import java.io.Serializable;
056    
057    import java.util.ArrayList;
058    import java.util.Collections;
059    import java.util.List;
060    import java.util.Set;
061    
062    /**
063     * @author    Brian Wing Shun Chan
064     * @see       SCFrameworkVersionPersistence
065     * @see       SCFrameworkVersionUtil
066     * @generated
067     */
068    public class SCFrameworkVersionPersistenceImpl extends BasePersistenceImpl<SCFrameworkVersion>
069            implements SCFrameworkVersionPersistence {
070            public static final String FINDER_CLASS_NAME_ENTITY = SCFrameworkVersionImpl.class.getName();
071            public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
072                    ".List";
073            public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
074                            SCFrameworkVersionModelImpl.FINDER_CACHE_ENABLED,
075                            FINDER_CLASS_NAME_LIST, "findByGroupId",
076                            new String[] {
077                                    Long.class.getName(),
078                                    
079                            "java.lang.Integer", "java.lang.Integer",
080                                    "com.liferay.portal.kernel.util.OrderByComparator"
081                            });
082            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
083                            SCFrameworkVersionModelImpl.FINDER_CACHE_ENABLED,
084                            FINDER_CLASS_NAME_LIST, "countByGroupId",
085                            new String[] { Long.class.getName() });
086            public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
087                            SCFrameworkVersionModelImpl.FINDER_CACHE_ENABLED,
088                            FINDER_CLASS_NAME_LIST, "findByCompanyId",
089                            new String[] {
090                                    Long.class.getName(),
091                                    
092                            "java.lang.Integer", "java.lang.Integer",
093                                    "com.liferay.portal.kernel.util.OrderByComparator"
094                            });
095            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
096                            SCFrameworkVersionModelImpl.FINDER_CACHE_ENABLED,
097                            FINDER_CLASS_NAME_LIST, "countByCompanyId",
098                            new String[] { Long.class.getName() });
099            public static final FinderPath FINDER_PATH_FIND_BY_G_A = new FinderPath(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
100                            SCFrameworkVersionModelImpl.FINDER_CACHE_ENABLED,
101                            FINDER_CLASS_NAME_LIST, "findByG_A",
102                            new String[] {
103                                    Long.class.getName(), Boolean.class.getName(),
104                                    
105                            "java.lang.Integer", "java.lang.Integer",
106                                    "com.liferay.portal.kernel.util.OrderByComparator"
107                            });
108            public static final FinderPath FINDER_PATH_COUNT_BY_G_A = new FinderPath(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
109                            SCFrameworkVersionModelImpl.FINDER_CACHE_ENABLED,
110                            FINDER_CLASS_NAME_LIST, "countByG_A",
111                            new String[] { Long.class.getName(), Boolean.class.getName() });
112            public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
113                            SCFrameworkVersionModelImpl.FINDER_CACHE_ENABLED,
114                            FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
115            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
116                            SCFrameworkVersionModelImpl.FINDER_CACHE_ENABLED,
117                            FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
118    
119            public void cacheResult(SCFrameworkVersion scFrameworkVersion) {
120                    EntityCacheUtil.putResult(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
121                            SCFrameworkVersionImpl.class, scFrameworkVersion.getPrimaryKey(),
122                            scFrameworkVersion);
123            }
124    
125            public void cacheResult(List<SCFrameworkVersion> scFrameworkVersions) {
126                    for (SCFrameworkVersion scFrameworkVersion : scFrameworkVersions) {
127                            if (EntityCacheUtil.getResult(
128                                                    SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
129                                                    SCFrameworkVersionImpl.class,
130                                                    scFrameworkVersion.getPrimaryKey(), this) == null) {
131                                    cacheResult(scFrameworkVersion);
132                            }
133                    }
134            }
135    
136            public void clearCache() {
137                    CacheRegistryUtil.clear(SCFrameworkVersionImpl.class.getName());
138                    EntityCacheUtil.clearCache(SCFrameworkVersionImpl.class.getName());
139                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
140                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
141            }
142    
143            public void clearCache(SCFrameworkVersion scFrameworkVersion) {
144                    EntityCacheUtil.removeResult(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
145                            SCFrameworkVersionImpl.class, scFrameworkVersion.getPrimaryKey());
146            }
147    
148            public SCFrameworkVersion create(long frameworkVersionId) {
149                    SCFrameworkVersion scFrameworkVersion = new SCFrameworkVersionImpl();
150    
151                    scFrameworkVersion.setNew(true);
152                    scFrameworkVersion.setPrimaryKey(frameworkVersionId);
153    
154                    return scFrameworkVersion;
155            }
156    
157            public SCFrameworkVersion remove(Serializable primaryKey)
158                    throws NoSuchModelException, SystemException {
159                    return remove(((Long)primaryKey).longValue());
160            }
161    
162            public SCFrameworkVersion remove(long frameworkVersionId)
163                    throws NoSuchFrameworkVersionException, SystemException {
164                    Session session = null;
165    
166                    try {
167                            session = openSession();
168    
169                            SCFrameworkVersion scFrameworkVersion = (SCFrameworkVersion)session.get(SCFrameworkVersionImpl.class,
170                                            new Long(frameworkVersionId));
171    
172                            if (scFrameworkVersion == null) {
173                                    if (_log.isWarnEnabled()) {
174                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
175                                                    frameworkVersionId);
176                                    }
177    
178                                    throw new NoSuchFrameworkVersionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
179                                            frameworkVersionId);
180                            }
181    
182                            return remove(scFrameworkVersion);
183                    }
184                    catch (NoSuchFrameworkVersionException nsee) {
185                            throw nsee;
186                    }
187                    catch (Exception e) {
188                            throw processException(e);
189                    }
190                    finally {
191                            closeSession(session);
192                    }
193            }
194    
195            protected SCFrameworkVersion removeImpl(
196                    SCFrameworkVersion scFrameworkVersion) throws SystemException {
197                    scFrameworkVersion = toUnwrappedModel(scFrameworkVersion);
198    
199                    try {
200                            clearSCProductVersions.clear(scFrameworkVersion.getPrimaryKey());
201                    }
202                    catch (Exception e) {
203                            throw processException(e);
204                    }
205                    finally {
206                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
207                    }
208    
209                    Session session = null;
210    
211                    try {
212                            session = openSession();
213    
214                            if (scFrameworkVersion.isCachedModel() ||
215                                            BatchSessionUtil.isEnabled()) {
216                                    Object staleObject = session.get(SCFrameworkVersionImpl.class,
217                                                    scFrameworkVersion.getPrimaryKeyObj());
218    
219                                    if (staleObject != null) {
220                                            session.evict(staleObject);
221                                    }
222                            }
223    
224                            session.delete(scFrameworkVersion);
225    
226                            session.flush();
227                    }
228                    catch (Exception e) {
229                            throw processException(e);
230                    }
231                    finally {
232                            closeSession(session);
233                    }
234    
235                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
236    
237                    EntityCacheUtil.removeResult(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
238                            SCFrameworkVersionImpl.class, scFrameworkVersion.getPrimaryKey());
239    
240                    return scFrameworkVersion;
241            }
242    
243            public SCFrameworkVersion updateImpl(
244                    com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion scFrameworkVersion,
245                    boolean merge) throws SystemException {
246                    scFrameworkVersion = toUnwrappedModel(scFrameworkVersion);
247    
248                    Session session = null;
249    
250                    try {
251                            session = openSession();
252    
253                            BatchSessionUtil.update(session, scFrameworkVersion, merge);
254    
255                            scFrameworkVersion.setNew(false);
256                    }
257                    catch (Exception e) {
258                            throw processException(e);
259                    }
260                    finally {
261                            closeSession(session);
262                    }
263    
264                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
265    
266                    EntityCacheUtil.putResult(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
267                            SCFrameworkVersionImpl.class, scFrameworkVersion.getPrimaryKey(),
268                            scFrameworkVersion);
269    
270                    return scFrameworkVersion;
271            }
272    
273            protected SCFrameworkVersion toUnwrappedModel(
274                    SCFrameworkVersion scFrameworkVersion) {
275                    if (scFrameworkVersion instanceof SCFrameworkVersionImpl) {
276                            return scFrameworkVersion;
277                    }
278    
279                    SCFrameworkVersionImpl scFrameworkVersionImpl = new SCFrameworkVersionImpl();
280    
281                    scFrameworkVersionImpl.setNew(scFrameworkVersion.isNew());
282                    scFrameworkVersionImpl.setPrimaryKey(scFrameworkVersion.getPrimaryKey());
283    
284                    scFrameworkVersionImpl.setFrameworkVersionId(scFrameworkVersion.getFrameworkVersionId());
285                    scFrameworkVersionImpl.setGroupId(scFrameworkVersion.getGroupId());
286                    scFrameworkVersionImpl.setCompanyId(scFrameworkVersion.getCompanyId());
287                    scFrameworkVersionImpl.setUserId(scFrameworkVersion.getUserId());
288                    scFrameworkVersionImpl.setUserName(scFrameworkVersion.getUserName());
289                    scFrameworkVersionImpl.setCreateDate(scFrameworkVersion.getCreateDate());
290                    scFrameworkVersionImpl.setModifiedDate(scFrameworkVersion.getModifiedDate());
291                    scFrameworkVersionImpl.setName(scFrameworkVersion.getName());
292                    scFrameworkVersionImpl.setUrl(scFrameworkVersion.getUrl());
293                    scFrameworkVersionImpl.setActive(scFrameworkVersion.isActive());
294                    scFrameworkVersionImpl.setPriority(scFrameworkVersion.getPriority());
295    
296                    return scFrameworkVersionImpl;
297            }
298    
299            public SCFrameworkVersion findByPrimaryKey(Serializable primaryKey)
300                    throws NoSuchModelException, SystemException {
301                    return findByPrimaryKey(((Long)primaryKey).longValue());
302            }
303    
304            public SCFrameworkVersion findByPrimaryKey(long frameworkVersionId)
305                    throws NoSuchFrameworkVersionException, SystemException {
306                    SCFrameworkVersion scFrameworkVersion = fetchByPrimaryKey(frameworkVersionId);
307    
308                    if (scFrameworkVersion == null) {
309                            if (_log.isWarnEnabled()) {
310                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
311                                            frameworkVersionId);
312                            }
313    
314                            throw new NoSuchFrameworkVersionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
315                                    frameworkVersionId);
316                    }
317    
318                    return scFrameworkVersion;
319            }
320    
321            public SCFrameworkVersion fetchByPrimaryKey(Serializable primaryKey)
322                    throws SystemException {
323                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
324            }
325    
326            public SCFrameworkVersion fetchByPrimaryKey(long frameworkVersionId)
327                    throws SystemException {
328                    SCFrameworkVersion scFrameworkVersion = (SCFrameworkVersion)EntityCacheUtil.getResult(SCFrameworkVersionModelImpl.ENTITY_CACHE_ENABLED,
329                                    SCFrameworkVersionImpl.class, frameworkVersionId, this);
330    
331                    if (scFrameworkVersion == null) {
332                            Session session = null;
333    
334                            try {
335                                    session = openSession();
336    
337                                    scFrameworkVersion = (SCFrameworkVersion)session.get(SCFrameworkVersionImpl.class,
338                                                    new Long(frameworkVersionId));
339                            }
340                            catch (Exception e) {
341                                    throw processException(e);
342                            }
343                            finally {
344                                    if (scFrameworkVersion != null) {
345                                            cacheResult(scFrameworkVersion);
346                                    }
347    
348                                    closeSession(session);
349                            }
350                    }
351    
352                    return scFrameworkVersion;
353            }
354    
355            public List<SCFrameworkVersion> findByGroupId(long groupId)
356                    throws SystemException {
357                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
358            }
359    
360            public List<SCFrameworkVersion> findByGroupId(long groupId, int start,
361                    int end) throws SystemException {
362                    return findByGroupId(groupId, start, end, null);
363            }
364    
365            public List<SCFrameworkVersion> findByGroupId(long groupId, int start,
366                    int end, OrderByComparator orderByComparator) throws SystemException {
367                    Object[] finderArgs = new Object[] {
368                                    groupId,
369                                    
370                                    String.valueOf(start), String.valueOf(end),
371                                    String.valueOf(orderByComparator)
372                            };
373    
374                    List<SCFrameworkVersion> list = (List<SCFrameworkVersion>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
375                                    finderArgs, this);
376    
377                    if (list == null) {
378                            Session session = null;
379    
380                            try {
381                                    session = openSession();
382    
383                                    StringBundler query = null;
384    
385                                    if (orderByComparator != null) {
386                                            query = new StringBundler(3 +
387                                                            (orderByComparator.getOrderByFields().length * 3));
388                                    }
389                                    else {
390                                            query = new StringBundler(3);
391                                    }
392    
393                                    query.append(_SQL_SELECT_SCFRAMEWORKVERSION_WHERE);
394    
395                                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
396    
397                                    if (orderByComparator != null) {
398                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
399                                                    orderByComparator);
400                                    }
401    
402                                    else {
403                                            query.append(SCFrameworkVersionModelImpl.ORDER_BY_JPQL);
404                                    }
405    
406                                    String sql = query.toString();
407    
408                                    Query q = session.createQuery(sql);
409    
410                                    QueryPos qPos = QueryPos.getInstance(q);
411    
412                                    qPos.add(groupId);
413    
414                                    list = (List<SCFrameworkVersion>)QueryUtil.list(q,
415                                                    getDialect(), start, end);
416                            }
417                            catch (Exception e) {
418                                    throw processException(e);
419                            }
420                            finally {
421                                    if (list == null) {
422                                            list = new ArrayList<SCFrameworkVersion>();
423                                    }
424    
425                                    cacheResult(list);
426    
427                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
428                                            finderArgs, list);
429    
430                                    closeSession(session);
431                            }
432                    }
433    
434                    return list;
435            }
436    
437            public SCFrameworkVersion findByGroupId_First(long groupId,
438                    OrderByComparator orderByComparator)
439                    throws NoSuchFrameworkVersionException, SystemException {
440                    List<SCFrameworkVersion> list = findByGroupId(groupId, 0, 1,
441                                    orderByComparator);
442    
443                    if (list.isEmpty()) {
444                            StringBundler msg = new StringBundler(4);
445    
446                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
447    
448                            msg.append("groupId=");
449                            msg.append(groupId);
450    
451                            msg.append(StringPool.CLOSE_CURLY_BRACE);
452    
453                            throw new NoSuchFrameworkVersionException(msg.toString());
454                    }
455                    else {
456                            return list.get(0);
457                    }
458            }
459    
460            public SCFrameworkVersion findByGroupId_Last(long groupId,
461                    OrderByComparator orderByComparator)
462                    throws NoSuchFrameworkVersionException, SystemException {
463                    int count = countByGroupId(groupId);
464    
465                    List<SCFrameworkVersion> list = findByGroupId(groupId, count - 1,
466                                    count, orderByComparator);
467    
468                    if (list.isEmpty()) {
469                            StringBundler msg = new StringBundler(4);
470    
471                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
472    
473                            msg.append("groupId=");
474                            msg.append(groupId);
475    
476                            msg.append(StringPool.CLOSE_CURLY_BRACE);
477    
478                            throw new NoSuchFrameworkVersionException(msg.toString());
479                    }
480                    else {
481                            return list.get(0);
482                    }
483            }
484    
485            public SCFrameworkVersion[] findByGroupId_PrevAndNext(
486                    long frameworkVersionId, long groupId,
487                    OrderByComparator orderByComparator)
488                    throws NoSuchFrameworkVersionException, SystemException {
489                    SCFrameworkVersion scFrameworkVersion = findByPrimaryKey(frameworkVersionId);
490    
491                    Session session = null;
492    
493                    try {
494                            session = openSession();
495    
496                            SCFrameworkVersion[] array = new SCFrameworkVersionImpl[3];
497    
498                            array[0] = getByGroupId_PrevAndNext(session, scFrameworkVersion,
499                                            groupId, orderByComparator, true);
500    
501                            array[1] = scFrameworkVersion;
502    
503                            array[2] = getByGroupId_PrevAndNext(session, scFrameworkVersion,
504                                            groupId, orderByComparator, false);
505    
506                            return array;
507                    }
508                    catch (Exception e) {
509                            throw processException(e);
510                    }
511                    finally {
512                            closeSession(session);
513                    }
514            }
515    
516            protected SCFrameworkVersion getByGroupId_PrevAndNext(Session session,
517                    SCFrameworkVersion scFrameworkVersion, long groupId,
518                    OrderByComparator orderByComparator, boolean previous) {
519                    StringBundler query = null;
520    
521                    if (orderByComparator != null) {
522                            query = new StringBundler(6 +
523                                            (orderByComparator.getOrderByFields().length * 6));
524                    }
525                    else {
526                            query = new StringBundler(3);
527                    }
528    
529                    query.append(_SQL_SELECT_SCFRAMEWORKVERSION_WHERE);
530    
531                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
532    
533                    if (orderByComparator != null) {
534                            String[] orderByFields = orderByComparator.getOrderByFields();
535    
536                            if (orderByFields.length > 0) {
537                                    query.append(WHERE_AND);
538                            }
539    
540                            for (int i = 0; i < orderByFields.length; i++) {
541                                    query.append(_ORDER_BY_ENTITY_ALIAS);
542                                    query.append(orderByFields[i]);
543    
544                                    if ((i + 1) < orderByFields.length) {
545                                            if (orderByComparator.isAscending() ^ previous) {
546                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
547                                            }
548                                            else {
549                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
550                                            }
551                                    }
552                                    else {
553                                            if (orderByComparator.isAscending() ^ previous) {
554                                                    query.append(WHERE_GREATER_THAN);
555                                            }
556                                            else {
557                                                    query.append(WHERE_LESSER_THAN);
558                                            }
559                                    }
560                            }
561    
562                            query.append(ORDER_BY_CLAUSE);
563    
564                            for (int i = 0; i < orderByFields.length; i++) {
565                                    query.append(_ORDER_BY_ENTITY_ALIAS);
566                                    query.append(orderByFields[i]);
567    
568                                    if ((i + 1) < orderByFields.length) {
569                                            if (orderByComparator.isAscending() ^ previous) {
570                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
571                                            }
572                                            else {
573                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
574                                            }
575                                    }
576                                    else {
577                                            if (orderByComparator.isAscending() ^ previous) {
578                                                    query.append(ORDER_BY_ASC);
579                                            }
580                                            else {
581                                                    query.append(ORDER_BY_DESC);
582                                            }
583                                    }
584                            }
585                    }
586    
587                    else {
588                            query.append(SCFrameworkVersionModelImpl.ORDER_BY_JPQL);
589                    }
590    
591                    String sql = query.toString();
592    
593                    Query q = session.createQuery(sql);
594    
595                    q.setFirstResult(0);
596                    q.setMaxResults(2);
597    
598                    QueryPos qPos = QueryPos.getInstance(q);
599    
600                    qPos.add(groupId);
601    
602                    if (orderByComparator != null) {
603                            Object[] values = orderByComparator.getOrderByValues(scFrameworkVersion);
604    
605                            for (Object value : values) {
606                                    qPos.add(value);
607                            }
608                    }
609    
610                    List<SCFrameworkVersion> list = q.list();
611    
612                    if (list.size() == 2) {
613                            return list.get(1);
614                    }
615                    else {
616                            return null;
617                    }
618            }
619    
620            public List<SCFrameworkVersion> filterFindByGroupId(long groupId)
621                    throws SystemException {
622                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
623                            QueryUtil.ALL_POS, null);
624            }
625    
626            public List<SCFrameworkVersion> filterFindByGroupId(long groupId,
627                    int start, int end) throws SystemException {
628                    return filterFindByGroupId(groupId, start, end, null);
629            }
630    
631            public List<SCFrameworkVersion> filterFindByGroupId(long groupId,
632                    int start, int end, OrderByComparator orderByComparator)
633                    throws SystemException {
634                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
635                            return findByGroupId(groupId, start, end, orderByComparator);
636                    }
637    
638                    Session session = null;
639    
640                    try {
641                            session = openSession();
642    
643                            StringBundler query = null;
644    
645                            if (orderByComparator != null) {
646                                    query = new StringBundler(3 +
647                                                    (orderByComparator.getOrderByFields().length * 3));
648                            }
649                            else {
650                                    query = new StringBundler(3);
651                            }
652    
653                            query.append(_FILTER_SQL_SELECT_SCFRAMEWORKVERSION_WHERE);
654    
655                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
656    
657                            if (orderByComparator != null) {
658                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
659                                            orderByComparator);
660                            }
661    
662                            else {
663                                    query.append(SCFrameworkVersionModelImpl.ORDER_BY_JPQL);
664                            }
665    
666                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
667                                            SCFrameworkVersion.class.getName(), _FILTER_COLUMN_PK,
668                                            _FILTER_COLUMN_USERID, groupId);
669    
670                            SQLQuery q = session.createSQLQuery(sql);
671    
672                            q.addEntity(_FILTER_ENTITY_ALIAS, SCFrameworkVersionImpl.class);
673    
674                            QueryPos qPos = QueryPos.getInstance(q);
675    
676                            qPos.add(groupId);
677    
678                            return (List<SCFrameworkVersion>)QueryUtil.list(q, getDialect(),
679                                    start, end);
680                    }
681                    catch (Exception e) {
682                            throw processException(e);
683                    }
684                    finally {
685                            closeSession(session);
686                    }
687            }
688    
689            public List<SCFrameworkVersion> findByCompanyId(long companyId)
690                    throws SystemException {
691                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
692                            null);
693            }
694    
695            public List<SCFrameworkVersion> findByCompanyId(long companyId, int start,
696                    int end) throws SystemException {
697                    return findByCompanyId(companyId, start, end, null);
698            }
699    
700            public List<SCFrameworkVersion> findByCompanyId(long companyId, int start,
701                    int end, OrderByComparator orderByComparator) throws SystemException {
702                    Object[] finderArgs = new Object[] {
703                                    companyId,
704                                    
705                                    String.valueOf(start), String.valueOf(end),
706                                    String.valueOf(orderByComparator)
707                            };
708    
709                    List<SCFrameworkVersion> list = (List<SCFrameworkVersion>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
710                                    finderArgs, this);
711    
712                    if (list == null) {
713                            Session session = null;
714    
715                            try {
716                                    session = openSession();
717    
718                                    StringBundler query = null;
719    
720                                    if (orderByComparator != null) {
721                                            query = new StringBundler(3 +
722                                                            (orderByComparator.getOrderByFields().length * 3));
723                                    }
724                                    else {
725                                            query = new StringBundler(3);
726                                    }
727    
728                                    query.append(_SQL_SELECT_SCFRAMEWORKVERSION_WHERE);
729    
730                                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
731    
732                                    if (orderByComparator != null) {
733                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
734                                                    orderByComparator);
735                                    }
736    
737                                    else {
738                                            query.append(SCFrameworkVersionModelImpl.ORDER_BY_JPQL);
739                                    }
740    
741                                    String sql = query.toString();
742    
743                                    Query q = session.createQuery(sql);
744    
745                                    QueryPos qPos = QueryPos.getInstance(q);
746    
747                                    qPos.add(companyId);
748    
749                                    list = (List<SCFrameworkVersion>)QueryUtil.list(q,
750                                                    getDialect(), start, end);
751                            }
752                            catch (Exception e) {
753                                    throw processException(e);
754                            }
755                            finally {
756                                    if (list == null) {
757                                            list = new ArrayList<SCFrameworkVersion>();
758                                    }
759    
760                                    cacheResult(list);
761    
762                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
763                                            finderArgs, list);
764    
765                                    closeSession(session);
766                            }
767                    }
768    
769                    return list;
770            }
771    
772            public SCFrameworkVersion findByCompanyId_First(long companyId,
773                    OrderByComparator orderByComparator)
774                    throws NoSuchFrameworkVersionException, SystemException {
775                    List<SCFrameworkVersion> list = findByCompanyId(companyId, 0, 1,
776                                    orderByComparator);
777    
778                    if (list.isEmpty()) {
779                            StringBundler msg = new StringBundler(4);
780    
781                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
782    
783                            msg.append("companyId=");
784                            msg.append(companyId);
785    
786                            msg.append(StringPool.CLOSE_CURLY_BRACE);
787    
788                            throw new NoSuchFrameworkVersionException(msg.toString());
789                    }
790                    else {
791                            return list.get(0);
792                    }
793            }
794    
795            public SCFrameworkVersion findByCompanyId_Last(long companyId,
796                    OrderByComparator orderByComparator)
797                    throws NoSuchFrameworkVersionException, SystemException {
798                    int count = countByCompanyId(companyId);
799    
800                    List<SCFrameworkVersion> list = findByCompanyId(companyId, count - 1,
801                                    count, orderByComparator);
802    
803                    if (list.isEmpty()) {
804                            StringBundler msg = new StringBundler(4);
805    
806                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
807    
808                            msg.append("companyId=");
809                            msg.append(companyId);
810    
811                            msg.append(StringPool.CLOSE_CURLY_BRACE);
812    
813                            throw new NoSuchFrameworkVersionException(msg.toString());
814                    }
815                    else {
816                            return list.get(0);
817                    }
818            }
819    
820            public SCFrameworkVersion[] findByCompanyId_PrevAndNext(
821                    long frameworkVersionId, long companyId,
822                    OrderByComparator orderByComparator)
823                    throws NoSuchFrameworkVersionException, SystemException {
824                    SCFrameworkVersion scFrameworkVersion = findByPrimaryKey(frameworkVersionId);
825    
826                    Session session = null;
827    
828                    try {
829                            session = openSession();
830    
831                            SCFrameworkVersion[] array = new SCFrameworkVersionImpl[3];
832    
833                            array[0] = getByCompanyId_PrevAndNext(session, scFrameworkVersion,
834                                            companyId, orderByComparator, true);
835    
836                            array[1] = scFrameworkVersion;
837    
838                            array[2] = getByCompanyId_PrevAndNext(session, scFrameworkVersion,
839                                            companyId, orderByComparator, false);
840    
841                            return array;
842                    }
843                    catch (Exception e) {
844                            throw processException(e);
845                    }
846                    finally {
847                            closeSession(session);
848                    }
849            }
850    
851            protected SCFrameworkVersion getByCompanyId_PrevAndNext(Session session,
852                    SCFrameworkVersion scFrameworkVersion, long companyId,
853                    OrderByComparator orderByComparator, boolean previous) {
854                    StringBundler query = null;
855    
856                    if (orderByComparator != null) {
857                            query = new StringBundler(6 +
858                                            (orderByComparator.getOrderByFields().length * 6));
859                    }
860                    else {
861                            query = new StringBundler(3);
862                    }
863    
864                    query.append(_SQL_SELECT_SCFRAMEWORKVERSION_WHERE);
865    
866                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
867    
868                    if (orderByComparator != null) {
869                            String[] orderByFields = orderByComparator.getOrderByFields();
870    
871                            if (orderByFields.length > 0) {
872                                    query.append(WHERE_AND);
873                            }
874    
875                            for (int i = 0; i < orderByFields.length; i++) {
876                                    query.append(_ORDER_BY_ENTITY_ALIAS);
877                                    query.append(orderByFields[i]);
878    
879                                    if ((i + 1) < orderByFields.length) {
880                                            if (orderByComparator.isAscending() ^ previous) {
881                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
882                                            }
883                                            else {
884                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
885                                            }
886                                    }
887                                    else {
888                                            if (orderByComparator.isAscending() ^ previous) {
889                                                    query.append(WHERE_GREATER_THAN);
890                                            }
891                                            else {
892                                                    query.append(WHERE_LESSER_THAN);
893                                            }
894                                    }
895                            }
896    
897                            query.append(ORDER_BY_CLAUSE);
898    
899                            for (int i = 0; i < orderByFields.length; i++) {
900                                    query.append(_ORDER_BY_ENTITY_ALIAS);
901                                    query.append(orderByFields[i]);
902    
903                                    if ((i + 1) < orderByFields.length) {
904                                            if (orderByComparator.isAscending() ^ previous) {
905                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
906                                            }
907                                            else {
908                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
909                                            }
910                                    }
911                                    else {
912                                            if (orderByComparator.isAscending() ^ previous) {
913                                                    query.append(ORDER_BY_ASC);
914                                            }
915                                            else {
916                                                    query.append(ORDER_BY_DESC);
917                                            }
918                                    }
919                            }
920                    }
921    
922                    else {
923                            query.append(SCFrameworkVersionModelImpl.ORDER_BY_JPQL);
924                    }
925    
926                    String sql = query.toString();
927    
928                    Query q = session.createQuery(sql);
929    
930                    q.setFirstResult(0);
931                    q.setMaxResults(2);
932    
933                    QueryPos qPos = QueryPos.getInstance(q);
934    
935                    qPos.add(companyId);
936    
937                    if (orderByComparator != null) {
938                            Object[] values = orderByComparator.getOrderByValues(scFrameworkVersion);
939    
940                            for (Object value : values) {
941                                    qPos.add(value);
942                            }
943                    }
944    
945                    List<SCFrameworkVersion> list = q.list();
946    
947                    if (list.size() == 2) {
948                            return list.get(1);
949                    }
950                    else {
951                            return null;
952                    }
953            }
954    
955            public List<SCFrameworkVersion> findByG_A(long groupId, boolean active)
956                    throws SystemException {
957                    return findByG_A(groupId, active, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
958                            null);
959            }
960    
961            public List<SCFrameworkVersion> findByG_A(long groupId, boolean active,
962                    int start, int end) throws SystemException {
963                    return findByG_A(groupId, active, start, end, null);
964            }
965    
966            public List<SCFrameworkVersion> findByG_A(long groupId, boolean active,
967                    int start, int end, OrderByComparator orderByComparator)
968                    throws SystemException {
969                    Object[] finderArgs = new Object[] {
970                                    groupId, active,
971                                    
972                                    String.valueOf(start), String.valueOf(end),
973                                    String.valueOf(orderByComparator)
974                            };
975    
976                    List<SCFrameworkVersion> list = (List<SCFrameworkVersion>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_A,
977                                    finderArgs, this);
978    
979                    if (list == null) {
980                            Session session = null;
981    
982                            try {
983                                    session = openSession();
984    
985                                    StringBundler query = null;
986    
987                                    if (orderByComparator != null) {
988                                            query = new StringBundler(4 +
989                                                            (orderByComparator.getOrderByFields().length * 3));
990                                    }
991                                    else {
992                                            query = new StringBundler(4);
993                                    }
994    
995                                    query.append(_SQL_SELECT_SCFRAMEWORKVERSION_WHERE);
996    
997                                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
998    
999                                    query.append(_FINDER_COLUMN_G_A_ACTIVE_2);
1000    
1001                                    if (orderByComparator != null) {
1002                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1003                                                    orderByComparator);
1004                                    }
1005    
1006                                    else {
1007                                            query.append(SCFrameworkVersionModelImpl.ORDER_BY_JPQL);
1008                                    }
1009    
1010                                    String sql = query.toString();
1011    
1012                                    Query q = session.createQuery(sql);
1013    
1014                                    QueryPos qPos = QueryPos.getInstance(q);
1015    
1016                                    qPos.add(groupId);
1017    
1018                                    qPos.add(active);
1019    
1020                                    list = (List<SCFrameworkVersion>)QueryUtil.list(q,
1021                                                    getDialect(), start, end);
1022                            }
1023                            catch (Exception e) {
1024                                    throw processException(e);
1025                            }
1026                            finally {
1027                                    if (list == null) {
1028                                            list = new ArrayList<SCFrameworkVersion>();
1029                                    }
1030    
1031                                    cacheResult(list);
1032    
1033                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_A, finderArgs,
1034                                            list);
1035    
1036                                    closeSession(session);
1037                            }
1038                    }
1039    
1040                    return list;
1041            }
1042    
1043            public SCFrameworkVersion findByG_A_First(long groupId, boolean active,
1044                    OrderByComparator orderByComparator)
1045                    throws NoSuchFrameworkVersionException, SystemException {
1046                    List<SCFrameworkVersion> list = findByG_A(groupId, active, 0, 1,
1047                                    orderByComparator);
1048    
1049                    if (list.isEmpty()) {
1050                            StringBundler msg = new StringBundler(6);
1051    
1052                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1053    
1054                            msg.append("groupId=");
1055                            msg.append(groupId);
1056    
1057                            msg.append(", active=");
1058                            msg.append(active);
1059    
1060                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1061    
1062                            throw new NoSuchFrameworkVersionException(msg.toString());
1063                    }
1064                    else {
1065                            return list.get(0);
1066                    }
1067            }
1068    
1069            public SCFrameworkVersion findByG_A_Last(long groupId, boolean active,
1070                    OrderByComparator orderByComparator)
1071                    throws NoSuchFrameworkVersionException, SystemException {
1072                    int count = countByG_A(groupId, active);
1073    
1074                    List<SCFrameworkVersion> list = findByG_A(groupId, active, count - 1,
1075                                    count, orderByComparator);
1076    
1077                    if (list.isEmpty()) {
1078                            StringBundler msg = new StringBundler(6);
1079    
1080                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1081    
1082                            msg.append("groupId=");
1083                            msg.append(groupId);
1084    
1085                            msg.append(", active=");
1086                            msg.append(active);
1087    
1088                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1089    
1090                            throw new NoSuchFrameworkVersionException(msg.toString());
1091                    }
1092                    else {
1093                            return list.get(0);
1094                    }
1095            }
1096    
1097            public SCFrameworkVersion[] findByG_A_PrevAndNext(long frameworkVersionId,
1098                    long groupId, boolean active, OrderByComparator orderByComparator)
1099                    throws NoSuchFrameworkVersionException, SystemException {
1100                    SCFrameworkVersion scFrameworkVersion = findByPrimaryKey(frameworkVersionId);
1101    
1102                    Session session = null;
1103    
1104                    try {
1105                            session = openSession();
1106    
1107                            SCFrameworkVersion[] array = new SCFrameworkVersionImpl[3];
1108    
1109                            array[0] = getByG_A_PrevAndNext(session, scFrameworkVersion,
1110                                            groupId, active, orderByComparator, true);
1111    
1112                            array[1] = scFrameworkVersion;
1113    
1114                            array[2] = getByG_A_PrevAndNext(session, scFrameworkVersion,
1115                                            groupId, active, orderByComparator, false);
1116    
1117                            return array;
1118                    }
1119                    catch (Exception e) {
1120                            throw processException(e);
1121                    }
1122                    finally {
1123                            closeSession(session);
1124                    }
1125            }
1126    
1127            protected SCFrameworkVersion getByG_A_PrevAndNext(Session session,
1128                    SCFrameworkVersion scFrameworkVersion, long groupId, boolean active,
1129                    OrderByComparator orderByComparator, boolean previous) {
1130                    StringBundler query = null;
1131    
1132                    if (orderByComparator != null) {
1133                            query = new StringBundler(6 +
1134                                            (orderByComparator.getOrderByFields().length * 6));
1135                    }
1136                    else {
1137                            query = new StringBundler(3);
1138                    }
1139    
1140                    query.append(_SQL_SELECT_SCFRAMEWORKVERSION_WHERE);
1141    
1142                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
1143    
1144                    query.append(_FINDER_COLUMN_G_A_ACTIVE_2);
1145    
1146                    if (orderByComparator != null) {
1147                            String[] orderByFields = orderByComparator.getOrderByFields();
1148    
1149                            if (orderByFields.length > 0) {
1150                                    query.append(WHERE_AND);
1151                            }
1152    
1153                            for (int i = 0; i < orderByFields.length; i++) {
1154                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1155                                    query.append(orderByFields[i]);
1156    
1157                                    if ((i + 1) < orderByFields.length) {
1158                                            if (orderByComparator.isAscending() ^ previous) {
1159                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1160                                            }
1161                                            else {
1162                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1163                                            }
1164                                    }
1165                                    else {
1166                                            if (orderByComparator.isAscending() ^ previous) {
1167                                                    query.append(WHERE_GREATER_THAN);
1168                                            }
1169                                            else {
1170                                                    query.append(WHERE_LESSER_THAN);
1171                                            }
1172                                    }
1173                            }
1174    
1175                            query.append(ORDER_BY_CLAUSE);
1176    
1177                            for (int i = 0; i < orderByFields.length; i++) {
1178                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1179                                    query.append(orderByFields[i]);
1180    
1181                                    if ((i + 1) < orderByFields.length) {
1182                                            if (orderByComparator.isAscending() ^ previous) {
1183                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1184                                            }
1185                                            else {
1186                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1187                                            }
1188                                    }
1189                                    else {
1190                                            if (orderByComparator.isAscending() ^ previous) {
1191                                                    query.append(ORDER_BY_ASC);
1192                                            }
1193                                            else {
1194                                                    query.append(ORDER_BY_DESC);
1195                                            }
1196                                    }
1197                            }
1198                    }
1199    
1200                    else {
1201                            query.append(SCFrameworkVersionModelImpl.ORDER_BY_JPQL);
1202                    }
1203    
1204                    String sql = query.toString();
1205    
1206                    Query q = session.createQuery(sql);
1207    
1208                    q.setFirstResult(0);
1209                    q.setMaxResults(2);
1210    
1211                    QueryPos qPos = QueryPos.getInstance(q);
1212    
1213                    qPos.add(groupId);
1214    
1215                    qPos.add(active);
1216    
1217                    if (orderByComparator != null) {
1218                            Object[] values = orderByComparator.getOrderByValues(scFrameworkVersion);
1219    
1220                            for (Object value : values) {
1221                                    qPos.add(value);
1222                            }
1223                    }
1224    
1225                    List<SCFrameworkVersion> list = q.list();
1226    
1227                    if (list.size() == 2) {
1228                            return list.get(1);
1229                    }
1230                    else {
1231                            return null;
1232                    }
1233            }
1234    
1235            public List<SCFrameworkVersion> filterFindByG_A(long groupId, boolean active)
1236                    throws SystemException {
1237                    return filterFindByG_A(groupId, active, QueryUtil.ALL_POS,
1238                            QueryUtil.ALL_POS, null);
1239            }
1240    
1241            public List<SCFrameworkVersion> filterFindByG_A(long groupId,
1242                    boolean active, int start, int end) throws SystemException {
1243                    return filterFindByG_A(groupId, active, start, end, null);
1244            }
1245    
1246            public List<SCFrameworkVersion> filterFindByG_A(long groupId,
1247                    boolean active, int start, int end, OrderByComparator orderByComparator)
1248                    throws SystemException {
1249                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1250                            return findByG_A(groupId, active, start, end, orderByComparator);
1251                    }
1252    
1253                    Session session = null;
1254    
1255                    try {
1256                            session = openSession();
1257    
1258                            StringBundler query = null;
1259    
1260                            if (orderByComparator != null) {
1261                                    query = new StringBundler(4 +
1262                                                    (orderByComparator.getOrderByFields().length * 3));
1263                            }
1264                            else {
1265                                    query = new StringBundler(4);
1266                            }
1267    
1268                            query.append(_FILTER_SQL_SELECT_SCFRAMEWORKVERSION_WHERE);
1269    
1270                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
1271    
1272                            query.append(_FINDER_COLUMN_G_A_ACTIVE_2);
1273    
1274                            if (orderByComparator != null) {
1275                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1276                                            orderByComparator);
1277                            }
1278    
1279                            else {
1280                                    query.append(SCFrameworkVersionModelImpl.ORDER_BY_JPQL);
1281                            }
1282    
1283                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1284                                            SCFrameworkVersion.class.getName(), _FILTER_COLUMN_PK,
1285                                            _FILTER_COLUMN_USERID, groupId);
1286    
1287                            SQLQuery q = session.createSQLQuery(sql);
1288    
1289                            q.addEntity(_FILTER_ENTITY_ALIAS, SCFrameworkVersionImpl.class);
1290    
1291                            QueryPos qPos = QueryPos.getInstance(q);
1292    
1293                            qPos.add(groupId);
1294    
1295                            qPos.add(active);
1296    
1297                            return (List<SCFrameworkVersion>)QueryUtil.list(q, getDialect(),
1298                                    start, end);
1299                    }
1300                    catch (Exception e) {
1301                            throw processException(e);
1302                    }
1303                    finally {
1304                            closeSession(session);
1305                    }
1306            }
1307    
1308            public List<SCFrameworkVersion> findAll() throws SystemException {
1309                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1310            }
1311    
1312            public List<SCFrameworkVersion> findAll(int start, int end)
1313                    throws SystemException {
1314                    return findAll(start, end, null);
1315            }
1316    
1317            public List<SCFrameworkVersion> findAll(int start, int end,
1318                    OrderByComparator orderByComparator) throws SystemException {
1319                    Object[] finderArgs = new Object[] {
1320                                    String.valueOf(start), String.valueOf(end),
1321                                    String.valueOf(orderByComparator)
1322                            };
1323    
1324                    List<SCFrameworkVersion> list = (List<SCFrameworkVersion>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1325                                    finderArgs, this);
1326    
1327                    if (list == null) {
1328                            Session session = null;
1329    
1330                            try {
1331                                    session = openSession();
1332    
1333                                    StringBundler query = null;
1334                                    String sql = null;
1335    
1336                                    if (orderByComparator != null) {
1337                                            query = new StringBundler(2 +
1338                                                            (orderByComparator.getOrderByFields().length * 3));
1339    
1340                                            query.append(_SQL_SELECT_SCFRAMEWORKVERSION);
1341    
1342                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1343                                                    orderByComparator);
1344    
1345                                            sql = query.toString();
1346                                    }
1347                                    else {
1348                                            sql = _SQL_SELECT_SCFRAMEWORKVERSION.concat(SCFrameworkVersionModelImpl.ORDER_BY_JPQL);
1349                                    }
1350    
1351                                    Query q = session.createQuery(sql);
1352    
1353                                    if (orderByComparator == null) {
1354                                            list = (List<SCFrameworkVersion>)QueryUtil.list(q,
1355                                                            getDialect(), start, end, false);
1356    
1357                                            Collections.sort(list);
1358                                    }
1359                                    else {
1360                                            list = (List<SCFrameworkVersion>)QueryUtil.list(q,
1361                                                            getDialect(), start, end);
1362                                    }
1363                            }
1364                            catch (Exception e) {
1365                                    throw processException(e);
1366                            }
1367                            finally {
1368                                    if (list == null) {
1369                                            list = new ArrayList<SCFrameworkVersion>();
1370                                    }
1371    
1372                                    cacheResult(list);
1373    
1374                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1375    
1376                                    closeSession(session);
1377                            }
1378                    }
1379    
1380                    return list;
1381            }
1382    
1383            public void removeByGroupId(long groupId) throws SystemException {
1384                    for (SCFrameworkVersion scFrameworkVersion : findByGroupId(groupId)) {
1385                            remove(scFrameworkVersion);
1386                    }
1387            }
1388    
1389            public void removeByCompanyId(long companyId) throws SystemException {
1390                    for (SCFrameworkVersion scFrameworkVersion : findByCompanyId(companyId)) {
1391                            remove(scFrameworkVersion);
1392                    }
1393            }
1394    
1395            public void removeByG_A(long groupId, boolean active)
1396                    throws SystemException {
1397                    for (SCFrameworkVersion scFrameworkVersion : findByG_A(groupId, active)) {
1398                            remove(scFrameworkVersion);
1399                    }
1400            }
1401    
1402            public void removeAll() throws SystemException {
1403                    for (SCFrameworkVersion scFrameworkVersion : findAll()) {
1404                            remove(scFrameworkVersion);
1405                    }
1406            }
1407    
1408            public int countByGroupId(long groupId) throws SystemException {
1409                    Object[] finderArgs = new Object[] { groupId };
1410    
1411                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1412                                    finderArgs, this);
1413    
1414                    if (count == null) {
1415                            Session session = null;
1416    
1417                            try {
1418                                    session = openSession();
1419    
1420                                    StringBundler query = new StringBundler(2);
1421    
1422                                    query.append(_SQL_COUNT_SCFRAMEWORKVERSION_WHERE);
1423    
1424                                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1425    
1426                                    String sql = query.toString();
1427    
1428                                    Query q = session.createQuery(sql);
1429    
1430                                    QueryPos qPos = QueryPos.getInstance(q);
1431    
1432                                    qPos.add(groupId);
1433    
1434                                    count = (Long)q.uniqueResult();
1435                            }
1436                            catch (Exception e) {
1437                                    throw processException(e);
1438                            }
1439                            finally {
1440                                    if (count == null) {
1441                                            count = Long.valueOf(0);
1442                                    }
1443    
1444                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1445                                            finderArgs, count);
1446    
1447                                    closeSession(session);
1448                            }
1449                    }
1450    
1451                    return count.intValue();
1452            }
1453    
1454            public int filterCountByGroupId(long groupId) throws SystemException {
1455                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1456                            return countByGroupId(groupId);
1457                    }
1458    
1459                    Session session = null;
1460    
1461                    try {
1462                            session = openSession();
1463    
1464                            StringBundler query = new StringBundler(2);
1465    
1466                            query.append(_FILTER_SQL_COUNT_SCFRAMEWORKVERSION_WHERE);
1467    
1468                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1469    
1470                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1471                                            SCFrameworkVersion.class.getName(), _FILTER_COLUMN_PK,
1472                                            _FILTER_COLUMN_USERID, groupId);
1473    
1474                            SQLQuery q = session.createSQLQuery(sql);
1475    
1476                            q.addScalar(COUNT_COLUMN_NAME,
1477                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
1478    
1479                            QueryPos qPos = QueryPos.getInstance(q);
1480    
1481                            qPos.add(groupId);
1482    
1483                            Long count = (Long)q.uniqueResult();
1484    
1485                            return count.intValue();
1486                    }
1487                    catch (Exception e) {
1488                            throw processException(e);
1489                    }
1490                    finally {
1491                            closeSession(session);
1492                    }
1493            }
1494    
1495            public int countByCompanyId(long companyId) throws SystemException {
1496                    Object[] finderArgs = new Object[] { companyId };
1497    
1498                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
1499                                    finderArgs, this);
1500    
1501                    if (count == null) {
1502                            Session session = null;
1503    
1504                            try {
1505                                    session = openSession();
1506    
1507                                    StringBundler query = new StringBundler(2);
1508    
1509                                    query.append(_SQL_COUNT_SCFRAMEWORKVERSION_WHERE);
1510    
1511                                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1512    
1513                                    String sql = query.toString();
1514    
1515                                    Query q = session.createQuery(sql);
1516    
1517                                    QueryPos qPos = QueryPos.getInstance(q);
1518    
1519                                    qPos.add(companyId);
1520    
1521                                    count = (Long)q.uniqueResult();
1522                            }
1523                            catch (Exception e) {
1524                                    throw processException(e);
1525                            }
1526                            finally {
1527                                    if (count == null) {
1528                                            count = Long.valueOf(0);
1529                                    }
1530    
1531                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
1532                                            finderArgs, count);
1533    
1534                                    closeSession(session);
1535                            }
1536                    }
1537    
1538                    return count.intValue();
1539            }
1540    
1541            public int countByG_A(long groupId, boolean active)
1542                    throws SystemException {
1543                    Object[] finderArgs = new Object[] { groupId, active };
1544    
1545                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A,
1546                                    finderArgs, this);
1547    
1548                    if (count == null) {
1549                            Session session = null;
1550    
1551                            try {
1552                                    session = openSession();
1553    
1554                                    StringBundler query = new StringBundler(3);
1555    
1556                                    query.append(_SQL_COUNT_SCFRAMEWORKVERSION_WHERE);
1557    
1558                                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
1559    
1560                                    query.append(_FINDER_COLUMN_G_A_ACTIVE_2);
1561    
1562                                    String sql = query.toString();
1563    
1564                                    Query q = session.createQuery(sql);
1565    
1566                                    QueryPos qPos = QueryPos.getInstance(q);
1567    
1568                                    qPos.add(groupId);
1569    
1570                                    qPos.add(active);
1571    
1572                                    count = (Long)q.uniqueResult();
1573                            }
1574                            catch (Exception e) {
1575                                    throw processException(e);
1576                            }
1577                            finally {
1578                                    if (count == null) {
1579                                            count = Long.valueOf(0);
1580                                    }
1581    
1582                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A, finderArgs,
1583                                            count);
1584    
1585                                    closeSession(session);
1586                            }
1587                    }
1588    
1589                    return count.intValue();
1590            }
1591    
1592            public int filterCountByG_A(long groupId, boolean active)
1593                    throws SystemException {
1594                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1595                            return countByG_A(groupId, active);
1596                    }
1597    
1598                    Session session = null;
1599    
1600                    try {
1601                            session = openSession();
1602    
1603                            StringBundler query = new StringBundler(3);
1604    
1605                            query.append(_FILTER_SQL_COUNT_SCFRAMEWORKVERSION_WHERE);
1606    
1607                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
1608    
1609                            query.append(_FINDER_COLUMN_G_A_ACTIVE_2);
1610    
1611                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1612                                            SCFrameworkVersion.class.getName(), _FILTER_COLUMN_PK,
1613                                            _FILTER_COLUMN_USERID, groupId);
1614    
1615                            SQLQuery q = session.createSQLQuery(sql);
1616    
1617                            q.addScalar(COUNT_COLUMN_NAME,
1618                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
1619    
1620                            QueryPos qPos = QueryPos.getInstance(q);
1621    
1622                            qPos.add(groupId);
1623    
1624                            qPos.add(active);
1625    
1626                            Long count = (Long)q.uniqueResult();
1627    
1628                            return count.intValue();
1629                    }
1630                    catch (Exception e) {
1631                            throw processException(e);
1632                    }
1633                    finally {
1634                            closeSession(session);
1635                    }
1636            }
1637    
1638            public int countAll() throws SystemException {
1639                    Object[] finderArgs = new Object[0];
1640    
1641                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1642                                    finderArgs, this);
1643    
1644                    if (count == null) {
1645                            Session session = null;
1646    
1647                            try {
1648                                    session = openSession();
1649    
1650                                    Query q = session.createQuery(_SQL_COUNT_SCFRAMEWORKVERSION);
1651    
1652                                    count = (Long)q.uniqueResult();
1653                            }
1654                            catch (Exception e) {
1655                                    throw processException(e);
1656                            }
1657                            finally {
1658                                    if (count == null) {
1659                                            count = Long.valueOf(0);
1660                                    }
1661    
1662                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1663                                            count);
1664    
1665                                    closeSession(session);
1666                            }
1667                    }
1668    
1669                    return count.intValue();
1670            }
1671    
1672            public List<com.liferay.portlet.softwarecatalog.model.SCProductVersion> getSCProductVersions(
1673                    long pk) throws SystemException {
1674                    return getSCProductVersions(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1675            }
1676    
1677            public List<com.liferay.portlet.softwarecatalog.model.SCProductVersion> getSCProductVersions(
1678                    long pk, int start, int end) throws SystemException {
1679                    return getSCProductVersions(pk, start, end, null);
1680            }
1681    
1682            public static final FinderPath FINDER_PATH_GET_SCPRODUCTVERSIONS = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
1683                            SCFrameworkVersionModelImpl.FINDER_CACHE_ENABLED_SCFRAMEWORKVERSI_SCPRODUCTVERS,
1684                            SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME,
1685                            "getSCProductVersions",
1686                            new String[] {
1687                                    Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1688                                    "com.liferay.portal.kernel.util.OrderByComparator"
1689                            });
1690    
1691            public List<com.liferay.portlet.softwarecatalog.model.SCProductVersion> getSCProductVersions(
1692                    long pk, int start, int end, OrderByComparator orderByComparator)
1693                    throws SystemException {
1694                    Object[] finderArgs = new Object[] {
1695                                    pk, String.valueOf(start), String.valueOf(end),
1696                                    String.valueOf(orderByComparator)
1697                            };
1698    
1699                    List<com.liferay.portlet.softwarecatalog.model.SCProductVersion> list = (List<com.liferay.portlet.softwarecatalog.model.SCProductVersion>)FinderCacheUtil.getResult(FINDER_PATH_GET_SCPRODUCTVERSIONS,
1700                                    finderArgs, this);
1701    
1702                    if (list == null) {
1703                            Session session = null;
1704    
1705                            try {
1706                                    session = openSession();
1707    
1708                                    String sql = null;
1709    
1710                                    if (orderByComparator != null) {
1711                                            sql = _SQL_GETSCPRODUCTVERSIONS.concat(ORDER_BY_CLAUSE)
1712                                                                                                       .concat(orderByComparator.getOrderBy());
1713                                    }
1714                                    else {
1715                                            sql = _SQL_GETSCPRODUCTVERSIONS.concat(com.liferay.portlet.softwarecatalog.model.impl.SCProductVersionModelImpl.ORDER_BY_SQL);
1716                                    }
1717    
1718                                    SQLQuery q = session.createSQLQuery(sql);
1719    
1720                                    q.addEntity("SCProductVersion",
1721                                            com.liferay.portlet.softwarecatalog.model.impl.SCProductVersionImpl.class);
1722    
1723                                    QueryPos qPos = QueryPos.getInstance(q);
1724    
1725                                    qPos.add(pk);
1726    
1727                                    list = (List<com.liferay.portlet.softwarecatalog.model.SCProductVersion>)QueryUtil.list(q,
1728                                                    getDialect(), start, end);
1729                            }
1730                            catch (Exception e) {
1731                                    throw processException(e);
1732                            }
1733                            finally {
1734                                    if (list == null) {
1735                                            list = new ArrayList<com.liferay.portlet.softwarecatalog.model.SCProductVersion>();
1736                                    }
1737    
1738                                    scProductVersionPersistence.cacheResult(list);
1739    
1740                                    FinderCacheUtil.putResult(FINDER_PATH_GET_SCPRODUCTVERSIONS,
1741                                            finderArgs, list);
1742    
1743                                    closeSession(session);
1744                            }
1745                    }
1746    
1747                    return list;
1748            }
1749    
1750            public static final FinderPath FINDER_PATH_GET_SCPRODUCTVERSIONS_SIZE = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
1751                            SCFrameworkVersionModelImpl.FINDER_CACHE_ENABLED_SCFRAMEWORKVERSI_SCPRODUCTVERS,
1752                            SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME,
1753                            "getSCProductVersionsSize", new String[] { Long.class.getName() });
1754    
1755            public int getSCProductVersionsSize(long pk) throws SystemException {
1756                    Object[] finderArgs = new Object[] { pk };
1757    
1758                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_SCPRODUCTVERSIONS_SIZE,
1759                                    finderArgs, this);
1760    
1761                    if (count == null) {
1762                            Session session = null;
1763    
1764                            try {
1765                                    session = openSession();
1766    
1767                                    SQLQuery q = session.createSQLQuery(_SQL_GETSCPRODUCTVERSIONSSIZE);
1768    
1769                                    q.addScalar(COUNT_COLUMN_NAME,
1770                                            com.liferay.portal.kernel.dao.orm.Type.LONG);
1771    
1772                                    QueryPos qPos = QueryPos.getInstance(q);
1773    
1774                                    qPos.add(pk);
1775    
1776                                    count = (Long)q.uniqueResult();
1777                            }
1778                            catch (Exception e) {
1779                                    throw processException(e);
1780                            }
1781                            finally {
1782                                    if (count == null) {
1783                                            count = Long.valueOf(0);
1784                                    }
1785    
1786                                    FinderCacheUtil.putResult(FINDER_PATH_GET_SCPRODUCTVERSIONS_SIZE,
1787                                            finderArgs, count);
1788    
1789                                    closeSession(session);
1790                            }
1791                    }
1792    
1793                    return count.intValue();
1794            }
1795    
1796            public static final FinderPath FINDER_PATH_CONTAINS_SCPRODUCTVERSION = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCProductVersionModelImpl.ENTITY_CACHE_ENABLED,
1797                            SCFrameworkVersionModelImpl.FINDER_CACHE_ENABLED_SCFRAMEWORKVERSI_SCPRODUCTVERS,
1798                            SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME,
1799                            "containsSCProductVersion",
1800                            new String[] { Long.class.getName(), Long.class.getName() });
1801    
1802            public boolean containsSCProductVersion(long pk, long scProductVersionPK)
1803                    throws SystemException {
1804                    Object[] finderArgs = new Object[] { pk, scProductVersionPK };
1805    
1806                    Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_SCPRODUCTVERSION,
1807                                    finderArgs, this);
1808    
1809                    if (value == null) {
1810                            try {
1811                                    value = Boolean.valueOf(containsSCProductVersion.contains(pk,
1812                                                            scProductVersionPK));
1813                            }
1814                            catch (Exception e) {
1815                                    throw processException(e);
1816                            }
1817                            finally {
1818                                    if (value == null) {
1819                                            value = Boolean.FALSE;
1820                                    }
1821    
1822                                    FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_SCPRODUCTVERSION,
1823                                            finderArgs, value);
1824                            }
1825                    }
1826    
1827                    return value.booleanValue();
1828            }
1829    
1830            public boolean containsSCProductVersions(long pk) throws SystemException {
1831                    if (getSCProductVersionsSize(pk) > 0) {
1832                            return true;
1833                    }
1834                    else {
1835                            return false;
1836                    }
1837            }
1838    
1839            public void addSCProductVersion(long pk, long scProductVersionPK)
1840                    throws SystemException {
1841                    try {
1842                            addSCProductVersion.add(pk, scProductVersionPK);
1843                    }
1844                    catch (Exception e) {
1845                            throw processException(e);
1846                    }
1847                    finally {
1848                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1849                    }
1850            }
1851    
1852            public void addSCProductVersion(long pk,
1853                    com.liferay.portlet.softwarecatalog.model.SCProductVersion scProductVersion)
1854                    throws SystemException {
1855                    try {
1856                            addSCProductVersion.add(pk, scProductVersion.getPrimaryKey());
1857                    }
1858                    catch (Exception e) {
1859                            throw processException(e);
1860                    }
1861                    finally {
1862                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1863                    }
1864            }
1865    
1866            public void addSCProductVersions(long pk, long[] scProductVersionPKs)
1867                    throws SystemException {
1868                    try {
1869                            for (long scProductVersionPK : scProductVersionPKs) {
1870                                    addSCProductVersion.add(pk, scProductVersionPK);
1871                            }
1872                    }
1873                    catch (Exception e) {
1874                            throw processException(e);
1875                    }
1876                    finally {
1877                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1878                    }
1879            }
1880    
1881            public void addSCProductVersions(long pk,
1882                    List<com.liferay.portlet.softwarecatalog.model.SCProductVersion> scProductVersions)
1883                    throws SystemException {
1884                    try {
1885                            for (com.liferay.portlet.softwarecatalog.model.SCProductVersion scProductVersion : scProductVersions) {
1886                                    addSCProductVersion.add(pk, scProductVersion.getPrimaryKey());
1887                            }
1888                    }
1889                    catch (Exception e) {
1890                            throw processException(e);
1891                    }
1892                    finally {
1893                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1894                    }
1895            }
1896    
1897            public void clearSCProductVersions(long pk) throws SystemException {
1898                    try {
1899                            clearSCProductVersions.clear(pk);
1900                    }
1901                    catch (Exception e) {
1902                            throw processException(e);
1903                    }
1904                    finally {
1905                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1906                    }
1907            }
1908    
1909            public void removeSCProductVersion(long pk, long scProductVersionPK)
1910                    throws SystemException {
1911                    try {
1912                            removeSCProductVersion.remove(pk, scProductVersionPK);
1913                    }
1914                    catch (Exception e) {
1915                            throw processException(e);
1916                    }
1917                    finally {
1918                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1919                    }
1920            }
1921    
1922            public void removeSCProductVersion(long pk,
1923                    com.liferay.portlet.softwarecatalog.model.SCProductVersion scProductVersion)
1924                    throws SystemException {
1925                    try {
1926                            removeSCProductVersion.remove(pk, scProductVersion.getPrimaryKey());
1927                    }
1928                    catch (Exception e) {
1929                            throw processException(e);
1930                    }
1931                    finally {
1932                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1933                    }
1934            }
1935    
1936            public void removeSCProductVersions(long pk, long[] scProductVersionPKs)
1937                    throws SystemException {
1938                    try {
1939                            for (long scProductVersionPK : scProductVersionPKs) {
1940                                    removeSCProductVersion.remove(pk, scProductVersionPK);
1941                            }
1942                    }
1943                    catch (Exception e) {
1944                            throw processException(e);
1945                    }
1946                    finally {
1947                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1948                    }
1949            }
1950    
1951            public void removeSCProductVersions(long pk,
1952                    List<com.liferay.portlet.softwarecatalog.model.SCProductVersion> scProductVersions)
1953                    throws SystemException {
1954                    try {
1955                            for (com.liferay.portlet.softwarecatalog.model.SCProductVersion scProductVersion : scProductVersions) {
1956                                    removeSCProductVersion.remove(pk,
1957                                            scProductVersion.getPrimaryKey());
1958                            }
1959                    }
1960                    catch (Exception e) {
1961                            throw processException(e);
1962                    }
1963                    finally {
1964                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1965                    }
1966            }
1967    
1968            public void setSCProductVersions(long pk, long[] scProductVersionPKs)
1969                    throws SystemException {
1970                    try {
1971                            Set<Long> scProductVersionPKSet = SetUtil.fromArray(scProductVersionPKs);
1972    
1973                            List<com.liferay.portlet.softwarecatalog.model.SCProductVersion> scProductVersions =
1974                                    getSCProductVersions(pk);
1975    
1976                            for (com.liferay.portlet.softwarecatalog.model.SCProductVersion scProductVersion : scProductVersions) {
1977                                    if (!scProductVersionPKSet.contains(
1978                                                            scProductVersion.getPrimaryKey())) {
1979                                            removeSCProductVersion.remove(pk,
1980                                                    scProductVersion.getPrimaryKey());
1981                                    }
1982                                    else {
1983                                            scProductVersionPKSet.remove(scProductVersion.getPrimaryKey());
1984                                    }
1985                            }
1986    
1987                            for (Long scProductVersionPK : scProductVersionPKSet) {
1988                                    addSCProductVersion.add(pk, scProductVersionPK);
1989                            }
1990                    }
1991                    catch (Exception e) {
1992                            throw processException(e);
1993                    }
1994                    finally {
1995                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
1996                    }
1997            }
1998    
1999            public void setSCProductVersions(long pk,
2000                    List<com.liferay.portlet.softwarecatalog.model.SCProductVersion> scProductVersions)
2001                    throws SystemException {
2002                    try {
2003                            long[] scProductVersionPKs = new long[scProductVersions.size()];
2004    
2005                            for (int i = 0; i < scProductVersions.size(); i++) {
2006                                    com.liferay.portlet.softwarecatalog.model.SCProductVersion scProductVersion =
2007                                            scProductVersions.get(i);
2008    
2009                                    scProductVersionPKs[i] = scProductVersion.getPrimaryKey();
2010                            }
2011    
2012                            setSCProductVersions(pk, scProductVersionPKs);
2013                    }
2014                    catch (Exception e) {
2015                            throw processException(e);
2016                    }
2017                    finally {
2018                            FinderCacheUtil.clearCache(SCFrameworkVersionModelImpl.MAPPING_TABLE_SCFRAMEWORKVERSI_SCPRODUCTVERS_NAME);
2019                    }
2020            }
2021    
2022            public void afterPropertiesSet() {
2023                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2024                                            com.liferay.portal.util.PropsUtil.get(
2025                                                    "value.object.listener.com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion")));
2026    
2027                    if (listenerClassNames.length > 0) {
2028                            try {
2029                                    List<ModelListener<SCFrameworkVersion>> listenersList = new ArrayList<ModelListener<SCFrameworkVersion>>();
2030    
2031                                    for (String listenerClassName : listenerClassNames) {
2032                                            listenersList.add((ModelListener<SCFrameworkVersion>)InstanceFactory.newInstance(
2033                                                            listenerClassName));
2034                                    }
2035    
2036                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2037                            }
2038                            catch (Exception e) {
2039                                    _log.error(e);
2040                            }
2041                    }
2042    
2043                    containsSCProductVersion = new ContainsSCProductVersion(this);
2044    
2045                    addSCProductVersion = new AddSCProductVersion(this);
2046                    clearSCProductVersions = new ClearSCProductVersions(this);
2047                    removeSCProductVersion = new RemoveSCProductVersion(this);
2048            }
2049    
2050            @BeanReference(type = SCLicensePersistence.class)
2051            protected SCLicensePersistence scLicensePersistence;
2052            @BeanReference(type = SCFrameworkVersionPersistence.class)
2053            protected SCFrameworkVersionPersistence scFrameworkVersionPersistence;
2054            @BeanReference(type = SCProductEntryPersistence.class)
2055            protected SCProductEntryPersistence scProductEntryPersistence;
2056            @BeanReference(type = SCProductScreenshotPersistence.class)
2057            protected SCProductScreenshotPersistence scProductScreenshotPersistence;
2058            @BeanReference(type = SCProductVersionPersistence.class)
2059            protected SCProductVersionPersistence scProductVersionPersistence;
2060            @BeanReference(type = ResourcePersistence.class)
2061            protected ResourcePersistence resourcePersistence;
2062            @BeanReference(type = UserPersistence.class)
2063            protected UserPersistence userPersistence;
2064            protected ContainsSCProductVersion containsSCProductVersion;
2065            protected AddSCProductVersion addSCProductVersion;
2066            protected ClearSCProductVersions clearSCProductVersions;
2067            protected RemoveSCProductVersion removeSCProductVersion;
2068    
2069            protected class ContainsSCProductVersion {
2070                    protected ContainsSCProductVersion(
2071                            SCFrameworkVersionPersistenceImpl persistenceImpl) {
2072                            super();
2073    
2074                            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2075                                            _SQL_CONTAINSSCPRODUCTVERSION,
2076                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
2077                                            RowMapper.COUNT);
2078                    }
2079    
2080                    protected boolean contains(long frameworkVersionId,
2081                            long productVersionId) {
2082                            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2083                                                    new Long(frameworkVersionId), new Long(productVersionId)
2084                                            });
2085    
2086                            if (results.size() > 0) {
2087                                    Integer count = results.get(0);
2088    
2089                                    if (count.intValue() > 0) {
2090                                            return true;
2091                                    }
2092                            }
2093    
2094                            return false;
2095                    }
2096    
2097                    private MappingSqlQuery<Integer> _mappingSqlQuery;
2098            }
2099    
2100            protected class AddSCProductVersion {
2101                    protected AddSCProductVersion(
2102                            SCFrameworkVersionPersistenceImpl persistenceImpl) {
2103                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2104                                            "INSERT INTO SCFrameworkVersi_SCProductVers (frameworkVersionId, productVersionId) VALUES (?, ?)",
2105                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2106                            _persistenceImpl = persistenceImpl;
2107                    }
2108    
2109                    protected void add(long frameworkVersionId, long productVersionId)
2110                            throws SystemException {
2111                            if (!_persistenceImpl.containsSCProductVersion.contains(
2112                                                    frameworkVersionId, productVersionId)) {
2113                                    ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductVersion>[] scProductVersionListeners =
2114                                            scProductVersionPersistence.getListeners();
2115    
2116                                    for (ModelListener<SCFrameworkVersion> listener : listeners) {
2117                                            listener.onBeforeAddAssociation(frameworkVersionId,
2118                                                    com.liferay.portlet.softwarecatalog.model.SCProductVersion.class.getName(),
2119                                                    productVersionId);
2120                                    }
2121    
2122                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductVersion> listener : scProductVersionListeners) {
2123                                            listener.onBeforeAddAssociation(productVersionId,
2124                                                    SCFrameworkVersion.class.getName(), frameworkVersionId);
2125                                    }
2126    
2127                                    _sqlUpdate.update(new Object[] {
2128                                                    new Long(frameworkVersionId), new Long(productVersionId)
2129                                            });
2130    
2131                                    for (ModelListener<SCFrameworkVersion> listener : listeners) {
2132                                            listener.onAfterAddAssociation(frameworkVersionId,
2133                                                    com.liferay.portlet.softwarecatalog.model.SCProductVersion.class.getName(),
2134                                                    productVersionId);
2135                                    }
2136    
2137                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductVersion> listener : scProductVersionListeners) {
2138                                            listener.onAfterAddAssociation(productVersionId,
2139                                                    SCFrameworkVersion.class.getName(), frameworkVersionId);
2140                                    }
2141                            }
2142                    }
2143    
2144                    private SqlUpdate _sqlUpdate;
2145                    private SCFrameworkVersionPersistenceImpl _persistenceImpl;
2146            }
2147    
2148            protected class ClearSCProductVersions {
2149                    protected ClearSCProductVersions(
2150                            SCFrameworkVersionPersistenceImpl persistenceImpl) {
2151                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2152                                            "DELETE FROM SCFrameworkVersi_SCProductVers WHERE frameworkVersionId = ?",
2153                                            new int[] { java.sql.Types.BIGINT });
2154                    }
2155    
2156                    protected void clear(long frameworkVersionId) throws SystemException {
2157                            ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductVersion>[] scProductVersionListeners =
2158                                    scProductVersionPersistence.getListeners();
2159    
2160                            List<com.liferay.portlet.softwarecatalog.model.SCProductVersion> scProductVersions =
2161                                    null;
2162    
2163                            if ((listeners.length > 0) ||
2164                                            (scProductVersionListeners.length > 0)) {
2165                                    scProductVersions = getSCProductVersions(frameworkVersionId);
2166    
2167                                    for (com.liferay.portlet.softwarecatalog.model.SCProductVersion scProductVersion : scProductVersions) {
2168                                            for (ModelListener<SCFrameworkVersion> listener : listeners) {
2169                                                    listener.onBeforeRemoveAssociation(frameworkVersionId,
2170                                                            com.liferay.portlet.softwarecatalog.model.SCProductVersion.class.getName(),
2171                                                            scProductVersion.getPrimaryKey());
2172                                            }
2173    
2174                                            for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductVersion> listener : scProductVersionListeners) {
2175                                                    listener.onBeforeRemoveAssociation(scProductVersion.getPrimaryKey(),
2176                                                            SCFrameworkVersion.class.getName(),
2177                                                            frameworkVersionId);
2178                                            }
2179                                    }
2180                            }
2181    
2182                            _sqlUpdate.update(new Object[] { new Long(frameworkVersionId) });
2183    
2184                            if ((listeners.length > 0) ||
2185                                            (scProductVersionListeners.length > 0)) {
2186                                    for (com.liferay.portlet.softwarecatalog.model.SCProductVersion scProductVersion : scProductVersions) {
2187                                            for (ModelListener<SCFrameworkVersion> listener : listeners) {
2188                                                    listener.onAfterRemoveAssociation(frameworkVersionId,
2189                                                            com.liferay.portlet.softwarecatalog.model.SCProductVersion.class.getName(),
2190                                                            scProductVersion.getPrimaryKey());
2191                                            }
2192    
2193                                            for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductVersion> listener : scProductVersionListeners) {
2194                                                    listener.onAfterRemoveAssociation(scProductVersion.getPrimaryKey(),
2195                                                            SCFrameworkVersion.class.getName(),
2196                                                            frameworkVersionId);
2197                                            }
2198                                    }
2199                            }
2200                    }
2201    
2202                    private SqlUpdate _sqlUpdate;
2203            }
2204    
2205            protected class RemoveSCProductVersion {
2206                    protected RemoveSCProductVersion(
2207                            SCFrameworkVersionPersistenceImpl persistenceImpl) {
2208                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2209                                            "DELETE FROM SCFrameworkVersi_SCProductVers WHERE frameworkVersionId = ? AND productVersionId = ?",
2210                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2211                            _persistenceImpl = persistenceImpl;
2212                    }
2213    
2214                    protected void remove(long frameworkVersionId, long productVersionId)
2215                            throws SystemException {
2216                            if (_persistenceImpl.containsSCProductVersion.contains(
2217                                                    frameworkVersionId, productVersionId)) {
2218                                    ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductVersion>[] scProductVersionListeners =
2219                                            scProductVersionPersistence.getListeners();
2220    
2221                                    for (ModelListener<SCFrameworkVersion> listener : listeners) {
2222                                            listener.onBeforeRemoveAssociation(frameworkVersionId,
2223                                                    com.liferay.portlet.softwarecatalog.model.SCProductVersion.class.getName(),
2224                                                    productVersionId);
2225                                    }
2226    
2227                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductVersion> listener : scProductVersionListeners) {
2228                                            listener.onBeforeRemoveAssociation(productVersionId,
2229                                                    SCFrameworkVersion.class.getName(), frameworkVersionId);
2230                                    }
2231    
2232                                    _sqlUpdate.update(new Object[] {
2233                                                    new Long(frameworkVersionId), new Long(productVersionId)
2234                                            });
2235    
2236                                    for (ModelListener<SCFrameworkVersion> listener : listeners) {
2237                                            listener.onAfterRemoveAssociation(frameworkVersionId,
2238                                                    com.liferay.portlet.softwarecatalog.model.SCProductVersion.class.getName(),
2239                                                    productVersionId);
2240                                    }
2241    
2242                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCProductVersion> listener : scProductVersionListeners) {
2243                                            listener.onAfterRemoveAssociation(productVersionId,
2244                                                    SCFrameworkVersion.class.getName(), frameworkVersionId);
2245                                    }
2246                            }
2247                    }
2248    
2249                    private SqlUpdate _sqlUpdate;
2250                    private SCFrameworkVersionPersistenceImpl _persistenceImpl;
2251            }
2252    
2253            private static final String _SQL_SELECT_SCFRAMEWORKVERSION = "SELECT scFrameworkVersion FROM SCFrameworkVersion scFrameworkVersion";
2254            private static final String _SQL_SELECT_SCFRAMEWORKVERSION_WHERE = "SELECT scFrameworkVersion FROM SCFrameworkVersion scFrameworkVersion WHERE ";
2255            private static final String _SQL_COUNT_SCFRAMEWORKVERSION = "SELECT COUNT(scFrameworkVersion) FROM SCFrameworkVersion scFrameworkVersion";
2256            private static final String _SQL_COUNT_SCFRAMEWORKVERSION_WHERE = "SELECT COUNT(scFrameworkVersion) FROM SCFrameworkVersion scFrameworkVersion WHERE ";
2257            private static final String _SQL_GETSCPRODUCTVERSIONS = "SELECT {SCProductVersion.*} FROM SCProductVersion INNER JOIN SCFrameworkVersi_SCProductVers ON (SCFrameworkVersi_SCProductVers.productVersionId = SCProductVersion.productVersionId) WHERE (SCFrameworkVersi_SCProductVers.frameworkVersionId = ?)";
2258            private static final String _SQL_GETSCPRODUCTVERSIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCFrameworkVersi_SCProductVers WHERE frameworkVersionId = ?";
2259            private static final String _SQL_CONTAINSSCPRODUCTVERSION = "SELECT COUNT(*) AS COUNT_VALUE FROM SCFrameworkVersi_SCProductVers WHERE frameworkVersionId = ? AND productVersionId = ?";
2260            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "scFrameworkVersion.groupId = ?";
2261            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "scFrameworkVersion.companyId = ?";
2262            private static final String _FINDER_COLUMN_G_A_GROUPID_2 = "scFrameworkVersion.groupId = ? AND ";
2263            private static final String _FINDER_COLUMN_G_A_ACTIVE_2 = "scFrameworkVersion.active = ?";
2264            private static final String _FILTER_SQL_SELECT_SCFRAMEWORKVERSION_WHERE = "SELECT DISTINCT {scFrameworkVersion.*} FROM SCFrameworkVersion scFrameworkVersion WHERE ";
2265            private static final String _FILTER_SQL_COUNT_SCFRAMEWORKVERSION_WHERE = "SELECT COUNT(DISTINCT scFrameworkVersion.frameworkVersionId) AS COUNT_VALUE FROM SCFrameworkVersion scFrameworkVersion WHERE ";
2266            private static final String _FILTER_COLUMN_PK = "scFrameworkVersion.frameworkVersionId";
2267            private static final String _FILTER_COLUMN_USERID = "scFrameworkVersion.userId";
2268            private static final String _FILTER_ENTITY_ALIAS = "scFrameworkVersion";
2269            private static final String _ORDER_BY_ENTITY_ALIAS = "scFrameworkVersion.";
2270            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SCFrameworkVersion exists with the primary key ";
2271            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SCFrameworkVersion exists with the key {";
2272            private static Log _log = LogFactoryUtil.getLog(SCFrameworkVersionPersistenceImpl.class);
2273    }